[concurrency-interest] Running ForkJoin framework on J9 virtual machine

Doug Lea dl at cs.oswego.edu
Fri May 15 06:52:20 EDT 2009

Binh Le wrote:
> When I run the Fibonacci program using the FJ framework with J9 on a 
> Linux box, I got the following exception (presumably related to JNI). I 
> just wonder if someone also run into the same problem. It appears that 
> IBM's javac can compile FJ programs but J9 can not run FJ bytecode. When 
> I browse the FJ framework implementation, it uses a class named 
> "Unsafe". Probably this class is the cause for the exception.

This is due to an odd state of affairs that I ought to try to
help resolve. Here's the backstory:

Java6 introduced AtomicX.lazySet methods. The openjdk/hotspot RI
implementation required new Unsafe methods to implement them.
"Unsafe" is basically a backdoor for introducing new low-level
capabilities that would otherwise require new bytecodes. It
truly is unsafe though because its methods (intrinsically)
rely on offsets within objects to indicate the element to
operate on. Even though not officially spec'ed anywhere,
these Unsafe methods are for the most part supported in
the same way across Sun, IBM, etc JVMs, because in most
cases there aren't any other good choices for how to do it.
However, for some versions of IBM J9, they apparently did find
some other way to support the lazySet methods (I believe this
on x86 only, PowerPC J9 seems to have them). This makes it
hard for us to put out preliminary (jsr166y) versions
of upcoming classes that rely on and extend the underlying JVM
support that cannot be guaranteed to work until (here, Java7) platform

There are internal workarounds for this that I could use
in ForkJoin classes that would cost a little more. But
without any kind of "#ifdef J9" construction
available, I don't know how to release these in jsr166y
form. In the mean time, one workaround that is correct but
needlessly heavy is to replace setOrderedX methods with
setXVolatile in sources and rebuild.


More information about the Concurrency-interest mailing list