-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
17.0.2
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Processor: AMD Ryzen 7 4700U with Radeon Graphics, 2.00 GHz
OS Edition: Windows 10 Education
Version: 21H1
Build: 19043.1586
Java version:
IBM Semeru Runtime Open Edition 17.0.2.0 (build 17.0.2+8)
Eclipse OpenJ9 VM 17.0.2.0 (build openj9-0.30.0, JRE 17 Windows 10 amd64-64-Bit Compressed References 20220128_95 (JIT enabled, AOT enabled)
OpenJ9 - 9dccbe076
OMR - dac962a28
JCL - 64cd399ca28 based on jdk-17.0.2+8)
also tested with Temurin and the Oracle JDK
A DESCRIPTION OF THE PROBLEM :
Switch statements with pattern matching fail to execute the Double case if preceded by a null case for certain double values.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
true
true
true
true
true
ACTUAL -
true
true
false
true
false
---------- BEGIN SOURCE ----------
public class DoubleSwitchTest {
public static void main(String[] args) {
Object object = -1.0;
// Prints true
System.out.println(object instanceof Double);
// Prints true
switch(object) {
case Double d -> System.out.println("true");
case null -> System.out.println("null");
default -> System.out.println("false");
}
// Prints false, expected true
switch(object) {
case null -> System.out.println("null");
case Double d -> System.out.println("true");
default -> System.out.println("false");
}
object = Math.nextUp(-1.0);
// Prints true
switch(object) {
case null -> System.out.println("null");
case Double d -> System.out.println("true");
default -> System.out.println("false");
}
object = Math.nextDown(-1.0);
// Prints false, expected true
switch(object) {
case null -> System.out.println("null");
case Double d -> System.out.println("true");
default -> System.out.println("false");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Put the null case at the end.
FREQUENCY : always
Processor: AMD Ryzen 7 4700U with Radeon Graphics, 2.00 GHz
OS Edition: Windows 10 Education
Version: 21H1
Build: 19043.1586
Java version:
IBM Semeru Runtime Open Edition 17.0.2.0 (build 17.0.2+8)
Eclipse OpenJ9 VM 17.0.2.0 (build openj9-0.30.0, JRE 17 Windows 10 amd64-64-Bit Compressed References 20220128_95 (JIT enabled, AOT enabled)
OpenJ9 - 9dccbe076
OMR - dac962a28
JCL - 64cd399ca28 based on jdk-17.0.2+8)
also tested with Temurin and the Oracle JDK
A DESCRIPTION OF THE PROBLEM :
Switch statements with pattern matching fail to execute the Double case if preceded by a null case for certain double values.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
true
true
true
true
true
ACTUAL -
true
true
false
true
false
---------- BEGIN SOURCE ----------
public class DoubleSwitchTest {
public static void main(String[] args) {
Object object = -1.0;
// Prints true
System.out.println(object instanceof Double);
// Prints true
switch(object) {
case Double d -> System.out.println("true");
case null -> System.out.println("null");
default -> System.out.println("false");
}
// Prints false, expected true
switch(object) {
case null -> System.out.println("null");
case Double d -> System.out.println("true");
default -> System.out.println("false");
}
object = Math.nextUp(-1.0);
// Prints true
switch(object) {
case null -> System.out.println("null");
case Double d -> System.out.println("true");
default -> System.out.println("false");
}
object = Math.nextDown(-1.0);
// Prints false, expected true
switch(object) {
case null -> System.out.println("null");
case Double d -> System.out.println("true");
default -> System.out.println("false");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Put the null case at the end.
FREQUENCY : always