1

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?

1 Answer 1

2
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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.