< prev index next >

test/jdk/valhalla/valuetypes/ArrayElementVarHandleTest.java

Print this page
rev 55119 : 8223387: [lworld] reflection support for LW2 arrays


  27  * @summary test VarHandle on inline class array
  28  * @compile -XDallowWithFieldOperator Point.java
  29  * @compile -XDallowWithFieldOperator Line.java
  30  * @compile -XDallowWithFieldOperator MutablePath.java
  31  * @compile -XDallowWithFieldOperator MixedValues.java NonFlattenValue.java
  32  * @run testng/othervm -XX:+EnableValhalla -XX:ValueArrayElemMaxFlatSize=-1 ArrayElementVarHandleTest
  33  * @run testng/othervm -XX:+EnableValhalla -XX:ValueArrayElemMaxFlatSize=0  ArrayElementVarHandleTest
  34  */
  35 
  36 import java.lang.invoke.*;
  37 
  38 import org.testng.annotations.DataProvider;
  39 import org.testng.annotations.Test;
  40 import static org.testng.Assert.*;
  41 
  42 public class ArrayElementVarHandleTest {
  43     private static final Point P = Point.makePoint(10, 20);
  44     private static final Line L = Line.makeLine(10, 20, 30, 40);
  45     private static final MutablePath PATH = MutablePath.makePath(10, 20, 30, 40);
  46 





  47     @DataProvider(name="arrayTests")
  48     static Object[][] arrayTests() {
  49         return new Object[][]{
  50             new Object[] { Point[].class,
  51                            new Point[] { Point.makePoint(1, 2),
  52                                          Point.makePoint(10, 20),
  53                                          Point.makePoint(100, 200)}},
  54             new Object[] { Point[][].class,
  55                            new Point[][] { new Point[] { Point.makePoint(1, 2),
  56                                                          Point.makePoint(10, 20)}}},




  57             new Object[] { Line[].class,
  58                            new Line[] { Line.makeLine(1, 2, 3, 4),
  59                                         Line.makeLine(10, 20, 30, 40),
  60                                         Line.makeLine(15, 25, 35, 45),
  61                                         Line.makeLine(20, 30, 40, 50)}},
  62             new Object[] { MutablePath[].class,
  63                            new MutablePath[] { MutablePath.makePath(1, 2, 3, 4),
  64                                                MutablePath.makePath(10, 20, 30, 40),
  65                                                MutablePath.makePath(15, 25, 35, 45),
  66                                                MutablePath.makePath(20, 30, 40, 50)}},
  67             new Object[] { MixedValues[].class,
  68                            new MixedValues[] { new MixedValues(P, L, PATH, "mixed", "values")}},
  69             new Object[] { NonFlattenValue[].class,
  70                            new NonFlattenValue[] { NonFlattenValue.make(1, 2),
  71                                                    NonFlattenValue.make(10, 20),
  72                                                    NonFlattenValue.make(100, 200)}},
  73         };
  74     }
  75 
  76     @Test(dataProvider="arrayTests")




  27  * @summary test VarHandle on inline class array
  28  * @compile -XDallowWithFieldOperator Point.java
  29  * @compile -XDallowWithFieldOperator Line.java
  30  * @compile -XDallowWithFieldOperator MutablePath.java
  31  * @compile -XDallowWithFieldOperator MixedValues.java NonFlattenValue.java
  32  * @run testng/othervm -XX:+EnableValhalla -XX:ValueArrayElemMaxFlatSize=-1 ArrayElementVarHandleTest
  33  * @run testng/othervm -XX:+EnableValhalla -XX:ValueArrayElemMaxFlatSize=0  ArrayElementVarHandleTest
  34  */
  35 
  36 import java.lang.invoke.*;
  37 
  38 import org.testng.annotations.DataProvider;
  39 import org.testng.annotations.Test;
  40 import static org.testng.Assert.*;
  41 
  42 public class ArrayElementVarHandleTest {
  43     private static final Point P = Point.makePoint(10, 20);
  44     private static final Line L = Line.makeLine(10, 20, 30, 40);
  45     private static final MutablePath PATH = MutablePath.makePath(10, 20, 30, 40);
  46 
  47     private static Class<?> nullablePointArrayClass() {
  48         Object a = new Point?[0];
  49         return a.getClass();
  50     }
  51 
  52     @DataProvider(name="arrayTests")
  53     static Object[][] arrayTests() {
  54         return new Object[][]{
  55             new Object[] { Point[].class,
  56                            new Point[] { Point.makePoint(1, 2),
  57                                          Point.makePoint(10, 20),
  58                                          Point.makePoint(100, 200)}},
  59             new Object[] { Point[][].class,
  60                            new Point[][] { new Point[] { Point.makePoint(1, 2),
  61                                                          Point.makePoint(10, 20)}}},
  62             new Object[] { nullablePointArrayClass(),
  63                            new Point?[] { Point.makePoint(11, 22),
  64                                           Point.makePoint(110, 220),
  65                                           null}},
  66             new Object[] { Line[].class,
  67                            new Line[] { Line.makeLine(1, 2, 3, 4),
  68                                         Line.makeLine(10, 20, 30, 40),
  69                                         Line.makeLine(15, 25, 35, 45),
  70                                         Line.makeLine(20, 30, 40, 50)}},
  71             new Object[] { MutablePath[].class,
  72                            new MutablePath[] { MutablePath.makePath(1, 2, 3, 4),
  73                                                MutablePath.makePath(10, 20, 30, 40),
  74                                                MutablePath.makePath(15, 25, 35, 45),
  75                                                MutablePath.makePath(20, 30, 40, 50)}},
  76             new Object[] { MixedValues[].class,
  77                            new MixedValues[] { new MixedValues(P, L, PATH, "mixed", "values")}},
  78             new Object[] { NonFlattenValue[].class,
  79                            new NonFlattenValue[] { NonFlattenValue.make(1, 2),
  80                                                    NonFlattenValue.make(10, 20),
  81                                                    NonFlattenValue.make(100, 200)}},
  82         };
  83     }
  84 
  85     @Test(dataProvider="arrayTests")


< prev index next >