-
Bug
-
Resolution: Fixed
-
P3
-
8u40
-
b96
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
javac 1.8.0_66
ADDITIONAL OS VERSION INFORMATION :
Linux 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Running with Eclipse Mars.
A DESCRIPTION OF THE PROBLEM :
According to specifications NaN should be different from every number, including itself, i.e. NaN != NaN should return true. If a != a is evaluated with Nashorn Javascript, it produces false, even if a == NaN. In fact the first evaluation returns true, but a second identical evaluation with the same ScriptEngine returns false.
REGRESSION. Last worked in version 7u80
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_31"
java-7-openjdk-amd64
We could check that the results were still correct with the two above versions (though not with an identical programme), but these are no longer installed on our computers.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the programme in "Source code for an executable test case:"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
true
true
true
true
true
ACTUAL -
true
false
false
true
true
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class DummyClass21d {
static ScriptEngineManager mgr = new ScriptEngineManager();
public static void main(String[] args) throws ScriptException {
ScriptEngine engine = mgr.getEngineByName("JavaScript");
// Compute twice the same. Do we get the same result ?
engine.eval("a1 = NaN; outCome = (a1!=a1);");
System.out.println(engine.get("outCome").toString());
engine.eval("a1 = NaN; outCome = (a1!=a1);");
System.out.println(engine.get("outCome").toString());
engine.eval("a1 = NaN; outCome2 = (a1!=a1);");
System.out.println(engine.get("outCome2").toString());
engine.eval("a1 = NaN; a2 = NaN; outCome = (a1!=a2);");
System.out.println(engine.get("outCome").toString());
engine.eval("a1 = NaN; outCome = (isNaN(a1));");
System.out.println(engine.get("outCome").toString());
}
}
---------- END SOURCE ----------
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
javac 1.8.0_66
ADDITIONAL OS VERSION INFORMATION :
Linux 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Running with Eclipse Mars.
A DESCRIPTION OF THE PROBLEM :
According to specifications NaN should be different from every number, including itself, i.e. NaN != NaN should return true. If a != a is evaluated with Nashorn Javascript, it produces false, even if a == NaN. In fact the first evaluation returns true, but a second identical evaluation with the same ScriptEngine returns false.
REGRESSION. Last worked in version 7u80
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_31"
java-7-openjdk-amd64
We could check that the results were still correct with the two above versions (though not with an identical programme), but these are no longer installed on our computers.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the programme in "Source code for an executable test case:"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
true
true
true
true
true
ACTUAL -
true
false
false
true
true
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package test;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class DummyClass21d {
static ScriptEngineManager mgr = new ScriptEngineManager();
public static void main(String[] args) throws ScriptException {
ScriptEngine engine = mgr.getEngineByName("JavaScript");
// Compute twice the same. Do we get the same result ?
engine.eval("a1 = NaN; outCome = (a1!=a1);");
System.out.println(engine.get("outCome").toString());
engine.eval("a1 = NaN; outCome = (a1!=a1);");
System.out.println(engine.get("outCome").toString());
engine.eval("a1 = NaN; outCome2 = (a1!=a1);");
System.out.println(engine.get("outCome2").toString());
engine.eval("a1 = NaN; a2 = NaN; outCome = (a1!=a2);");
System.out.println(engine.get("outCome").toString());
engine.eval("a1 = NaN; outCome = (isNaN(a1));");
System.out.println(engine.get("outCome").toString());
}
}
---------- END SOURCE ----------