getting a basic class loader

Alan Snyder javalists at
Sun Dec 6 20:25:23 UTC 2015

I have been told [1] that doing something like String.class.getClassLoader() is a good way to get a value that can specified as the parent of a custom class loader when my goal for the custom class loader is to exclude application-specific classes (e.g. from the classpath).

Is this the best way to accomplish that goal, and does the answer change in JDK 9 with jigsaw?

I am skeptical because I don’t see any reason to believe that the class loader for any given JDK class is necessarily a complete class loader that knows about all JDK runtime classes. In fact, in JDK 8 it is clearly not the case because the extensions class loader is not included.


[1] <>

More information about the jigsaw-dev mailing list