use of org.objectweb.asm.commons.JSRInlinerAdapter in project lombok by rzwitserloot.
the class AsmUtil method fixJSRInlining.
static byte[] fixJSRInlining(byte[] byteCode) {
ClassReader reader = new ClassReader(byteCode);
ClassWriter writer = new FixedClassWriter(reader, 0);
ClassVisitor visitor = new ClassVisitor(Opcodes.ASM6, writer) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
return new JSRInlinerAdapter(super.visitMethod(access, name, desc, signature, exceptions), access, name, desc, signature, exceptions);
}
};
reader.accept(visitor, 0);
return writer.toByteArray();
}
use of org.objectweb.asm.commons.JSRInlinerAdapter in project evosuite by EvoSuite.
the class JSRInlinerClassVisitor method visitMethod.
/**
* {@inheritDoc}
*/
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, final String[] exceptions) {
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
mv = new JSRInlinerAdapter(mv, access, name, desc, signature, exceptions);
return mv;
}
use of org.objectweb.asm.commons.JSRInlinerAdapter in project CodenameOne by codenameone.
the class Parser method visitMethod.
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
BytecodeMethod mtd = new BytecodeMethod(clsName, access, name, desc, signature, exceptions);
cls.addMethod(mtd);
JSRInlinerAdapter a = new JSRInlinerAdapter(new MethodVisitorWrapper(super.visitMethod(access, name, desc, signature, exceptions), mtd), access, name, desc, signature, exceptions);
return a;
}
use of org.objectweb.asm.commons.JSRInlinerAdapter in project robolectric by robolectric.
the class ClassInstrumentor method analyzeClass.
private MutableClass analyzeClass(byte[] origClassBytes, final InstrumentationConfiguration config, ClassNodeProvider classNodeProvider) {
ClassNode classNode = new ClassNode(Opcodes.ASM4) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodVisitor methodVisitor = super.visitMethod(access, name, config.remapParams(desc), signature, exceptions);
return new JSRInlinerAdapter(methodVisitor, access, name, desc, signature, exceptions);
}
};
final ClassReader classReader = new ClassReader(origClassBytes);
classReader.accept(classNode, 0);
return new MutableClass(classNode, config, classNodeProvider);
}
use of org.objectweb.asm.commons.JSRInlinerAdapter in project quasar by puniverse.
the class InstrumentClass method visitMethod.
@Override
public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
SuspendableType markedSuspendable = null;
if (suspendableInterface)
markedSuspendable = SuspendableType.SUSPENDABLE_SUPER;
if (markedSuspendable == null)
markedSuspendable = classifier.isSuspendable(db, sourceName, sourceDebugInfo, isInterface, className, classEntry.getSuperName(), classEntry.getInterfaces(), name, desc, signature, exceptions);
final SuspendableType setSuspendable = classEntry.check(name, desc);
if (setSuspendable == null)
classEntry.set(name, desc, markedSuspendable != null ? markedSuspendable : SuspendableType.NON_SUSPENDABLE);
final SuspendableType suspendable = max(markedSuspendable, setSuspendable, SuspendableType.NON_SUSPENDABLE);
if (checkAccessForMethodVisitor(access) && !isYieldMethod(className, name)) {
if (methods == null)
methods = new ArrayList<>();
final MethodNode mn = new MethodNode(access, name, desc, signature, exceptions);
return new MethodVisitor(ASMAPI, mn) {
private SuspendableType susp = suspendable;
private boolean commited = false;
@Override
public AnnotationVisitor visitAnnotation(String adesc, boolean visible) {
// look for @Suspendable or @DontInstrument annotation
if (adesc.equals(SUSPENDABLE_DESC))
susp = SuspendableType.SUSPENDABLE;
else if (adesc.equals(DONT_INSTRUMENT_DESC))
susp = SuspendableType.NON_SUSPENDABLE;
susp = suspendableToSuperIfAbstract(access, susp);
return super.visitAnnotation(adesc, visible);
}
@Override
public void visitCode() {
commit();
super.visitCode();
}
@Override
public void visitEnd() {
if (exception != null)
return;
commit();
try {
super.visitEnd();
} catch (RuntimeException e) {
exception = e;
}
}
private void commit() {
if (commited)
return;
commited = true;
if (db.isDebug())
db.log(LogLevel.INFO, "Method %s#%s%s suspendable: %s (markedSuspendable: %s setSuspendable: %s)", className, name, desc, susp, susp, setSuspendable);
classEntry.set(name, desc, susp);
if (susp == SuspendableType.SUSPENDABLE && checkAccessForMethodInstrumentation(access)) {
if (isSynchronized(access)) {
if (!db.isAllowMonitors())
throw new UnableToInstrumentException("synchronization", className, name, desc);
else
db.log(LogLevel.WARNING, "Method %s#%s%s is synchronized", className, name, desc);
}
methods.add(mn);
} else {
MethodVisitor _mv = makeOutMV(mn);
_mv = new JSRInlinerAdapter(_mv, access, name, desc, signature, exceptions);
mn.accept(new MethodVisitor(ASMAPI, _mv) {
@Override
public void visitEnd() {
// don't call visitEnd on MV
}
});
// write method as-is
this.mv = _mv;
}
}
};
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
Aggregations