On Wed, 24 Jan 2024 13:47:17 GMT, Doug Simon <dnsi...@openjdk.org> wrote:

> You're right. I had forgotten the intricacies of class loader delegation. The 
> only hard constraint on loading a class in multiple loaders is that `java.*` 
> classes [must (only) be loaded by the boot 
> loader](https://github.com/openjdk/jdk/blob/bccd823c8e40863bed70ff5b24772843203871a5/src/java.base/share/classes/java/lang/ClassLoader.java#L904).

Just to add that this restriction was relaxed in Java 9 to allow java.* classes 
be defined by the platform class loader. The code that is linked to here throws 
if the class loader is not the platform class loader. There isn't a user 
accessible ClassLoader object for the boot loader and testing `this == null` 
doesn't make sense.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17520#issuecomment-1908375220

Reply via email to