mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -2,8 +2,10 @@ package cn.hutool.core.compiler;
|
||||
|
||||
import cn.hutool.core.compress.ZipUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.reflect.ConstructorUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
@@ -16,6 +18,13 @@ import java.io.InputStream;
|
||||
*/
|
||||
public class JavaSourceCompilerTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void compilerATest(){
|
||||
final boolean compile = CompilerUtil.compile(FileUtil.file("test-compile/a/A.java").getAbsolutePath());
|
||||
Assert.assertTrue(compile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试编译Java源码
|
||||
*/
|
||||
@@ -29,6 +38,7 @@ public class JavaSourceCompilerTest {
|
||||
FileUtil.getInputStream("test-compile/a/A$1.class"),
|
||||
FileUtil.getInputStream("test-compile/a/A$InnerClass.class")
|
||||
});
|
||||
Console.log(libFile.getAbsolutePath());
|
||||
final ClassLoader classLoader = CompilerUtil.getCompiler(null)
|
||||
.addSource(FileUtil.file("test-compile/b/B.java"))
|
||||
.addSource("c.C", FileUtil.readUtf8String("test-compile/c/C.java"))
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package a;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.lang.ConsoleTable;
|
||||
import cn.hutool.core.lang.caller.CallerUtil;
|
||||
|
||||
@@ -10,15 +11,12 @@ public class A {
|
||||
public A() {
|
||||
new InnerClass() {{
|
||||
int i = 0;
|
||||
Class<?> caller = CallerUtil.getCaller(i);
|
||||
final ConsoleTable t = new ConsoleTable();
|
||||
t.addHeader("类名", "类加载器");
|
||||
System.out.println("初始化 " + getClass() + " 的调用链为: ");
|
||||
while (caller != null) {
|
||||
t.addBody(caller.toString(), caller.getClassLoader().toString());
|
||||
Console.log("初始化 " + getClass() + " 的调用链为: ");
|
||||
Class<?> caller = CallerUtil.getCaller(i);
|
||||
while (caller != null) {
|
||||
Console.log("{} {}", caller, caller.getClassLoader());
|
||||
caller = CallerUtil.getCaller(++i);
|
||||
}
|
||||
t.print();
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user