Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: folded the excpetion into the description of the rule, because it wasn't really an exception to the rule but a clarification

...

Code that depends on implementation-defined behavior is non-portable.  In the unusual case where a program is guaranteed to execute only on a single implementation, it is permissible to depend on implementation-specific ranges of memoized values.

Noncompliant Code Example

...

Code Block
bgColor#CCCCFF
public void exampleEqualOperator(){
  Boolean b1 = true; // Or Boolean.True
  Boolean b2 = true; // Or Boolean.True
	
  if (b1 == b2) {        // always equal
    System.out.println("Always print");
  }
}

Exceptions

...

Risk Assessment

Using the equivalence operators to compare values of boxed primitives can lead to erroneous comparisons.

...