Error "Can't unambiguously select between fixed arity signatures" when trying to run v13.2
See original GitHub issueWhen i tried to compile and run scriptcraft with v 13.2, it throw an error (see later) I tried to do some more investigation but without success - it is from lib/scriptcraft.js which is requiring js-patch and unit-testing setTimeout method.
Any possibility to fix it ? Thank you…
[21:00:50 INFO]: [scriptcraft] Enabling scriptcraft v3.3.0-2017-10-15
[21:00:52 ERROR]: [scriptcraft] Error evaluating scriptcraft\lib\scriptcraft.js: java.lang.NoSuchMethodException: Can't unambiguously select between fixed arity signatures [(org.bukkit.plugin.Plugin, java.util.function.Consumer, long), (org.bukkit.plugin.Plugin, java.lang.Runnable, long)] of the method org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.runTaskLater for argument types [org.scriptcraftjs.bukkit.ScriptCraftPlugin, jdk.nashorn.internal.runtime.ScriptFunction, java.lang.Double]
[21:00:52 WARN]: java.lang.NoSuchMethodException: Can't unambiguously select between fixed arity signatures [(org.bukkit.plugin.Plugin, java.util.function.Consumer, long), (org.bukkit.plugin.Plugin, java.lang.Runnable, long)] of the method org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.runTaskLater for argument types [org.scriptcraftjs.bukkit.ScriptCraftPlugin, jdk.nashorn.internal.runtime.ScriptFunction, java.lang.Double]
[21:00:52 WARN]: at jdk.internal.dynalink.beans.OverloadedMethod.throwAmbiguousMethod(OverloadedMethod.java:225)
[21:00:52 WARN]: at jdk.nashorn.internal.scripts.Script$Recompilation$32$158AI$\^eval\_.L:1#bukkitSetTimeout(<eval>:5)
[21:00:52 WARN]: at jdk.nashorn.internal.scripts.Script$Recompilation$31$1905A$\^eval\_.L:1#exports#unitTest(<eval>:57)
[21:00:52 WARN]: at jdk.nashorn.internal.scripts.Script$Recompilation$5$16346AAA$\^eval\_.__onEnable(<eval>:754)
[21:00:52 WARN]: at jdk.nashorn.internal.scripts.Script$Recompilation$2$1583AAA$\^eval\_.L:5#__scboot(<eval>:90)
[21:00:52 WARN]: at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:643)
[21:00:52 WARN]: at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
[21:00:52 WARN]: at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
[21:00:52 WARN]: at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:199)
[21:00:52 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:386)
[21:00:52 WARN]: at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:190)
[21:00:52 WARN]: at org.scriptcraftjs.bukkit.ScriptCraftPlugin.onEnable(ScriptCraftPlugin.java:38)
[21:00:52 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:254)
[21:00:52 WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:339)
[21:00:52 WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403)
[21:00:52 WARN]: at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugin(CraftServer.java:434)
[21:00:52 WARN]: at org.bukkit.craftbukkit.v1_13_R2.CraftServer.enablePlugins(CraftServer.java:348)
[21:00:52 WARN]: at net.minecraft.server.v1_13_R2.MinecraftServer.l(MinecraftServer.java:584)
[21:00:52 WARN]: at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:546)
[21:00:52 WARN]: at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:424)
[21:00:52 WARN]: at net.minecraft.server.v1_13_R2.DedicatedServer.init(DedicatedServer.java:294)
[21:00:52 WARN]: at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:702)
[21:00:52 WARN]: at java.lang.Thread.run(Unknown Source)
[21:00:52 ERROR]: [scriptcraft] Can't unambiguously select between fixed arity signatures [(org.bukkit.plugin.Plugin, java.util.function.Consumer, long), (org.bukkit.plugin.Plugin, java.lang.Runnable, long)] of the method org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.runTaskLater for argument types [org.scriptcraftjs.bukkit.ScriptCraftPlugin, jdk.nashorn.internal.runtime.ScriptFunction, java.lang.Double]
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Solved: Can't unambiguously select between fixed arity sig...
NoSuchMethodException : Can't unambiguously select between fixed arity signatures [(org.apache.nifi.logging.LogMessage), (java.lang.
Read more >Can't unambiguously select between fixed arity signatures ...
e.g. instance.test([1,2,3]) will result in java.lang.NoSuchMethodException: Can't unambiguously select between fixed arity signatures [(java.util.
Read more >Nashorn: How to select constructor to invoke - Stack Overflow
awt["Color(int, int, int)"] (the signature is part of the last name component, consistent with how it works on method names). You can try...
Read more >Windows post.jar Can't unambiguously select between fixed ...
SolrException: Unable to invoke function processAdd in script: update-script.js: Can't unambiguously select between fixed arity signatures [(java.lang.
Read more >JDK 8u152 Bug Fixes - Oracle
# JBS Component Subcomponent
1 JDK‑8160893 client‑libs
2 JDK‑8177315 client‑libs
3 JDK‑8039412 client‑libs 2d
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Whenever the following error occurs:
It’s because of overloaded functions (specifically functions with the same number of params in their signature but with different param types). Rhino & Nashorn both let you explicitly specify which overload (signature) you want to use by specifying the function/param combo as a string property of the object. See https://github.com/walterhiggins/ScriptCraft/commit/f7601576bcc5b641b9833561c49fab9f2af4a333#diff-d09711779c520b5ceb965bc1a5ac5b4eL17
There are two Java implementations for
server.scheduler.runTaskLater
, with different signatures - one that takes ajava.lang.Runnable
and another that takes ajava.util.function.Consumer
. The runtime selects the correct one based on the type of the arguments passed into the call.The Javascript callback function is being passed to Java as a type
jdk.nashorn.internal.runtime.ScriptFunction
and needs to be cast into either ajava.lang.Runnable
or ajava.util.function.Consumer
. The problem is that Java can’t do that cast automatically - either because neither can be done, or because both could be done.The patch @triyuga linked to explicitly specifies which implementation to use. That may work if the JVM can cast
jdk.nashorn.internal.runtime.ScriptFunction
->java.lang.Runnable
or ->java.util.function.Consumer
.Otherwise, I would try next explicitly constructing one of the accepted types from the callback. Maybe like this in
src/js/main/lib/task-bukkit.js
(from “Extending Java classes” here):