Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More String.prototype.endsWith problems on Nashorn #1130

Closed
AprilArcus opened this issue Sep 28, 2022 · 0 comments · Fixed by #1131
Closed

More String.prototype.endsWith problems on Nashorn #1130

AprilArcus opened this issue Sep 28, 2022 · 0 comments · Fixed by #1131

Comments

@AprilArcus
Copy link
Contributor

Now that 27b5630 and #1129 are merged, the original Nashorn error of Java::JavaLang::AssertionError (unknown call type GET:METHOD|PROPERTY|ELEMENT:call(Object)Object@jdk.nashorn.internal.scripts.Script$Recompilation$3$\^eval\_/0x0000000800765040) from #1128 has been addressed, and the polyfill can be loaded successfully. However, when I try to use a function such as endsWith, I get this new error:

Java::JavaxScript::ScriptException (TypeError: Can not invoke method [jdk.dynalink.beans.SimpleDynamicMethod boolean java.lang.String.endsWith(String)] with the passed arguments; they do not match any of its method signatures. in <eval> at line number 1)

The problem originates with the fact that Nashorn implementation of endsWith can't be called with the endPosition parameter:

> engine.eval("Function.prototype.call.apply(''.endsWith, ['foo',
 'o'])")
< true
engine.eval("Function.prototype.call.apply(''.endsWith, ['foo', 'o', 3])")
Java::JavaxScript::ScriptException

In order to correct this, the return value from uncurryThis should be falsey here:

https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.ends-with.js#L13

Then the native implementation will be bypassed during this check:

https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.string.ends-with.js#L34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants