commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Created] (BCEL-249) Check for max Short seems wrong
Date Wed, 19 Aug 2015 23:23:45 GMT
Sebb created BCEL-249:
-------------------------

             Summary: 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


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)

Mime
View raw message