You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Emmanuel Bourg (JIRA)" <ji...@apache.org> on 2014/04/24 14:57:21 UTC

[jira] [Updated] (BCEL-26) StackMapType.printIndex fails if index is -1

     [ https://issues.apache.org/jira/browse/BCEL-26?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bourg updated BCEL-26:
-------------------------------

             Priority: Major
          Environment: URL: http://cvs.apache.org/viewcvs/jakarta-bcel/src/java/org/apache/bcel/classfile/StackMapType.java?rev=1.2&content-type=text/vnd.viewcvs-markup  (was: Operating System: All
Platform: All
URL: http://cvs.apache.org/viewcvs/jakarta-bcel/src/java/org/apache/bcel/classfile/StackMapType.java?rev=1.2&content-type=text/vnd.viewcvs-markup)
    Affects Version/s:     (was: unspecified)
        Fix Version/s: 5.2
             Priority:   (was: P3)
             Severity:   (was: normal)

> StackMapType.printIndex fails if index is -1
> --------------------------------------------
>
>                 Key: BCEL-26
>                 URL: https://issues.apache.org/jira/browse/BCEL-26
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>         Environment: URL: http://cvs.apache.org/viewcvs/jakarta-bcel/src/java/org/apache/bcel/classfile/StackMapType.java?rev=1.2&content-type=text/vnd.viewcvs-markup
>            Reporter: Mark Crocker
>            Assignee: Apache Commons Developers
>             Fix For: 5.2
>
>
> There are circumstances where a StackMapType might have an index of -1. 
> Unfortunately, the printIndex method in StackMapType has problems with this. 
> The fix is simple:
> Original code:
>   private String printIndex() {
>     if(type == Constants.ITEM_Object)
>       return ", class=" + constant_pool.constantToString(index,
> Constants.CONSTANT_Class);
>     else if(type == Constants.ITEM_NewObject)
>       return ", offset=" + index;
>     else
>       return "";
>   }
> Proposed fix:
>   private String printIndex() {
>     if(type == Constants.ITEM_Object) {
>       if(index == -1) {
>         return ", class=<unknown>";
>       } else {
>         return ", class=" + constant_pool.constantToString(index,
> Constants.CONSTANT_Class) + "(" + index + ")";
>       }
>     } else if(type == Constants.ITEM_NewObject) {
>       if(index == -1) {
>         return ", offset=<unknown>";
>       } else {
>         return ", offset=" + index;
>       }
>     } else {
>       return "";
>     }
>   }
> One could also argue that the ConstantPool.constantToString methods should be
> fixed as well, though it could also be argued that such cases should fail.  In
> the case of StackMapType.printIndex, the case is much clearer.
> P.S.  While I'm at this, Bugzilla for BCEL doesn't have an option to select
> version 5.1 of BCEL.  This particular bug is in both 5.0 and 5.1.



--
This message was sent by Atlassian JIRA
(v6.2#6252)