java-callgraph
java-callgraph copied to clipboard
ArrayIndexOutOfBoundsException being thrown.

Seeing this exception when running the javacg-0.1-SNAPSHOT-static.jar on my project's jar.
Can you please explain under what scenario can this be coming?
I was able to reproduce this issue with the following:
- Method = static Class[] getClassesFromContextPath(String contextPath, ClassLoader classLoader) throws Exceptions: javax.xml.bind.JAXBException
- Class =javax.xml.bind.ModuleUtil extends java.lang.Object
- Jar = ./jakarta.xml.bind-api-2.3.3.jar
- Bytecode line = invokedynamic 0:makeConcatWithConstants (Ljava/lang/String;)Ljava/lang/String; (10)
The retrieveCalls() method expects bootstrap methods to always contain more than one argument, but in this case only one is parsed, as seen in the objects contained in boots variable:
[BootstrapMethod(137, 1, [138]), BootstrapMethod(137, 1, [155]), BootstrapMethod(137, 1, [167])]
My workaround is to ignore these cases:
--- a/src/main/java/gr/gousiosg/javacg/stat/DynamicCallManager.java
+++ b/src/main/java/gr/gousiosg/javacg/stat/DynamicCallManager.java
@@ -81,12 +81,14 @@ public class DynamicCallManager {
while (matcher.find()) {
int bootIndex = Integer.parseInt(matcher.group(1));
BootstrapMethod bootMethod = boots[bootIndex];
+ if (bootMethod.getBootstrapArguments().length > 1) {
int calledIndex = bootMethod.getBootstrapArguments()[CALL_HANDLE_INDEX_ARGUMENT];
String calledName = getMethodNameFromHandleIndex(cp, calledIndex);
String callerName = method.getName();
dynamicCallers.put(calledName, callerName);
}
}
+ }