Created attachment 118361 [details] [diff] [review] Disable invoker optimization if it triggers SecurityException The patch adds a public API to enable/disable on per Context basis the invoker optimization and disables it for any Context instance that has seen SecurityException during invoker invocation. The patch also disables invoker optimization in case of var-arg methods since there any speedup in method invocation is berried under the need to create/unwrap additional argument arrays.
Created attachment 118908 [details] [diff] [review] Minimalistic patch: initialize invoker in FunctionObject constructor A simple way to resolve the issue is to create an invoker object in FunctionObject constructor instead of doing this lazily during script call. In typical applications FunctionObject instances are constructed during initialization when there is no script or other code on Java stack with restricted permissions, so as long as Rhino classes have enough permissions, Invoker optimization should be available. And if it is not, the patch catches SecurityException to disable the optimization in this case which will happen only once and not during each call, so the performance impact should be minimal even in this case.
Attachment #118361 - Attachment is obsolete: true
Created attachment 118933 [details] [diff] [review] Patch fix: In FunctionObject constructor create invoker only if method != null
Attachment #118908 - Attachment is obsolete: true
Created attachment 118934 [details] [diff] [review] Yet another patch update: see comments in omj/optimizer/InvokerImpl.java for the reason
Attachment #118933 - Attachment is obsolete: true
I committed the above patch.
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
Verified FIXED. I followed the steps that Igor outlined above in the Rhino1_5R4 shell vs. the Rhino1_5R5pre shell. I got the same exception as Igor in R4, but no exception in R5pre. I tried both variations of the test (opt -1 and opt 9) which Igor explained above. I will attach my opt -1 results below -
Status: RESOLVED → VERIFIED
Targeting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.