Bytecode Instrumentation

| 2004 JavaOne
SM
Conference | Session 3042 Copyright Hewlett Packard Co., 2004.
17
Creating Instrumentation Hooks (pre-5.0)
Experience with BCEL and class loaders [McPhail]
Custom class loader
Finds, instruments, and loads class before system class loader
System classes (java.* and javax.*) still loaded by the system
class loader
Type problem with classes loaded by both class loaders –
ClassCastException
Hidden classpath
Follows delegation model for class loading
Requires the classes be found through some mechanism other
than the classpath
Does not work if software expects to find classes or resources
in the classpath
Remedy by creating class loader with parent set to
getClass().getClassLoader() instead of the system class
loader