Always getting NullPointerException on startup when running on Mac OSX

Started by Nickallen2, July 03, 2016, 00:11:57

Previous topic - Next topic

Nickallen2

Great job on this library BTW. It is working for me flawlessly on both Linux and Windows. However, I am always getting this NPE when starting to use lwjgl on Mac OSX:


java.lang.NullPointerException
   at org.lwjgl.system.APIUtil.apiGetManifestValue(APIUtil.java:92)
   at org.lwjgl.system.Library.checkHash(Library.java:260)
   at org.lwjgl.system.Library.<clinit>(Library.java:44)

When I look at the code there I can see it does this:

URL url = Thread.currentThread().getContextClassLoader().getResource("org/lwjgl/system/APIUtil.class");

The getContextClassLoader() can return null according to the Javadocs for this method:

"The context ClassLoader for this Thread, or null indicating the system class loader (or, failing that, the bootstrap class loader)"

So I guess a check for null in thi case would fix the crash.

Nickallen2

I found a workaround. If I call Library.initialize() on my main thread it fixes this problem!

spasi