use of org.objectweb.asm.tree.LineNumberNode in project bytecode-viewer by Konloch.
the class InstructionSearcher method search.
public boolean search() {
for (AbstractInsnNode ain : insns.toArray()) {
if (ain instanceof LineNumberNode || ain instanceof FrameNode)
continue;
if (pattern.accept(ain)) {
matches.add(pattern.getLastMatch());
pattern.resetMatch();
}
}
return size() != 0;
}
use of org.objectweb.asm.tree.LineNumberNode in project atlas by alibaba.
the class TBIncrementalSupportVisitor method visitMethod.
/**
* Insert Constructor specific logic({@link ConstructorRedirection} and
* {@link ConstructorBuilder}) for constructor redirecting or
* normal method redirecting ({@link MethodRedirection}) for other methods.
*/
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
access = transformAccessForInstantRun(access);
MethodVisitor defaultVisitor = super.visitMethod(access, name, desc, signature, exceptions);
MethodNode method = checkNotNull(getMethodByNameInClass(name, desc, classNode), "Method found by visitor but not in the pre-parsed class node.");
if (!supportAddCallSuper) {
method.instructions.accept(new MethodVisitor(api) {
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
if (opcode == Opcodes.INVOKESPECIAL && !owner.equals(visitedClassName)) {
visitSuperMethods.add(name + "." + desc);
}
super.visitMethodInsn(opcode, owner, name, desc, itf);
}
});
}
if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
return defaultVisitor;
}
boolean hasIncompatibleChange = InstantRunMethodVerifier.verifyMethod(method) != InstantRunVerifierStatus.COMPATIBLE;
if (hasIncompatibleChange || disableRedirectionForClass || !isAccessCompatibleWithInstantRun(access) || name.equals(ByteCodeUtils.CLASS_INITIALIZER)) {
return defaultVisitor;
} else {
ArrayList<Type> args = new ArrayList<>(Arrays.asList(Type.getArgumentTypes(desc)));
boolean isStatic = (access & Opcodes.ACC_STATIC) != 0;
if (!isStatic) {
args.add(0, Type.getType(Object.class));
}
// Install the Jsr/Ret inliner adapter, we have had reports of code still using the
// Jsr/Ret deprecated byte codes.
// see https://code.google.com/p/android/issues/detail?id=220019
JSRInlinerAdapter jsrInlinerAdapter = new JSRInlinerAdapter(defaultVisitor, access, name, desc, signature, exceptions);
ISMethodVisitor mv = new ISMethodVisitor(jsrInlinerAdapter, access, name, desc);
if (name.equals(ByteCodeUtils.CONSTRUCTOR)) {
if (patchInitMethod) {
Constructor constructor = ConstructorBuilder.build(visitedClassName, method);
LabelNode start = new LabelNode();
method.instructions.insert(constructor.loadThis, start);
if (constructor.lineForLoad != -1) {
// Record the line number from the start of LOAD_0 for uninitialized 'this'.
// This allows a breakpoint to be set at the line with this(...) or super(...)
// call in the constructor.
method.instructions.insert(constructor.loadThis, new LineNumberNode(constructor.lineForLoad, start));
}
mv.addRedirection(new TBConstructorRedirection(start, constructor, args));
} else {
return defaultVisitor;
}
} else {
mv.addRedirection(new TBMethodRedirection(new LabelNode(mv.getStartLabel()), name + "." + desc, args, Type.getReturnType(desc)));
}
method.accept(mv);
return null;
}
}
Aggregations