LWJGL Forum

Programming => OpenGL => Topic started by: Nickallen2 on July 03, 2016, 00:11:57

Title: Always getting NullPointerException on startup when running on Mac OSX
Post by: Nickallen2 on July 03, 2016, 00:11:57
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.
Title: Re: Always getting NullPointerException on startup when running on Mac OSX
Post by: Nickallen2 on July 03, 2016, 00:26:05
I found a workaround. If I call Library.initialize() on my main thread it fixes this problem!
Title: Re: Always getting NullPointerException on startup when running on Mac OSX
Post by: spasi on July 03, 2016, 07:13:52
Thanks, it should be fixed in the next nightly build.