Merge branch 'targetBytecode' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into targetBytecode

This commit is contained in:
pl@gohorb.ba-horb.de 2023-10-27 21:19:30 +02:00
commit c51190feef
3 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,9 @@
import java.lang.System;
import java.lang.String;
import java.io.PrintStream;
public class HelloWorld {
static hello() {
System.out.println("Hello World!");
}
}

View File

@ -119,6 +119,10 @@ public class JavaTXCompiler {
if (clazz.getClassName().equals(name)) return clazz;
}
}
try {
var clazz = classLoader.loadClass(name.toString());
return ASTFactory.createClass(clazz);
} catch (ClassNotFoundException ignored) {}
return null;
}

View File

@ -763,4 +763,12 @@ public class TestComplete {
var m = clazz.getDeclaredMethod("m");
assertEquals(m.invoke(instance), 5);
}
@Test
public void testHelloWorld() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "HelloWorld.jav");
var clazz = classFiles.get("HelloWorld");
var hello = clazz.getDeclaredMethod("hello");
hello.invoke(null);
}
}