commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Loic Guibert <lfdummy-apa...@yahoo.fr>
Subject [LANG] EnumUtils *BitVector methods issue with more than 32 values Enums
Date Fri, 12 Jun 2015 08:33:58 GMT
Hello,
I found an issue into `EnumUtils` *BitVector methods when working with
more than 32 values Enums.

This is due to a implicit `int` -> `long` conversion in generating the
Enum value `long` mask.


More in detail :
    /* Bad code : here `1` is an `int` value so the `<<` operation is
done into
     * an `int` context and then, the result is converted to a `long`
value*/
    long mask = 1 << 32;    // -> mask = 1 and not 4294967296 (0x100000000)

    /* Good code : here `1L` is a `long` value so the `<<` operation is done
     * into an `long` context*/
    long mask = 1L << 32;    // -> mask = 4294967296 (0x100000000)


I opened a JIRA ticket (LANG-1147) and an associated Pull Request (#97)

https://issues.apache.org/jira/browse/LANG-1147
https://github.com/apache/commons-lang/pull/97


Regards,

-- 
Loic Guibert
PGP : 0x65EB4F33


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message