Class InstrumentationProvider
java.lang.Object
org.jrd.agent.InstrumentationProvider
This class stores instrumentation and transformer objects and handles the
transformation, retrieval of bytecode and class names.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate final Instrumentationprivate final Stringprivate final Stringprivate final Transformer -
Constructor Summary
ConstructorsConstructorDescriptionInstrumentationProvider(Instrumentation inst, Transformer transformer, String loneliness, String origArgs) -
Method Summary
Modifier and TypeMethodDescriptionvoidTis was originally solved by custom classloader which had map(string, byte[]) and map(string, clazz).voidprivate static booleanclassloaderMatches(String classlaoder, Class loadedClass) intcleanOverrides(String pattern) voiddetach()private Classbyte[]findClassBody(String className, String classloader) Finds class object corresponding to the class name and returns its bytecode.(package private) byte[]getClassBody(Class clazz, String classloader) voidgetClasses(BlockingQueue<String> queue, Boolean abort, boolean doGetInfo, Optional<ClassFilter> filter, String classlaoder) Inserts names of classes into queue.voidgetOverrides(BlockingQueue<String> queue) voidsetClassBody(String cname, byte[] nwBody, String classloader)
-
Field Details
-
transformer
-
instrumentation
-
loneliness
-
origArgs
-
INFO_DELIMITER
- See Also:
-
-
Constructor Details
-
InstrumentationProvider
InstrumentationProvider(Instrumentation inst, Transformer transformer, String loneliness, String origArgs)
-
-
Method Details
-
setClassBody
public void setClassBody(String cname, byte[] nwBody, String classloader) throws UnmodifiableClassException - Throws:
UnmodifiableClassException
-
getClassBody
- Throws:
UnmodifiableClassException
-
findClassBody
Finds class object corresponding to the class name and returns its bytecode.- Parameters:
className- name of class we want to get- Returns:
- bytecode of given class
- Throws:
UnmodifiableClassException- if the class can not be re-transformed
-
findClass
-
getClasses
public void getClasses(BlockingQueue<String> queue, Boolean abort, boolean doGetInfo, Optional<ClassFilter> filter, String classlaoder) throws InterruptedException Inserts names of classes into queue. Stops execution when it receives abort signal.- Parameters:
queue- output queueabort- abort signal- Throws:
InterruptedException- interrupted exception
-
classloaderMatches
-
getOverrides
- Throws:
InterruptedException
-
cleanOverrides
-
detach
public void detach() -
addClass
public void addClass(String className, byte[] b) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException Tis was originally solved by custom classloader which had map(string, byte[]) and map(string, clazz). However such class, although visible in class listing and by decompilers, was not usable in tunrime compilation, nor eg initialized by class.forName. The class.forName is good test or the class being correctly loadedThe reflection could be avoided by doing fake classlaoder which was publishing defineClass method and friends, but they are final now
Waring! Do not work with target process JDK17, that would eed --add-opens java.base or similar:(
-
addJar
- Throws:
IOException
-