use of com.newrelic.agent.deps.org.objectweb.asm.AnnotationVisitor in project newrelic-java-agent by newrelic.
the class WeavingClassLoader method usesWeaver.
public static boolean usesWeaver(byte[] classBytes) {
ClassReader reader = new ClassReader(classBytes);
final boolean[] foundWeaveAnnotation = { false };
reader.accept(new ClassVisitor(WeaveUtils.ASM_API_LEVEL) {
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
if (desc.equals(WeaveClassInfo.WEAVE_DESC) || desc.equals(WeaveClassInfo.SKIP_IF_PRESENT_DESC) || desc.equals(SCALA_WEAVE_DESC) || desc.equals(WeaveClassInfo.WEAVE_ANNOTATED_TYPE_DESC)) {
foundWeaveAnnotation[0] = true;
}
return null;
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
return new MethodVisitor(WeaveUtils.ASM_API_LEVEL, mv) {
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
if (desc.equals(WeaveClassInfo.WEAVE_ANNOTATED_TYPE_DESC)) {
foundWeaveAnnotation[0] = true;
}
return null;
}
};
}
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
return foundWeaveAnnotation[0];
}
Aggregations