### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java,v retrieving revision 1.71 diff -u -r1.71 EqualExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 27 Jun 2008 16:03:56 -0000 1.71 +++ compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 17 Oct 2008 13:47:34 -0000 @@ -811,7 +811,9 @@ // check whether comparing identical expressions Binding leftDirect = Expression.getDirectBinding(this.left); - if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right)) { + if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right) + && this.left.resolvedType != TypeBinding.DOUBLE) { + // Double.NaN == Double.NaN => false scope.problemReporter().comparingIdenticalExpressions(this); } return this.resolvedType = TypeBinding.BOOLEAN; #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java,v retrieving revision 1.15 diff -u -r1.15 ProgrammingProblemsTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 27 Jun 2008 16:04:46 -0000 1.15 +++ src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 17 Oct 2008 13:47:35 -0000 @@ -26,25 +26,25 @@ public class ProgrammingProblemsTest extends AbstractRegressionTest { public ProgrammingProblemsTest(String name) { - super(name); + super(name); } // Static initializer to specify tests subset using TESTS_* static variables - // All specified tests which does not belong to the class are skipped... - // Only the highest compliance level is run; add the VM argument - // -Dcompliance=1.4 (for example) to lower it if needed - static { + // All specified tests which does not belong to the class are skipped... + // Only the highest compliance level is run; add the VM argument + // -Dcompliance=1.4 (for example) to lower it if needed + static { // TESTS_NAMES = new String[] { "test001" }; -// TESTS_NUMBERS = new int[] { 1 }; +// TESTS_NUMBERS = new int[] { 39 }; // TESTS_RANGE = new int[] { 1, -1 }; - } + } public static Test suite() { - return buildAllCompliancesTestSuite(testClass()); + return buildAllCompliancesTestSuite(testClass()); } public static Class testClass() { - return ProgrammingProblemsTest.class; + return ProgrammingProblemsTest.class; } void runTest( @@ -1399,4 +1399,46 @@ "Zork cannot be resolved to a type\n" + "----------\n"); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=251227 +public void test0038() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportComparingIdentical, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " double d1 = 0.0;\n" + + " System.out.println(d1 == d1);\n" + + " }\n" + + "}\n" + }, + "true", + null, + true, + null, + options, + null); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=251227 +public void test0039() { + Map options = getCompilerOptions(); + options.put(CompilerOptions.OPTION_ReportComparingIdentical, CompilerOptions.ERROR); + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " double d1 = Double.NaN;\n" + + " System.out.println(d1 == d1);\n" + + " }\n" + + "}\n" + }, + "false", + null, + true, + null, + options, + null); +} } \ No newline at end of file