I ran into a problem when Rhino throws a "Error generating inline code when compiling a script: generated bytecode for a method exceeds 64K limit" exception when running Rhino through the javax.script.ScriptEngine API. The accepted solution is to call setOptimizationLevel(-1) on sun.org.mozilla.javascript.Context .
Unfortunately, I cannot access the Context that ContextFactory creates. I tried adding ContextFactory.Listener to ContextFactory.getGlobal() , which would change Context after creation, but my listener would never be called. I also looked at the source of Java 7 using the makeContext() method in Java 6 to understand what I mean.
As far as I can tell, I believe that my best option is to run Rhino directly, as shown in this example of using Rhino to start the CoffeeScript compiler . Although, as you can see, the code is much messy, so I would prefer to use the javax.script.ScriptEngine API, if possible, while continuing to support Java 6. Are there any other options?
source share