use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.
the class TypeDescriptorExtractor method extract.
public TypeDescriptor extract(byte[] bytes, boolean isReloadableType) {
ClassReader fileReader = new ClassReader(bytes);
ExtractionVisitor extractionVisitor = new ExtractionVisitor(isReloadableType);
fileReader.accept(extractionVisitor, 0);
return extractionVisitor.getTypeDescriptor();
}
use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.
the class QuickVisitor method getImplementedInterfaces.
public static String[] getImplementedInterfaces(byte[] bytes) {
ClassReader fileReader = new ClassReader(bytes);
QuickVisitor1 qv = new QuickVisitor1();
try {
// TODO more flags to skip other things?
fileReader.accept(qv, ClassReader.SKIP_FRAMES);
} catch (EarlyExitException eee) {
}
return qv.interfaces;
}
use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.
the class SystemClassReflectionInvestigator method investigate.
public static int investigate(String slashedClassName, byte[] bytes, boolean print) {
ClassReader fileReader = new ClassReader(bytes);
RewriteClassAdaptor classAdaptor = new RewriteClassAdaptor(print);
fileReader.accept(classAdaptor, ClassReader.SKIP_FRAMES);
return classAdaptor.hitCount;
}
use of org.objectweb.asm.ClassReader in project spring-loaded by spring-projects.
the class GroovyPlugin method modify.
public byte[] modify(String slashedClassName, ClassLoader classLoader, byte[] bytes) {
if (allowCompilableCallSites) {
return modifyDefineInClassLoaderForClassArtifacts(bytes);
} else {
// Deactivate compilation
if (slashedClassName.equals("org/codehaus/groovy/runtime/callsite/GroovySunClassLoader")) {
// if (GlobalConfiguration.isRuntimeLogging && log.isLoggable(Level.INFO)) {
// log.info("loadtime modifying " + slashedClassName);
// }
ClassReader cr = new ClassReader(bytes);
NonFinalizer ca = new NonFinalizer("sunVM");
// ClassVisitingConstructorAppender ca = new ClassVisitingConstructorAppender("org/springsource/loaded/agent/SpringPlugin",
// "recordInstance");
cr.accept(ca, 0);
byte[] newbytes = ca.getBytes();
return newbytes;
} else {
// must be the CallSiteGenerator
ClassReader cr = new ClassReader(bytes);
FalseReturner ca = new FalseReturner("isCompilable");
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 PluginUtils method addInstanceTracking.
/**
* If adding instance tracking, the classToCall must implement:
* <tt>public static void recordInstance(Object obj)</tt>.
*
* @param bytes the bytes for the class to which instance tracking is being added
* @param classToCall the class to call when a new instance is created
* @return the modified bytes for the class
*/
public static byte[] addInstanceTracking(byte[] bytes, String classToCall) {
ClassReader cr = new ClassReader(bytes);
ClassVisitingConstructorAppender ca = new ClassVisitingConstructorAppender(classToCall, "recordInstance");
cr.accept(ca, 0);
byte[] newbytes = ca.getBytes();
return newbytes;
}
Aggregations