You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2015/08/20 14:20:46 UTC

[jira] [Resolved] (BCEL-249) Check for max Short seems wrong

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

Sebb resolved BCEL-249.
-----------------------
       Resolution: Fixed
    Fix Version/s: 6.0

URL: http://svn.apache.org/r1696777
Log:
BCEL-249 Check for max Short seems wrong

Modified:
    commons/proper/bcel/trunk/src/changes/changes.xml
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/BranchInstruction.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/GOTO.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/Instruction.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/JSR.java
    commons/proper/bcel/trunk/src/main/java/org/apache/commons/bcel6/generic/PUSH.java


> Check for max Short seems wrong
> -------------------------------
>
>                 Key: BCEL-249
>                 URL: https://issues.apache.org/jira/browse/BCEL-249
>             Project: Commons BCEL
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 6.0
>
>
> There are some checks for the max  value that will fit in a short.
> These are of the form:
> {code}
> if (Math.abs(value) >= 32767)
> {code}
> This seems wrong, as Short.MAX_VALUE = 32767, so the check should be
> {code}
> if (Math.abs(value) > 32767)
> {code}
> There's a further problem, which is that Short.MIN_VALUE = -32768.
> This will be disallowed, unless the condition is written as:
> {code}
> if ((value >= -32768) && (value <= 32767))
> {code}
> This is how the ctor generic.PUSH.PUSH(ConstantPoolGen cp, int value) does the check.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)