-
Bug
-
Resolution: Fixed
-
P5
-
8
JLS 13.4.9 has the following:
==========
We note, but do not recommend, that if a field of primitive type of an
interface may change, its value may be expressed idiomatically as in:
...
boolean debug = new Boolean(true).booleanValue();
...
==========
This is not incorrect, but it uses the Boolean constructor, which is usually unnecessary and whose use is discouraged. I believe that all that's necessary here is to get a boolean value from an expression that's not a compile-time constant, so the following should be sufficient:
boolean debug = Boolean.valueOf(true).booleanValue();
Perhaps the JLS 13.4.9 example could be changed to use this instead.
==========
We note, but do not recommend, that if a field of primitive type of an
interface may change, its value may be expressed idiomatically as in:
...
boolean debug = new Boolean(true).booleanValue();
...
==========
This is not incorrect, but it uses the Boolean constructor, which is usually unnecessary and whose use is discouraged. I believe that all that's necessary here is to get a boolean value from an expression that's not a compile-time constant, so the following should be sufficient:
boolean debug = Boolean.valueOf(true).booleanValue();
Perhaps the JLS 13.4.9 example could be changed to use this instead.