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

CoffeeScript support does not work #92

Closed
walterhiggins opened this issue Aug 11, 2013 · 5 comments
Closed

CoffeeScript support does not work #92

walterhiggins opened this issue Aug 11, 2013 · 5 comments

Comments

@walterhiggins
Copy link
Owner

I'm getting errors when the Java plugin attempts to load and evaluate the _coffeescript.js file (it's there - I've downloaded it) ...

21:53:56 [SEVERE] javax.script.ScriptException: sun.org.mozilla.javascript.EvaluatorException: Encountered code generation error while compiling function "null": generated bytecode for method exceeds 64K limit. (#8) in at line number 8
21:53:56 [SEVERE] at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:183)
21:53:56 [SEVERE] at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
21:53:56 [SEVERE] at net.walterhiggins.scriptcraft.ScriptCraftPlugin.onEnable(Unknown Source)

See 7205646

@ghost ghost assigned walterhiggins Aug 11, 2013
walterhiggins referenced this issue Aug 11, 2013
Simple integration of CoffeeScript support. The code uses the JavaScript
implementation of the CoffeeScript compiler. All *.coffee files get
compiled to JavaScript just before eval(). Additionaly a new command
named /coffe is introduced to run CoffeeScript code straight in the
Minecraft console.
@f0086
Copy link
Contributor

f0086 commented Aug 16, 2013

Works good on my side. What Java RE do you have installed?
I use the OpenJDK 7

 $ java -version
 java version "1.7.0_21"
 OpenJDK Runtime Environment (IcedTea 2.3.9) (ArchLinux build 7.u21_2.3.9-4-x86_64)
 OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

I found this one: http://coachwei.sys-con.com/node/676073/mobile
Seems the big function() {} wrapper in the _coffeescript.js file is the problem.

I'll try to reproduce the problem with the Oracle JRE.

@walterhiggins
Copy link
Owner Author

java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.2)
OpenJDK Server VM (build 20.0-b12, mixed mode)

@walterhiggins
Copy link
Owner Author

Hi @aaronmueller ,
Any update on this issue? Were you able to reproduce it in 1.6 ?

@f0086
Copy link
Contributor

f0086 commented Jan 2, 2014

No, I've had some problems running multiple Java versions on my machine and hadn't time to investigate the problem here. But I've done some research. The main problem seems this:

 generated bytecode for method exceeds 64K limit

Java6 tries to compile the coffeescript.js file to Java bytecode and failed. To prevent this, the sun.org.mozilla.javascript.Context can be set in an interpreter mode (Java7 does this by default?).

According to the documentation, we need to call setOptimizationLevel(-1) on the sun.org.mozilla.javascript.Context (see here: http://www-archive.mozilla.org/rhino/apidocs/org/mozilla/javascript/Context.html#setOptimizationLevel(int))

Can you please try this?

@walterhiggins
Copy link
Owner Author

Hi Aaron,

ScriptCraft uses the javax.script package bundled with Java 6/7. It no longer uses or depends on Rhino.
I've removed the coffeescript code from the codebase as it doesn't work in most Java environments.
If you can get this to work in a vanilla Java 6/7 env (using the javax.script package with no deps on external Rhino - the javascript engine bundled with java 6/7 differs from Rhino - see 'Javascript Script Engine' here - http://docs.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html - there is no optimizer available ).

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

No branches or pull requests

2 participants