Value Types - static fields are not assgined in value's constructors

GIACHERIO Fabien f.giacherio at gmail.com
Mon Mar 6 11:18:00 UTC 2017


Hi everyone,

I'm trying to execute some tests of the ValueTypeTestBench.java and i've
noticed that the static field 's' of MyValue1 is never affected to the
value of the integer x.

The static method called in order to create the value is
createDontInline(int, long).

It seems that we can set a static field using a VALUE_FACTORY method, but
we can not assign it in a constructor.

Is it a normal behavior ?

____________________________________________

 __ByValue final class MyValue1 {
     static int s;
     static final long sf = ValueTypeTestBench.rL;
     final int x;
     final long y;
     final MyValue2 v1;
     final MyValue2 v2;
     static final MyValue2 v3 =
MyValue2.createInline(ValueTypeTestBench.rI, true);
     final int c;

     private MyValue1(int x, long y, MyValue2 v1, MyValue2 v2, int c) {
         s = x;
         this.x = x;
         this.y = y;
         this.v1 = v1;
         this.v2 = v2;
         this.c = c;
     }

     public static MyValue1 createDontInline(int x, long y) {
         return __Make MyValue1(x, y, MyValue2.createInline(x, true),
MyValue2.createInline(x, false), ValueTypeTestBench.rI);
     }


Best regards,
Fabien GIACHERIO


More information about the valhalla-dev mailing list