在下面的测试用例中,直接字段 t 没有被 CGLIB 截获。那么我可以使用CGLIB吗?
public class Test {
@Test
public void testCGLib() {
A a = (A) Enhancer.create(A.class, new Class[] {}, new B());
System.out.println(a.t);
a.t();
}
public static class A {
public int t = 0;
public void t() {
System.out.println("bbb");
}
}
public static class B implements LazyLoader {
@Override
public Object loadObject() throws Exception {
System.out.println("xxx");
return new A();
}
}
}