Uploaded image for project: 'Commons BCEL'
  1. Commons BCEL
  2. BCEL-289

Crash when parsing constructor of inner classes with parameters annotated

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 6.0
    • 6.1
    • Parser
    • None

    Description

      BCEL crashes when parsing the constructor of an inner class whose parameters are annotated. For instance, when parsing the jar obtained from the following classes:

      public @interface A {}
      public @interface B {}
      public class Test {
          public class Inner {
      	public Inner(@A Object a, @B Object b) {}
          }
      }
      

      In particular:

      		ClassParser cp = new ClassParser(args[0]);
      		ClassGen cg = new ClassGen(cp.parse());
      		MethodGen mg = new MethodGen(cg.getMethodAt(0), cg.getClassName(), cg.getConstantPool());
      		mg.getAnnotationsOnParameter(0);
      

      (where args[0] points to Test$Inner.class)

      you get

      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
      	at org.apache.bcel.generic.MethodGen.ensureExistingParameterAnnotationsUnpacked(MethodGen.java:1120)
      	at org.apache.bcel.generic.MethodGen.getAnnotationsOnParameter(MethodGen.java:1073)
      

      Attachments

        Activity

          People

            kinow Bruno P. Kinoshita
            pferrara Pietro Ferrara
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: