OdinMS Java 8 Compatibility Fixes

Joined
Aug 2, 2010
Messages
190
Reaction score
91
Since Java 7 support is ending in approximately a month and most users are switching over to Java 8, I felt like being nice and giving people a heads-up on how to easily migrate over to Java 8.

Generally speaking, code compatibility shouldn't break when you migrate from Java 7 to 8. The only exception are the NPC scripts in OdinMS. Unless you updated all your NPC scripts to be Nashorn compatible (Java 8 JS Standard), your NPC scripts are compatible only with Mozilla Rhino. Since JSR-223 essentially left Mozilla Rhino in the dust, Java 8 will no longer support your NPC scripts. If you're lazy like me and are unwilling to go through every NPC script and replace the JavaScript, I'd suggest doing the following.

JSR-223

Mozilla Rhino is still very well alive, it's just that Java 8 and later will never include it in the Runtime libraries. To fix this, you'll need the Mozilla Rhino engine which is attainable here:


You'll also need js.jar which can be extracted from this archive:


Lastly, in your engine factory you'll need to change "JavaScript" to "rhino". Once you make the changes, recompile and add the downloaded 2 jars to your classpath. You'll need to do this pretty much for Java 8 and later versions unless you decide to update all your NPC scripts to work with Nashorn instead.

JSR-310

If you're also like me, you probably used JODA Time for managing most of the date times in Java 7 since Java didn't have an effective Time API. This is now changed in Java 8 with the addition of java.time. I would personally suggest using java.time.ZonedDateTime in replacement for DateTime in JODA. Even the JODA time developers have encouraged use of the new time APIs.

That's all I have really done to support Java 8, let me know if it works out for you or if there should be additions.
 
why the **** you go out of your way to use the inferior rhino when you could use the new nashorn script engine which is several orders of magnitude faster

You have hundreds of scripts that are Rhino-based, if you want a quick compatibility fix you'll have to use the Rhino script engine. I'm not advocating for people to use Rhino, I'm simply providing a workaround. Whatever scripting engine you want to use, feel free to use it.

Personally, I'd go with JRuby or Jython for scripting...but hey that's just me.
 
You have hundreds of scripts that are Rhino-based, if you want a quick compatibility fix you'll have to use the Rhino script engine. I'm not advocating for people to use Rhino, I'm simply providing a workaround. Whatever scripting engine you want to use, feel free to use it.

Personally, I'd go with JRuby or Jython for scripting...but hey that's just me.

I made a thread with a better workaround that lets you use Nashorn with all of your existing rhino scripts

link
 
Back