Remi Forax forax at univ-mlv.fr
Thu Aug 24 20:18:51 UTC 2017

With the following base code

public final class Test {
  private final int value;

  public java.lang.String toString();
       0: aload_0
       1: getfield      #11                 // Field value:I
       4: invokedynamic #23,  0             // InvokeDynamic #0:makeConcatWithConstants:(I)Ljava/lang/String;
       9: areturn

  public static void main(java.lang.String[]);
       0: vdefault      #27                 // class ";QTest;"
       3: iconst_3
       4: vwithfield    #28                 // Field ";QTest;".value:I
       7: vstore        1
       9: getstatic     #34                 // Field java/lang/System.out:Ljava/io/PrintStream;
      12: vload         1
      14: vbox          #2                  // class Test
      17: invokevirtual #40                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      20: return

for all the test, mvt/Test is the value capable class and ;Qmvt/Test$Value; is the corresponding value type.

1. using VDEFAULT with the clas ref and not the value type ref is allowed (at least with the product VM)
   VDEFAULT "mvt/Test" 

2. worst, you can then call VWITHFIELD, it works again !
   VDEFAULT "mvt/Test"
   VWITHFIELD, "mvt/Test", "value", "I")

3. if the field 'value' is private (final),
   the following code raises an IllegalAccessError
   VDEFAULT ;Qmvt/Test$Value;
   VWITHFIELD, ;Qmvt/Test$Value; value I

   Exception in thread "main" java.lang.IllegalAccessError: tried to access field mvt.Test$Value.value from class mvt.Test

   Does the MVT support nestmates ??   
4. same code as above, but with the field 'value' declared package private or public.
   Note that mvt/Test and ;Qmvt/Test$Value; should be in the same package.
   Exception in thread "main" java.lang.IllegalAccessError: Update to non-static final field mvt.Test$Value.value attempted from a different class (mvt.Test) than the field's declaring class
	at mvt.Test.main(Unknown Source)

   so i do not know how i can use VWITHFIELD ?


More information about the valhalla-dev mailing list