commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <>
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
             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:

if (Math.abs(value) >= 32767)

This seems wrong, as Short.MAX_VALUE = 32767, so the check should be

if (Math.abs(value) > 32767)

There's a further problem, which is that Short.MIN_VALUE = -32768.
This will be disallowed, unless the condition is written as:

if ((value >= -32768) && (value <= 32767))

This is how the ctor generic.PUSH.PUSH(ConstantPoolGen cp, int value) does the check.

This message was sent by Atlassian JIRA

View raw message