add source code for dynamic compile

This commit is contained in:
xuwenping
2023-03-02 22:45:33 +08:00
parent f5cb27a608
commit f0d94c9806
3 changed files with 32 additions and 3 deletions

View File

@@ -40,4 +40,17 @@ public class JavaSourceCompilerTest {
Assert.assertTrue(String.valueOf(obj).startsWith("c.C@"));
}
@Test
public void testErrorCompile() {
Exception exception = null;
try {
CompilerUtil.getCompiler(null)
.addSource(FileUtil.file("test-compile/error/ErrorClazz.java"))
.compile();
} catch (Exception ex) {
exception = ex;
} finally {
Assert.assertTrue(exception instanceof CompilerException);
}
}
}

View File

@@ -0,0 +1,8 @@
package error;
public class ErrorClazz {
public static void 123main(String[] args) {
System.out.println("hello world");
}
}