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

NativeError.js_captureStackTrace causes ClassCastException when 'Error' has been overridden #366

Open
tmallery opened this issue Nov 30, 2017 · 1 comment
Labels
Java Exception Leaking Issues related to Java Exceptions leaking into JavaScript non-Ecma Triage Issues yet to be triaged

Comments

@tmallery
Copy link

tmallery commented Nov 30, 2017

java.lang.ClassCastException: org.mozilla.v17.javascript.NativeObject cannot be cast to org.mozilla.v17.javascript.Function

var oldError = Error;
Error = {};
oldError.captureStackTrace({});

The issue is because NativeError.js_captureStackTrace creates a new "Error" on line 303.
NativeError err = (NativeError)cx.newObject(thisObj, "Error");

It needs to create NativeError directly instead of assuming JS defined "Error" is the object it wants.

@p-bakker p-bakker added Triage Issues yet to be triaged Java Exception Leaking Issues related to Java Exceptions leaking into JavaScript labels Jul 5, 2021
@p-bakker
Copy link
Collaborator

Not sure how relevant this still is: as of Rhino 1.7.14 all Error instances should automatically have their stack property initialized

Also: taggin this as an EcmaScript Incompatibility, because Error.captureStackTrace is not in the EcmaScript spec. This is a V8 feature, but as far as I can tell, this function availability is not controlled by the Context.FEATURE_V8_EXTENSIONS flag

@p-bakker p-bakker added the Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec label Oct 14, 2021
@p-bakker p-bakker added non-Ecma and removed Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec labels Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java Exception Leaking Issues related to Java Exceptions leaking into JavaScript non-Ecma Triage Issues yet to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants