[MVT] Issues with VDEFAULT + VWITHFIELD
Remi Forax
forax at univ-mlv.fr
Thu Aug 24 20:28:55 UTC 2017
oops, cut & paste the wrong snippet :(
@jvm/internal/value/ValueCapableClass
public final class mvt.Test {
private final int value;
public java.lang.String toString();
Code:
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[]);
Code:
0: vdefault #27 // class ";Qmvt/Test$Value;"
3: iconst_3
4: vwithfield #28 // Field ";Qmvt/Test$Value;".value:I
7: vstore 1
9: getstatic #34 // Field java/lang/System.out:Ljava/io/PrintStream;
12: vload 1
14: vbox #2 // class mvt/Test
17: invokevirtual #40 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
20: return
}
for the issue 3, forgotten to say that the spec allow a value capable class to use vwithfield on a field of the value type,
from 6.5 vwithfield:
"Otherwise, if the class named by the referenced direct value class type is neither the current class nor a value class derived from the current class (5.3), the vwithfield instruction throws an IllegalAccessError."
----- Mail original -----
> De: "Remi Forax" <forax at univ-mlv.fr>
> À: "valhalla-dev" <valhalla-dev at openjdk.java.net>
> Envoyé: Jeudi 24 Août 2017 22:18:51
> Objet: [MVT] Issues with VDEFAULT + VWITHFIELD
>
> 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"
> ICONST_3
> VWITHFIELD, "mvt/Test", "value", "I")
>
> 3. if the field 'value' is private (final),
> the following code raises an IllegalAccessError
> VDEFAULT ;Qmvt/Test$Value;
> ICONST_3
> 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 ?
>
> cheers,
> Rémi
More information about the valhalla-dev
mailing list