When does the JVM load classes?
Assume I have the following class: class Caller { public void createSomething() { new Something(); } } Would executing this line: static void main() { Class<?> clazz = Caller.class; } cause the JVM to load the class Something or is the class loading deferred until the method createSomething() is called? A class is loaded only when you require information about that class. public class SomethingCaller { public static Something something = null; // (1) does not cause class loading public static Class<?> somethingClass = Something.class; // (2) causes class loading public void doSomething() { new