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

beautifyJs why what will execute my script? #127

Open
MrLi2018 opened this issue May 6, 2022 · 5 comments
Open

beautifyJs why what will execute my script? #127

MrLi2018 opened this issue May 6, 2022 · 5 comments

Comments

@MrLi2018
Copy link

MrLi2018 commented May 6, 2022

Caused by: ECMAException: TypeError: Cannot get property "length" of null\n
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)\n
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213)\n
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185)\n
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172)\n
at jdk.nashorn.internal.runtime.linker.NashornBottomLinker.linkNull(NashornBottomLinker.java:183)\n
at jdk.nashorn.internal.runtime.linker.NashornBottomLinker.getGuardedInvocation(NashornBottomLinker.java:66)\n
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)\n
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)\n
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)\n
at jdk.nashorn.internal.scripts.Script$Recompilation$92$128098A$^eval_.L:10#L:3403#TokenStream(:3439)\n
at jdk.nashorn.internal.scripts.Script$Recompilation$90$124532$^eval_.L:10#L:3256#tokenize(:3311)\n
at jdk.nashorn.internal.scripts.Script$Recompilation$59$13770A$^eval_.L:10#L:199#_reset(:427)\n
at jdk.nashorn.internal.scripts.Script$Recompilation$58$15003$^eval_.L:10#L:199#beautify(:438)\n
at jdk.nashorn.internal.scripts.Script$Recompilation$50$7249AA$^eval_.L:10#L:150#js_beautify(:188)\n
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:641)\n
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)\n
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)\n
at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117)\n
at delight.nashornsandbox.internal.JsSanitizer.lambda$beautifierAsFunction$1(JsSanitizer.java:320)\n
at delight.nashornsandbox.internal.JsSanitizer.beautifyJs(JsSanitizer.java:292)\n
at delight.nashornsandbox.internal.JsSanitizerExt.secureJs(JsSanitizerExt.java:36)\n

@mxro
Copy link
Collaborator

mxro commented May 7, 2022

Is there an error in the JavaScript file that should be run?

@MrLi2018
Copy link
Author

MrLi2018 commented May 7, 2022

There should be no errors, I wonder why beautifyJs would execute my script, is it not just glorification, and this is an occasional problem.

@mxro
Copy link
Collaborator

mxro commented May 7, 2022

Beautify will run for all scripts. It is used to simplify the formatting of scripts so that it is easier to inject the statements for the sandbox. Since Beautify will run for all scripts - I would assume it is either a problem with the script or if it is intermittent Nashorn?

Here for reference the code that injects the statements for the sandbox (and uses beautify): https://github.com/javadelight/delight-nashorn-sandbox/blob/master/src/main/java/delight/nashornsandbox/internal/JsSanitizer.java

@MrLi2018
Copy link
Author

MrLi2018 commented May 7, 2022

I don't think this is the problem of JS script, because it is an occasional problem rather than a necessary problem. In addition, I think beautify JS will only format my JS text, but I don't know if it will execute my JS

@mxro
Copy link
Collaborator

mxro commented May 7, 2022

The beautify does not run the code - it only changes the code, and then it is run by Nashorn.

My guess is there is a different problem causing the error (and it has nothing to do with beautify).

You can enable debugging log4j.logger.delight.nashornsandbox.NashornSandbox=DEBUG to see what scripts beautify generates and if there are any problems with it (and maybe that shows any other issue with the script as well).

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

No branches or pull requests

2 participants