2
在下面的測試用例中,直接字段t不被CGLIB攔截。 那麼我可以使用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();
}
}
}