Friday, April 18, 2008

JRuby engine for JDK 1.5

I've released JSR 223 JRuby engine for JDK 1.5 the other day. New release includes JRubyScirptEngineManager class, which is alternative to javax.script.ScriptEngineManager for JDK 1.5 users. However, newly added class was not necessary for JDK 1.5 users. NetBeans tricked me.

When I tested JRuby engine on JDK 1.5, I could not avoid version mismatch error caused by some archives compiled on JDK 1.6. I thought this must have come from script-api.jar which is distributed in a binary form. The archive was the only one that considerably compiled on JDK 1.6. JAVA_HOME was set to 1.5, commend, java -version, ouputs version 1.5 correctly, etc/netbeans.conf has correct path to JDK 1.5, and the project on NetBeans has 1.5 library only. However, script-api.jar was not a culprit. It was NetBeans trick. NetBeans has cached old classpath to 1.6 of the project and never refreshes it. Caches are in directories under /Users/yoko/.netbeans/6.1beta/var/cache/index/0.8. My JDK 1.6 for Mac OSX has JSR 223 AppleScript engine in it and causes version mismatch error. Even though NetBeans works on JDK 1.5, and the project has JDK 1.5 library only, cached classpath to JDK 1.6 is vaild for execution. Very tricky. The old cached classpath is not valid for compile, so I got compile error if I did not have script-api.jar in the project library.

Although JRubyScriptEngineManager does not need for JDK 1.5, this class helped me to figure out what's going on. Moreover, I added relevant exception which would help users keep from stucking into. javax.script.ScriptEngineManager does not raise any exception even though it could not find script engine. People often don't know null is returned and got exception at the eval() method line. JRubyScriptEngineManager might help users out.

No comments: