You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Loic Guibert <lf...@yahoo.fr> on 2015/06/12 10:33:58 UTC
[LANG] EnumUtils *BitVector methods issue with more than 32 values
Enums
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