Skip to content

Commit

Permalink
Update to latest TeaVM
Browse files Browse the repository at this point in the history
 - Add the core TeaVM jar to the runtime the classpath, to ensure
   various runtime classes are present.
 - Fix computer initialisation errors not being displayed on the screen.
   The terminal was set to the default 0x0 size when logging the error,
   and so never displayed anything!
  • Loading branch information
SquidDev committed Apr 17, 2024
1 parent 03bb279 commit 776fa00
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ minotaur = "2.+"
nullAway = "0.10.25"
spotless = "6.23.3"
taskTree = "2.1.1"
teavm = "0.10.0-SQUID.3"
teavm = "0.10.0-SQUID.4"
vanillaExtract = "0.1.2"
versionCatalogUpdate = "0.8.1"

Expand Down Expand Up @@ -154,6 +154,7 @@ minotaur = { module = "com.modrinth.minotaur:Minotaur", version.ref = "minotaur"
nullAway = { module = "com.uber.nullaway:nullaway", version.ref = "nullAway" }
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" }
teavm-classlib = { module = "org.teavm:teavm-classlib", version.ref = "teavm" }
teavm-core = { module = "org.teavm:teavm-core", version.ref = "teavm" }
teavm-jso = { module = "org.teavm:teavm-jso", version.ref = "teavm" }
teavm-jso-apis = { module = "org.teavm:teavm-jso-apis", version.ref = "teavm" }
teavm-jso-impl = { module = "org.teavm:teavm-jso-impl", version.ref = "teavm" }
Expand Down
1 change: 1 addition & 0 deletions projects/web/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
implementation(libs.guava)
implementation(libs.netty.http)
implementation(libs.slf4j)
runtimeOnly(libs.teavm.core) // Contains the TeaVM runtime

"builderCompileOnly"(libs.bundles.annotations)
"builderImplementation"(libs.bundles.teavm.tooling)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,18 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {

@Override
public @Nullable InputStream getResourceAsStream(String name) {
if (!name.endsWith(".class")) return super.getResourceAsStream(name);
if (!name.endsWith(".class") || name.startsWith("java/") || name.startsWith("javax/")) {
return super.getResourceAsStream(name);
}

var lastFile = this.lastFile;
if (lastFile != null && lastFile.name().equals(name)) return new ByteArrayInputStream(lastFile.contents());

var path = findFile(name);
if (path == null) return null;
if (path == null) {
System.out.printf("Cannot find %s. Falling back to system class loader.\n", name);
return super.getResourceAsStream(name);
}

ClassReader reader;
try (var stream = Files.newInputStream(path)) {
Expand Down
6 changes: 6 additions & 0 deletions projects/web/src/frontend/emu/computer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class EmulatedComputer implements ComputerDisplay, ComputerActionable {
for (const callback of this.callbacks) callback(computer);
})
.catch(e => {
console.error(e);

if (this.terminal.sizeX === 0 || this.terminal.sizeY === 0) this.terminal.resize(51, 19);

const width = this.terminal.sizeX;
const fg = "0".repeat(width);
const bg = "e".repeat(width);
Expand All @@ -83,6 +87,8 @@ class EmulatedComputer implements ComputerDisplay, ComputerActionable {
this.terminal.fore[y] = fg;
this.terminal.back[y] = bg;
}

this.flushTerminal();
});
}

Expand Down

0 comments on commit 776fa00

Please sign in to comment.