Reputation: 56352
Can Thread.getContextClassLoader()
be null ? The javadoc is not really clear.
Should a library take this case into account ?
Update: the reason I asked is that beansbinding.dev.java.net
does not work in this case (and my code does setContextClassLoader(null)
Upvotes: 9
Views: 5975
Reputation: 3343
Java threads created from JNI code in a non-java thread have null ContextClassloader unless the creator explicitly sets it.
Also in such context Thread.currentThread() returns null.
Upvotes: 13
Reputation: 12971
Yes you should, someone could have called Thread.setContextClassLoader(null)
and your library IMO should be able to deal with that.
Upvotes: 5