In Java How could getClass().getClassLoader() return null?
- The jar the 'class' is located in is NOT located under common/lib.
- The jar is NOT being boostrap-loaded.
The ClassLoader for all classes within the jar is null.
In Java How could getClass().getClassLoader() return null?
The ClassLoader for all classes within the jar is null.
From the documentation...
public ClassLoader getClassLoader()
Returns the class loader for the class. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader.
...
If this object represents a primitive type or void, null is returned.
Are you using any endorsed standards? I believe this would cause the classes to be loaded by the bootstrap class loader even though you may not be explicitly using -Xbootclasspath.