Stock JDK classes and the “null” ClassLoader?

后端 未结 3 1677
南笙
南笙 2020-12-20 16:39

Hi guys : Im trying to debug a very strange class error by looking at the ClassLoaders for some dynamically created components. ClassLoaders are s

3条回答
  •  庸人自扰
    2020-12-20 17:37

    The javadoc for getClassLoader() says

    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.

    So, that at least explains why you get that result. But it does not explain why the implementors decided to do it that way.

    EDIT: After testing adding my own classes to the bootclasspath then they also show up as null class loader.

提交回复
热议问题