-
Notifications
You must be signed in to change notification settings - Fork 861
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
Circular dependency between Context and ScriptRuntime leads to a NullPointerException (emptyArgs null) #1793
Comments
Our code has only two places where Context.emptyArgs is used - should we deprecate that field and always use ScriptRuntime.emptyArgs? |
It could be a good solution. |
PR provided - @gbrail, @andreabergia , @p-bakker what do you think? |
I am ok with removing the duplication and using only the |
Maybe the circular dependency. ScriptRuntime needs Context to initialize the static field ContextClass. Maybe moving the initialization emptyArgs before ContextClass is enough. In my call stack, |
Hello,
I think I have a circular dependency problem between the two classes org.mozilla.javascript.Context and org.mozilla.javascript.ScriptRuntime.
The problem is with the initialization of emptyArgs in Context class which is null and leads to a NullpointerExcption in the MemberBox code when the list of parameters is iterated.
Here is the Stacktrace :
Here are the different versions used in my application:
Rhino 1.7.15
Spring Framework 6.0.23
Java 17
Tomcat 10.1.6
Here's my problem code :
When I try to execute a function by calling Function.call I get a NullPointerException in the MemberBox class on args which is null. The script tries to interpret a simple getter on my object (Script parameter).
I think this is due to the static initialization of emptyArgs in Context class :
public static final Object[] emptyArgs = ScriptRuntime.emptyArgs;
Looking in debug mode, ScriptRuntime.emptyArgs is not yet initialised with the empty array.
I then tried to force the initialization of the ScriptRuntime class first when launching my application but ScriptRuntime also depends on Context (code in ScriptRuntime.class line 102) :
Is this a known problem or is something missing from my code ?
How can I ensure that Context.emptyArgs is always initialised with an empty object array ?
Thank you in advance
The text was updated successfully, but these errors were encountered: