GetClass (). getClassLoader (). getResourceAsStream throws NullPointerException

In Java How Can getClass (). getClassLoader () returns null?

  • The box that the "class" is in is: NOT under the shared / lib.
  • The box is NOT loaded with a buffer.

The Loader class for all classes in the bank is null.

+2


source to share


2 answers


Are you using approved standards ? I believe this will cause the classes to be loaded by the boot class loader, even if you cannot explicitly use -Xbootclasspath.



+1


source


From the documentation ...

public ClassLoader getClassLoader()

      



Returns the class loader for the class. Some implementations may use null to represent the bootstrap loader class. This method returns null in such implementations if this class was loaded by the bootstrap Loader class.

...

If this object represents a primitive type or void, null is returned.

+4


source







All Articles