mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
Merge pull request #2942 from xuwenping123/v5_dev_compile
add source code for dynamic compile
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package error;
|
||||
|
||||
public class ErrorClazz {
|
||||
|
||||
public static void 123main(String[] args) {
|
||||
System.out.println("hello world");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user