-
Bug
-
Resolution: Fixed
-
P3
-
8u72, 9
-
b25
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8208995 | 8u201 | Hannes Wallnoefer | P3 | Resolved | Fixed | b01 |
JDK-8196143 | 8u192 | Hannes Wallnoefer | P3 | Resolved | Fixed | b01 |
JDK-8216953 | emb-8u201 | Hannes Wallnoefer | P3 | Resolved | Fixed | master |
FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.14393]
A DESCRIPTION OF THE PROBLEM :
If a varargs function that only passes the arguments to another function rather than using them directly is bound after the first time it is called, binding fails with a "duplicate code" assertion if assertions are enabled.
REGRESSION. Last worked in version 8u121
ADDITIONAL REGRESSION INFORMATION:
The code does not assert in version 1.8.0_40; however, that is before the assertion was added, so I do not know if the underlying issue of generating duplicate function specializations is a regression.
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code listed in the "Source code for an executable test case" field with assertions enabled.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Only one function specialization should be generated when binding.
ACTUAL -
Two identical function specializations were generated, resulting in a "duplicate code" assertion.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.AssertionError: duplicate code
at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.addCode(RecompilableScriptFunctionData.java:831)
at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.addCode(RecompilableScriptFunctionData.java:848)
at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.getBest(RecompilableScriptFunctionData.java:922)
at jdk.nashorn.internal.runtime.ScriptFunctionData.getGeneric(ScriptFunctionData.java:384)
at jdk.nashorn.internal.runtime.ScriptFunctionData.createGenericConstructor(ScriptFunctionData.java:298)
at jdk.nashorn.internal.runtime.ScriptFunctionData.getGenericConstructor(ScriptFunctionData.java:292)
at jdk.nashorn.internal.runtime.ScriptFunctionData.makeBoundFunctionData(ScriptFunctionData.java:429)
at jdk.nashorn.internal.runtime.ScriptFunction.createBound(ScriptFunction.java:392)
at jdk.nashorn.internal.runtime.linker.Bootstrap.bindCallable(Bootstrap.java:384)
at jdk.nashorn.internal.objects.NativeFunction.bind(NativeFunction.java:219)
at jdk.nashorn.internal.scripts.Script$\^eval\_.:program(<eval>:8)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at BindErrorTest.main(BindErrorTest.java:7)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class BindErrorTest {
public static void main(String[] args) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval("var fn2 = function () {};\n" +
"\n" +
"var fn = function () {\n" +
" fn2.apply(null, arguments);\n" +
"};\n" +
"\n" +
"fn();\n" +
"fn.bind();\n");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Create a new function that calls the desired function with the correct "this" and arguments instead of binding. Alternatively, don't enable assertions.
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.14393]
A DESCRIPTION OF THE PROBLEM :
If a varargs function that only passes the arguments to another function rather than using them directly is bound after the first time it is called, binding fails with a "duplicate code" assertion if assertions are enabled.
REGRESSION. Last worked in version 8u121
ADDITIONAL REGRESSION INFORMATION:
The code does not assert in version 1.8.0_40; however, that is before the assertion was added, so I do not know if the underlying issue of generating duplicate function specializations is a regression.
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code listed in the "Source code for an executable test case" field with assertions enabled.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Only one function specialization should be generated when binding.
ACTUAL -
Two identical function specializations were generated, resulting in a "duplicate code" assertion.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.AssertionError: duplicate code
at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.addCode(RecompilableScriptFunctionData.java:831)
at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.addCode(RecompilableScriptFunctionData.java:848)
at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.getBest(RecompilableScriptFunctionData.java:922)
at jdk.nashorn.internal.runtime.ScriptFunctionData.getGeneric(ScriptFunctionData.java:384)
at jdk.nashorn.internal.runtime.ScriptFunctionData.createGenericConstructor(ScriptFunctionData.java:298)
at jdk.nashorn.internal.runtime.ScriptFunctionData.getGenericConstructor(ScriptFunctionData.java:292)
at jdk.nashorn.internal.runtime.ScriptFunctionData.makeBoundFunctionData(ScriptFunctionData.java:429)
at jdk.nashorn.internal.runtime.ScriptFunction.createBound(ScriptFunction.java:392)
at jdk.nashorn.internal.runtime.linker.Bootstrap.bindCallable(Bootstrap.java:384)
at jdk.nashorn.internal.objects.NativeFunction.bind(NativeFunction.java:219)
at jdk.nashorn.internal.scripts.Script$\^eval\_.:program(<eval>:8)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at BindErrorTest.main(BindErrorTest.java:7)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class BindErrorTest {
public static void main(String[] args) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval("var fn2 = function () {};\n" +
"\n" +
"var fn = function () {\n" +
" fn2.apply(null, arguments);\n" +
"};\n" +
"\n" +
"fn();\n" +
"fn.bind();\n");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Create a new function that calls the desired function with the correct "this" and arguments instead of binding. Alternatively, don't enable assertions.
- backported by
-
JDK-8196143 Nashorn: "duplicate code" assertion when binding a vararg function that just passes arguments along
-
- Resolved
-
-
JDK-8208995 Nashorn: "duplicate code" assertion when binding a vararg function that just passes arguments along
-
- Resolved
-
-
JDK-8216953 Nashorn: "duplicate code" assertion when binding a vararg function that just passes arguments along
-
- Resolved
-