Not everything that works from "user" code will work in the guts of the VM. In particular, the code that determines how native libraries are loaded is in the VM and is itself written in Java. It requires some initialization, which is run somewhere, transitively, from VM.boot. I suspect that one problem *might* be that your thread is being created before that code runs. 

The relevant initial code will be in gnu.classpath.VMSystemProperties. Classpath provides a dummy implementation that we override with our own. Perhaps you can try seeing if that code runs before, or after, your call to loadLibrary. 


On 28/12/2010, at 5:13 PM, José Simão <> wrote:

Hello JikesRVM researchers,


I’m trying to use Sigar ( in VM code. The main class (Sigar.class) uses JNI calls to the native library.


When I use Sigar in a Java “user” program and then run it using the JikesRvm everything is ok.

The problem is when I use Sigar in the VM code. I have a dedicated class that extends Thread (extending RVMThread leads to other interesting problems), and the run method uses Sigar. I create the thread just before the MainThread in the method VM.boot(), but although I have tried many forms of referring the correct library file, the error message is always the same “failed to load sigar-x86-linux: null pointer exception” (this message is produced by the Sigar library).

Looking at the Sigar source code (and the exception trace) one can see that the native library is loaded in the class’s static constructor.


Because I can use the same exact code in “user” code, I was expecting that the VM code would solve the native library the same way.

The Gnu Classpath refers to a system property called java.library.path, but that didn’t work too. When running the “user” program I don’t have to set anything for Jikes to find the native library. Just have to be in the running directory.


Does this problem seems familiar to anyone?

Thanks for any help.



José Simão

Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
Jikesrvm-researchers mailing list