[ https://issues.apache.org/jira/browse/BCEL-289?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16015502#comment-16015502 ]
ASF GitHub Bot commented on BCEL-289: ------------------------------------- GitHub user kinow opened a pull request: https://github.com/apache/commons-bcel/pull/13 BCEL-289: iterate through parameter annotation entries using the right limit The code was iterating through the number of parameters (3 in this case, the Bar parent class, and the two annotated parameters, while looking for annotated parameters. As the constructor method has two annotated parameters, it throws an ArrayIndexOutOfBoundsException. Found no pull requests with this fix, Maven site reports look OK, no new warnings/errors added, added a simple unit test. As I never contributed to BCEL, will drop a message to the mailing list asking for someone to review it before I merge it. Cheers Bruno You can merge this pull request into a Git repository by running: $ git pull https://github.com/kinow/commons-bcel BCEL-289 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/commons-bcel/pull/13.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #13 ---- commit d60291173e4d4a589873338547d968a540210507 Author: Bruno P. Kinoshita <brunodepau...@yahoo.com.br> Date: 2017-05-18T09:37:07Z BCEL-289: iterate through parameter annotation entries using the right limit ---- > Crash when parsing constructor of inner classes with parameters annotated > ------------------------------------------------------------------------- > > Key: BCEL-289 > URL: https://issues.apache.org/jira/browse/BCEL-289 > Project: Commons BCEL > Issue Type: Bug > Components: Parser > Affects Versions: 6.0 > Reporter: Pietro Ferrara > Priority: Critical > Fix For: 6.1 > > > 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: > {code:java} > public @interface A {} > public @interface B {} > public class Test { > public class Inner { > public Inner(@A Object a, @B Object b) {} > } > } > {code} > In particular: > {code:java} > 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); > {code} > (where args\[0\] points to Test$Inner.class) > you get > {noformat} > 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) > {noformat} -- This message was sent by Atlassian JIRA (v6.3.15#6346)