use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.
the class SpringPlugin method bytesWithInstanceCreationCaptured.
/**
* Modify the supplied bytes such that constructors are intercepted and will invoke the specified class/method so
* that the instances can be tracked.
*
* @return modified bytes for the class
*/
private byte[] bytesWithInstanceCreationCaptured(byte[] bytes, String classToCall, String methodToCall) {
ClassReader cr = new ClassReader(bytes);
ClassVisitingConstructorAppender ca = new ClassVisitingConstructorAppender(classToCall, methodToCall);
cr.accept(ca, 0);
byte[] newbytes = ca.getBytes();
return newbytes;
}
use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.
the class EmptyCtor method invoke.
/**
* Empty the constructors with the specified descriptors.
*
* @param bytesIn input class as bytes
* @param descriptors descriptors of interest (e.g. "()V")
* @return modified class as byte array
*/
public static byte[] invoke(byte[] bytesIn, String... descriptors) {
ClassReader cr = new ClassReader(bytesIn);
EmptyCtor ca = new EmptyCtor(descriptors);
cr.accept(ca, 0);
byte[] newbytes = ca.getBytes();
return newbytes;
}
use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.
the class ClassPrinter method print.
public static void print(byte[] bytes, boolean includeBytecode) {
ClassReader reader = new ClassReader(bytes);
reader.accept(new ClassPrinter(System.out, includeBytecode ? INCLUDE_BYTECODE : 0), 0);
}
use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.
the class ClassPrinter method print.
public static void print(byte[] bytes, int includeFlags) {
ClassReader reader = new ClassReader(bytes);
reader.accept(new ClassPrinter(System.out, includeFlags), 0);
}
use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.
the class ClassPrinter method print.
public static void print(PrintStream printStream, byte[] bytes, boolean includeBytecode) {
ClassReader reader = new ClassReader(bytes);
reader.accept(new ClassPrinter(printStream, includeBytecode ? INCLUDE_BYTECODE : 0), 0);
}
Aggregations