JDK-8058615 : Overload resolution ambiguity involving ConsString
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u40,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-09-17
  • Updated: 2015-06-04
  • Resolved: 2014-09-17
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 b32Fixed
Description
File: test.js

var BufferedWriter = java.io.BufferedWriter;
var StringWriter = java.io.StringWriter;
var w = new BufferedWriter(new StringWriter());
var s = "hello";
w.write(s + "world");

Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodException: Can't unambiguously select between fixed arity signatures [(java.lang.String), (int)] of the method java.io.BufferedWriter.write for argument types [jdk.nashorn.internal.runtime.ConsString]
	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:385)
	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)
Caused by: java.lang.NoSuchMethodException: Can't unambiguously select between fixed arity signatures [(java.lang.String), (int)] of the method java.io.BufferedWriter.write for argument types [jdk.nashorn.internal.runtime.ConsString]
	at jdk.internal.dynalink.beans.OverloadedMethod.throwAmbiguousMethod(OverloadedMethod.java:225)
	at jdk.nashorn.internal.scripts.Script$Recompilation$3$test$cu2$restOf.:program(test.js:5)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:636)
	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:632)
	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:226)
	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:381)
	... 5 more