Reputation: 788
As it is known, classes from rt.jar library are loaded via Bootstrap Classloader. java.lang is a part of rt.jar library.
However, this sample
System.out.println(ArrayList.class.getClassLoader());
prints null
instead of something like BootstrapClassLoader
.
Also, I know that BootstrapClassLoader is not written in Java. Can it be the reason? And how can I make sure that the class is loaded by BootstrapCL?
Upvotes: 1
Views: 257
Reputation: 21104
Class#getClassLoader
The documentation explicitly warns you about this case.
Returns the class loader for the class.
Some implementations may use null to represent the bootstrap class loader.
Remember to always give a look at the associated JavaDoc. That is valid for everything and it might be a lifesaver sometimes.
Upvotes: 2