WEB开发网
开发学院软件开发Java Java 编程的动态性,第 6 部分: 利用 Javassist 进... 阅读

Java 编程的动态性,第 6 部分: 利用 Javassist 进行面向方面的更改

 2010-03-18 00:00:00 来源:WEB开发网   
核心提示: 清单 4 显示了对 清单 2 中的 BeanTest 程序运行清单 3 中的 Dissect 程序所产生的输出,它给出了加载的每一个类的每一个方法中所做的工作的详细分析,列出了所有方法调用、字段访问和新对象创建,Java 编程的动态性,第 6 部分: 利用 Javassist 进行面向方面的更改

清单 4 显示了对 清单 2 中的 BeanTest 程序运行清单 3 中的 Dissect 程序所产生的输出。它给出了加载的每一个类的每一个方法中所做的工作的详细分析,列出了所有方法调用、字段访问和新对象创建。

清单 4. 已剖析的 BeanTest

[dennis]$ java -cp .:javassist.jar Dissect BeanTest 
Dissecting class BeanTest 
 new Bean in BeanTest(BeanTest.java:7) 
 write of BeanTest.m_bean in BeanTest(BeanTest.java:7) 
 read of java.lang.System.out in print(BeanTest.java:11) 
 new java.lang.StringBuffer in print(BeanTest.java:11) 
 call to java.lang.StringBuffer.append in print(BeanTest.java:11) 
 read of BeanTest.m_bean in print(BeanTest.java:11) 
 call to Bean.getA in print(BeanTest.java:11) 
 call to java.lang.StringBuffer.append in print(BeanTest.java:11) 
 call to java.lang.StringBuffer.append in print(BeanTest.java:11) 
 read of BeanTest.m_bean in print(BeanTest.java:11) 
 call to Bean.getB in print(BeanTest.java:11) 
 call to java.lang.StringBuffer.append in print(BeanTest.java:11) 
 call to java.lang.StringBuffer.toString in print(BeanTest.java:11) 
 call to java.io.PrintStream.println in print(BeanTest.java:11) 
 read of BeanTest.m_bean in changeValues(BeanTest.java:16) 
 new java.lang.StringBuffer in changeValues(BeanTest.java:16) 
 call to java.lang.StringBuffer.append in changeValues(BeanTest.java:16) 
 call to java.lang.StringBuffer.append in changeValues(BeanTest.java:16) 
 call to java.lang.StringBuffer.toString in changeValues(BeanTest.java:16) 
 call to Bean.setA in changeValues(BeanTest.java:16) 
 read of BeanTest.m_bean in changeValues(BeanTest.java:17) 
 new java.lang.StringBuffer in changeValues(BeanTest.java:17) 
 call to java.lang.StringBuffer.append in changeValues(BeanTest.java:17) 
 call to java.lang.StringBuffer.append in changeValues(BeanTest.java:17) 
 call to java.lang.StringBuffer.toString in changeValues(BeanTest.java:17) 
 call to Bean.setB in changeValues(BeanTest.java:17) 
 new BeanTest in main(BeanTest.java:21) 
 call to BeanTest.print in main(BeanTest.java:22) 
 call to BeanTest.changeValues in main(BeanTest.java:23) 
 call to BeanTest.print in main(BeanTest.java:24) 
Dissecting class Bean 
 write of Bean.m_a in Bean(Bean.java:10) 
 write of Bean.m_b in Bean(Bean.java:11) 
 read of Bean.m_a in getA(Bean.java:15) 
 read of Bean.m_b in getB(Bean.java:19) 
 write of Bean.m_a in setA(Bean.java:23) 
 write of Bean.m_b in setB(Bean.java:27) 
Bean values are originalA and originalB 
Bean values are newA and newB 

上一页  2 3 4 5 6 7 8 9  下一页

Tags:Java 编程 动态性

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接