Reputation: 14550
Let's say I have a class:
public class SomeClass {
public NotPresent1 method1(NotPresent2 input) {return null;}
public void method2() {}
}
I compiled this class but on runtime, NotPresent1 and/or NotPresent2 are not on the classpath. can i load that class? can i instantiate such class and call method2()
? or maybe i can even call method1(null)
?
Upvotes: 1
Views: 82
Reputation: 3446
AFAIK it is not specified/depends on VM/JIT implementation. I know that the current VM loads classes lazy, as late as possible (when code of that class is invoked/state accessed). This was done ~1.3 or so in order to speed up startup time of Fat Clients (Swing). However it may happen that an agressive optimizing JIT loads them in advance (e.g. to optimize server side performance). Don't rely on current behaviour regarding class loading timing.
Upvotes: 1