Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException being thrown. #30

Open
thisissvikas opened this issue Sep 11, 2019 · 1 comment
Open

ArrayIndexOutOfBoundsException being thrown. #30

thisissvikas opened this issue Sep 11, 2019 · 1 comment

Comments

@thisissvikas
Copy link

image

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?

@nevesnunes
Copy link

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);
             }
         }
+    }

pombredanne pushed a commit to pombredanne/java-callgraph that referenced this issue May 29, 2024
* Added updated patch file w/ Naive List gen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants