in core/src/main/java/com/spotify/missinglink/ClassLoader.java [144:196]
private static void analyseMethod(
String className,
MethodNode method,
Map<MethodDescriptor, DeclaredMethod> declaredMethods,
Set<ClassTypeDescriptor> loadedClasses) {
final Set<CalledMethod> thisCalls = new HashSet<>();
final Set<AccessedField> thisFields = new HashSet<>();
int lineNumber = 0;
final List<AbstractInsnNode> instructions = toList(method.instructions.iterator());
for (final AbstractInsnNode insn : instructions) {
try {
if (insn instanceof LineNumberNode) {
lineNumber = ((LineNumberNode) insn).line;
}
if (insn instanceof MethodInsnNode) {
handleMethodCall(
thisCalls,
lineNumber,
(MethodInsnNode) insn,
getTryCatchBlocksProtecting(instructions, insn, method));
}
if (insn instanceof FieldInsnNode) {
handleFieldAccess(
thisFields,
lineNumber,
(FieldInsnNode) insn,
getTryCatchBlocksProtecting(instructions, insn, method));
}
if (insn instanceof LdcInsnNode) {
handleLdc(loadedClasses, (LdcInsnNode) insn);
}
} catch (Exception e) {
throw new MissingLinkException(
"Error analysing " + className + "." + method.name + ", line: " + lineNumber, e);
}
}
final DeclaredMethod declaredMethod =
new DeclaredMethodBuilder()
.descriptor(MethodDescriptors.fromDesc(method.desc, method.name))
.lineNumber(lineNumber)
.methodCalls(thisCalls)
.fieldAccesses(thisFields)
.isStatic((method.access & Opcodes.ACC_STATIC) != 0)
.build();
if (declaredMethods.put(declaredMethod.descriptor(), declaredMethod) != null) {
throw new RuntimeException(
"Multiple definitions of " + declaredMethod.descriptor() + " in class " + className);
}
}