MethodVisitor (int access, final String name, final String methodDescriptor, String signature, String[] exceptions) { return new MethodVisitor(Opcodes.API_VERSION) { private final MethodKey methodKey = new MethodKey(name, methodDescriptor); private boolean annotated = false; private boolean firstLineNumberVisited = false; @Override public AnnotationVisitor visitAnnotation(String annotationDescriptor, boolean visible) { for (TMHAssertionGenerator assertionGenerator : assertionGenerators) { if (assertionGenerator.isMyAnnotation(annotationDescriptor)) { return assertionGenerator.getAnnotationChecker(Opcodes.API_VERSION, () -> { annotatedMethods.put(methodKey, new InstrumentationInfo(assertionGenerator)); annotated = true; }); } } return super.visitAnnotation(annotationDescriptor, visible); } @Override public void visitLineNumber(int line, Label start) { super.visitLineNumber(line, start); if (annotated && !firstLineNumberVisited) { annotatedMethods.get(methodKey).methodStartLineNumber = line; firstLineNumberVisited = true; } } }; }