0 Replies Latest reply on Feb 13, 2017 3:59 AM by nitinl

    Javassist 3.20.0-GA, StackOverflowError with $sig in call to static method

    nitinl

      I'm getting a stackoverflow error on using $sig in a static method.

       

      Exception in thread "main" java.lang.StackOverflowError
              at javassist.runtime.Desc.getClassType(Desc.java:139)
              at javassist.runtime.Desc.getType(Desc.java:122)
              at javassist.runtime.Desc.getClassType(Desc.java:150)
              at javassist.runtime.Desc.getType(Desc.java:122)
              at javassist.runtime.Desc.getParams(Desc.java:70)
      

       

      Found the same question for version 3.15.0-GA here: https://developer.jboss.org/thread/176637 But it has no answer.

       

      Here's the code I'm injecting:

      method.insertBefore("System.out.println(com.example.MyClass.formatArgs($args, $sig));");
      

       

      And this is the body of the function formatArgs:

      public static String formatArgs(Object[] args, Class[] argTypes){
          try {
              StringBuilder result = new StringBuilder();
              result.append("Arguments:");
              for (int i = 0; i < args.length; ++i) {
                  result.append(" - type: ").append(argTypes[i]).append(", value: ").append(args[i]);
              }
              return result.toString();
          }
          catch (Throwable e){
              System.out.println("EXCEPTION in formatArgs");
              e.printStackTrace();
          }
          return "";
      }
      

       

      I'm using gradle 3.0, with Javassist version 3.20.0-GA. My run command is:

      java -Xbootclasspath/a:javassist-3.20.0-GA.jar -javaagent:myAgent.jar -jar myApp.jar
      

       

      How do I resolve this error?