Update to latest TeaVM

- 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!
This commit is contained in:
Jonathan Coates 2024-04-17 21:57:11 +01:00
parent 03bb279206
commit 776fa00b94
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
4 changed files with 16 additions and 3 deletions

View File

@ -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"
@ -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" }

View File

@ -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)

View File

@ -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)) {

View File

@ -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);
@ -83,6 +87,8 @@ class EmulatedComputer implements ComputerDisplay, ComputerActionable {
this.terminal.fore[y] = fg;
this.terminal.back[y] = bg;
}
this.flushTerminal();
});
}