Does Scala work well on proprietary JVM's?
Asked Answered
P

3

25

My company has a large legacy Java code base and many of our customers run WebSphere and WebLogic. We are considering starting to use Scala but have been unable to confirm that Scala (2.9.X) works well with IBM's JDK (and BEA's JRockit).

Since these JVM's passes the TCK I would say that it should just work, but given the various problems I have had with the different JVM's over the years I am a little nervous. Are there any gotchas to be aware of when using scala with other JVM's ?

  1. Any compiler flags to use (or avoid) ?
  2. Should I compile the code using Scala on hotspot or on the customers JVM ?
  3. Any problems with mixing JAR's compiled using different versions of Scala/Java on different JVM's ?

Any war stories, links and suggestions are welcome.

Pammie answered 31/8, 2011 at 9:5 Comment(0)
G
13

The Scala compiler should produce the same byte-code regardless of the JVM you use. I would expect Scala to run on all three platforms however HotSpot has tried to optimise for dynamic languages and might be slightly better. (Possibly not enough to worry about)

In recent years there has been less and less difference between these platforms and in the near future I expect them all to be directly based on OpenJDK (as IBM has agreed to support OpenJDK now) The JRockit and Hotspot teams have been merged for some time since Oracle owns both.

However if you are not running recent version of the JDK, you may see some issue.

JVMs talk to each other very well and I would consider running Scala in its own JVM to isolate any concerns you might have.

Gulp answered 31/8, 2011 at 9:18 Comment(0)
U
5

Yes, Scala works on non-Sun JVM. Consider, for instance, these two comments from the source code:

 //print SourceAnnotation in a predefined way to insure
 // against difference in the JVMs (e.g. Sun's vs IBM's)

    // on IBM J9 1.6 do not use ForkJoinPool

There aren't many of these. After all, the various JVM are supposed to be compatible -- and tested for it. But, whereas issues arise, action is taken to make sure things run smoothly.

Undone answered 31/8, 2011 at 16:22 Comment(0)
S
4
  1. Nothing I could think of.

  2. The compiler shouldn't make a difference, in fact if running scalac on different VM would generate different bytecode, it is definitely a bug.

  3. You should always run Scala code with the same version of Scala it was compiled with. Code compiled on 2.x won't run on 2.x+1 by default. Code compiled on 2.x.y should run on 2.x.y+1, though.

I agree though, that it would be nice to get licenses from third-party vendors like IBM or Azul to include those platforms into testing.

Sikorski answered 31/8, 2011 at 9:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.