java - Will a class be loaded completely on static member dependency? -




this question has answer here:

public class extends b {     public static final int const = 6;  ... logic ... }  public class c {     private int addnumber(int x) {         return x + a.const;     } } 

i wonder if junit test class c load field class a, depends on or if logic class extension (class b) loaded.

how jvm working in case ?

thanks !

on first reference class a, class loaded. given extends b, class b loaded well. static initializers , static fields in b executed/initialized in order specified in b, in a, , return code extracting const field.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -