JDK-8061113 : Boolean used as optimistic call return type
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u40
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-10-15
  • Updated: 2015-06-04
  • Resolved: 2014-10-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b36Fixed
Related Reports
Relates :  
Description
Well the nashorn-nightly completed successfully at least so it seems:
http://javac.us.oracle.com/job/nashorn-nightly/3/console

But looking at the log files carefully, I see these failures.
     [java] Test(compile, run): test/script/external/test262/test/suite/ch15/15.9/15.9.5/S15.9.5_A41_T1.js
     [java] Test(compile, run): test/script/external/test262/test/suite/ch15/15.9/15.9.5/S15.9.5_A42_T1.js
     [java] Exception in thread "main" java.lang.AssertionError: TEST FAILED
     [java] 	at jdk.nashorn.internal.test.framework.ParallelTestRunner.run(ParallelTestRunner.java:416)
     [java] 	at jdk.nashorn.internal.test.framework.ParallelTestRunner.main(ParallelTestRunner.java:436)
     [java] 
     [java] FAILED TESTS
     [java] Test(compile, run): test/script/external/test262/test/suite/ch10/10.1/10.1.1/10.1.1-23-s.js
     [java] java.lang.AssertionError: boolean, class java.lang.Object
     [java] Test(compile, run): test/script/external/test262/test/suite/ch10/10.1/10.1.1/10.1.1-24-s.js
     [java] java.lang.AssertionError: boolean, class java.lang.Object
     [java] Test(compile, run): test/script/external/test262/test/suite/ch10/10.6/10.6-6-4.js
     [java] java.lang.AssertionError: boolean, class java.lang.Object
     [java] Tests run: 11552/11552 tests, passed: 11549 (99.97%), failed: 3. Time elapsed: 49min 49s.
     [java] Java Result: 1
Kumar
Comments
Looks like private static MethodHandle getOptimisticTypeGuard(final Class<?> actual, final Class<?> provable) of OptimisticReturnFilters.java does not handle the case of actual type being boolean.class -- else part asserts actual type being not-primitive but previous "ifs" only handle number primitive types used in nashorn.
16-10-2014

Test derived from one of the failing test262 tests. File: test.js function testcase() { var arguments= undefined; return (function (a,b,c) {return arguments.length === 0})(); } print(testcase()); jjs -J-Djava.ext.dirs=<your_nashorn.jar_dir> -J-ea -doe test.js Exception in thread "main" java.lang.AssertionError: boolean, class java.lang.Object at jdk.nashorn.internal.runtime.OptimisticReturnFilters.getOptimisticTypeGuard(OptimisticReturnFilters.java:145) at jdk.nashorn.internal.runtime.OptimisticReturnFilters.filterOptimisticReturnValue(OptimisticReturnFilters.java:115) at jdk.nashorn.internal.runtime.CompiledFunction.createInvoker(CompiledFunction.java:693) at jdk.nashorn.internal.runtime.CompiledFunction.access$200(CompiledFunction.java:59) at jdk.nashorn.internal.runtime.CompiledFunction$2.get(CompiledFunction.java:661) at jdk.nashorn.internal.runtime.CompiledFunction$2.get(CompiledFunction.java:658) at jdk.nashorn.internal.runtime.CompiledFunction.getValidOptimisticInvocation(CompiledFunction.java:604) at jdk.nashorn.internal.runtime.CompiledFunction.createFunctionInvocation(CompiledFunction.java:658) at jdk.nashorn.internal.runtime.ScriptFunction.findCallMethod(ScriptFunction.java:628) at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1845) at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:100) at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:94) at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176) at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124) at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:149) at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:233) at jdk.nashorn.internal.scripts.Script$Recompilation$6$test$cu1$restOf.testcase(test.js:3) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636) at jdk.nashorn.internal.scripts.Script$Recompilation$3$test.:program(test.js:6) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387) at jdk.nashorn.tools.Shell.apply(Shell.java:394) at jdk.nashorn.tools.Shell.runScripts(Shell.java:323) at jdk.nashorn.tools.Shell.run(Shell.java:169) at jdk.nashorn.tools.Shell.main(Shell.java:133) at jdk.nashorn.tools.Shell.main(Shell.java:112)
16-10-2014

I reverted changesets one by one from tip. Reverting to changeset before this (which is just before current jdk9-dev tip) summary: 8060241: Immediately invoked function expressions cause lot of deoptimization fixes these failures. it appears that fix for JDK-8060241 is the cause of the 3 test262 failures reported in this bug.
16-10-2014

Reproduced the 3 test failures with jdk9-dev tip using Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
16-10-2014