增加Java源码编译器

This commit is contained in:
lzpeng723
2020-11-23 00:21:21 +08:00
parent 3bd15f999f
commit c92bdde0b3
9 changed files with 647 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package a;
import cn.hutool.core.lang.ConsoleTable;
import cn.hutool.core.lang.caller.CallerUtil;
public class A {
private class InnerClass {
}
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());
caller = CallerUtil.getCaller(++i);
}
t.print();
}};
}
}

View File

@@ -0,0 +1,8 @@
package b;
import a.A;
public class B {
public B() {
new A();
}
}

View File

@@ -0,0 +1,9 @@
package c;
import b.B;
public class C {
public C() {
new B();
}
}