Default values of static fields

Ioi Lam ioi.lam at
Wed Jan 9 01:13:34 UTC 2019 

    5.4.2. Preparation

    Preparation involves creating the static fields for a class or
    interface and initializing such
    fields to their default values.

However, in the current implementation, for a class like this:

class Test {
     static Point p;

The slot for p as stored in the mirror object of the Test class is NULL. 
When the JVM reads Test.p, it must do a NULL check, and return 
Point.default as appropriate.

Is there any reason for doing this? Why don't we initialize Test.p to 
point to Point.default when we allocate the mirror for Test?


- Ioi

More information about the valhalla-dev mailing list