Instrumenting java core libraries
When we compile a java program, we get .class files. Can I access these .class files of java core libraries? e.g. can I have access to java.lang.String.class ?
Actually I am doing a research and trying to开发者_运维知识库 find branch coverage of some java core libraries. The tool I am using for branch coverage actually instruments the .class files.
Thanks
It's in rt.jar
in your JRE directory. You've even got the sources in src.zip
. (Or you could just pull the latest version of OpenJDK.)
Also, if you want to instrument the base classes, you'll also need to specify a boot classpath. Look at the -Xbootclasspath
option for java
: http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html
Sure, it's right there, in jre/lib/rt.jar
inside your JAVA_HOME
Yes, the class files are inside the #{JDK INSTALL PATH}/jre/lib/rt.jar archive. Or if you use an IDE like Eclipse you can ctrl+click on any string method, or on "String" in declarations like private String var;
to open that class.
精彩评论