openjdk9 on Freebsd

Brian Gardner openjdk at
Tue Feb 16 02:13:04 UTC 2016

I’ve been working on getting jdk9 to build cleanly and compile and run HelloWorld cleanly on Freebsd.  This was following up on a couple patches released by Magnus Ipse Bursie who works at Oracle.  He is interested in getting some of these changes integrated into to jdk9 mainline.

Here are his patches:
WebRev for build changes: <> 

To make this compile properly on BSD, some source code changes are also needed. Here is a simple patch that fixes the compilation show-stoppers. Note that this is *not* part of this bug. <>

Here are my patches which supplement Magnus’s:

porting from bsd-port/jdk8 repo, to fix NM errors during build <>
porting getthreadid logic from bsd-port/jdk8. calling syscall(SYS_thr_self) caused pthread_setspecific to be cleared. <>
adding in servicability agent ported from bsd-port/jdk8 <>
adding classlist.bsd that is identical to classlist.linux, in order to compile <>

The next patches where less straightforward.  When running java I was getting a ton of messages like:
Thread 832744400 has exited with leftover thread-specific data after 4 destructor iterations
After doing a lot of digging and debugging on Linux, I found the code path for Linux was identical for Freebsd and the cleanup destructor was being executed 4 times just like Freebsd, the difference being that Freebsd would print out this benign warning while Linux would just ignore it.  The problem is that all threads that are created and initialize TLS current thread data, must clean them up by explicitly setting the TLS current thread to null.  I’ve come up with two approaches to accomplish this.

clean up TLS current thread at end of ::run functions similar to how it's done in openjdk8. <>
clear current thread before exiting java_start to avoid warnings from leftover pthread_setspecific data <>

With all these patches I’ve accomplished my initial goal of getting Freebsd to build cleanly and compile and run HelloWorld cleanly on Freebsd

Brian Gardner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the bsd-port-dev mailing list