RFR: 8275771: JDK source code contains redundant boolean operations in jdk.compiler and langtools

Vicente Romero vromero at openjdk.java.net
Fri Dec 3 20:46:14 UTC 2021


On Tue, 30 Nov 2021 00:09:23 GMT, PROgrm_JARvis <duke at openjdk.java.net> wrote:

>> make/langtools/tools/compileproperties/CompileProperties.java line 187:
>> 
>>> 185:                 }
>>> 186:                 if ( ok && contents != null ) {
>>> 187:                     String tokens[] = (new String(contents)).split("\\s+");
>> 
>> So the intended composite predicate here is thought to be
>> ok == true && contents != null
>> which is equivalent to
>> ok && contents != null.
>> The semantics of the current code are equivalent to just
>> contents != null
>> right?
>
> The semantics is definitely changed (considering the first branch was always true originally) but it may be the original implementation being incorrect,

well not assigning `true` to `ok` also breaks the semantics as `ok` is used in boolean expressions below this point. So if we want to keep the semantics 100% we will have to either let the code as it was or do:

ok = true;
if (contents != null) {
   ...

-------------

PR: https://git.openjdk.java.net/jdk/pull/6599


More information about the compiler-dev mailing list