|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.curjent.agent.DelegatingLoader
public class DelegatingLoader
Delegates class creation and loading to an existing ClassLoader
.
See the class description for AgentLoader
.
Field Summary | |
---|---|
private ClassLoader |
classLoader
Class loader whose 'defineClass' method is called. |
private Method |
defineClass
Cached 'defineClass' method of classLoader . |
Constructor Summary | |
---|---|
DelegatingLoader(Class<?> type)
Equivalent to DelegatingLoader(type.getClassLoader()) . |
|
DelegatingLoader(ClassLoader classLoader)
Initializes this instance with the given classLoader for
creating and loading generated classes. |
|
DelegatingLoader(Object instance)
Equivalent to DelegatingLoader(instance.getClass().getClassLoader()) . |
Method Summary | |
---|---|
Class<?> |
defineClass(String name,
byte[] bytes)
Uses the previously cached defineClass method to create a
generated class. |
ClassLoader |
getClassLoader()
Returns the classLoader instance this instance was
constructed with. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final ClassLoader classLoader
private final Method defineClass
classLoader
.
Constructor Detail |
---|
public DelegatingLoader(Object instance)
DelegatingLoader(instance.getClass().getClassLoader())
.
DelegatingLoader(ClassLoader)
public DelegatingLoader(Class<?> type)
DelegatingLoader(type.getClassLoader())
.
DelegatingLoader(ClassLoader)
public DelegatingLoader(ClassLoader classLoader)
classLoader
for
creating and loading generated classes. Reflection is used during
construction to find and cache the loader's defineClass
method.
NullPointerException
- classLoader == null
IllegalArgumentException
- defineClass(String, byte[], int, int)
not found in the class of the given classLoader
SecurityException
- Reflection is restricted by security settings.Method Detail |
---|
public ClassLoader getClassLoader()
classLoader
instance this instance was
constructed with.
getClassLoader
in interface AgentLoader
DelegatingLoader(ClassLoader)
public Class<?> defineClass(String name, byte[] bytes)
defineClass
method to create a
generated class.
defineClass
in interface AgentLoader
name
- The class's fully qualified name.bytes
- The generated bytecodes for the class. The offset is
0
, and the length is equal to bytes.length
.
IllegalStateException
- Wraps as the cause an
IllegalAccessException
thrown because the
defineClass
method is not accessible.
AgentException
- Wraps as the cause an exception thrown by the
defineClass
method.DelegatingLoader(ClassLoader)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |