< prev index next >

test/valhalla/mvt/MVTTest.java

Print this page


   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * @test
  28  * @run testng/othervm -Xint -Xverify:none -XX:+EnableMVT -XX:+ValueArrayFlatten MVTTest
  29  * @run testng/othervm -Xint -Xverify:none -XX:+EnableMVT -XX:-ValueArrayFlatten MVTTest


  44 
  45 @Test
  46 public class MVTTest {
  47     static final Class<?> DVT;
  48 
  49     static final ValueType<?> VT = ValueType.forClass(Point.class);
  50 
  51     static final Class<?>[] FIELD_TYPES;
  52 
  53     static final String[] FIELD_NAMES;
  54 
  55     static String TEMPLATE = "Point[x=#x, y=#y, z=#z]";
  56 
  57     static final Object[] FIELD_VALUES = {42, (short) 43, (short) 44};
  58 
  59     static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
  60 
  61     static final MethodHandle PRINT_POINT;
  62 
  63     static {
  64         try {
  65             DVT = MinimalValueTypes_1_0.getValueTypeClass(Point.class);
  66         }
  67         catch (ClassNotFoundException e) {
  68             throw new RuntimeException(e);
  69         }
  70 
  71         Field[] fs = Point.class.getFields();
  72 
  73         FIELD_TYPES = new Class<?>[fs.length];
  74         FIELD_NAMES = new String[fs.length];
  75 
  76         for (int i = 0; i < fs.length; i++) {
  77             FIELD_TYPES[i] = fs[i].getType();
  78             FIELD_NAMES[i] = fs[i].getName();
  79         }
  80 
  81         try {
  82             PRINT_POINT = LOOKUP.findStatic(MVTTest.class, "print", methodType(String.class, Point.class))
  83                     .asType(methodType(String.class, DVT));
  84         }
  85         catch (Exception e) {
  86             throw new RuntimeException(e);
  87         }
  88     }
  89 


   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.


   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @run testng/othervm -Xint -Xverify:none -XX:+EnableMVT -XX:+ValueArrayFlatten MVTTest
  27  * @run testng/othervm -Xint -Xverify:none -XX:+EnableMVT -XX:-ValueArrayFlatten MVTTest


  42 
  43 @Test
  44 public class MVTTest {
  45     static final Class<?> DVT;
  46 
  47     static final ValueType<?> VT = ValueType.forClass(Point.class);
  48 
  49     static final Class<?>[] FIELD_TYPES;
  50 
  51     static final String[] FIELD_NAMES;
  52 
  53     static String TEMPLATE = "Point[x=#x, y=#y, z=#z]";
  54 
  55     static final Object[] FIELD_VALUES = {42, (short) 43, (short) 44};
  56 
  57     static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
  58 
  59     static final MethodHandle PRINT_POINT;
  60 
  61     static {

  62         DVT = MinimalValueTypes_1_0.getValueTypeClass(Point.class);




  63 
  64         Field[] fs = Point.class.getFields();
  65 
  66         FIELD_TYPES = new Class<?>[fs.length];
  67         FIELD_NAMES = new String[fs.length];
  68 
  69         for (int i = 0; i < fs.length; i++) {
  70             FIELD_TYPES[i] = fs[i].getType();
  71             FIELD_NAMES[i] = fs[i].getName();
  72         }
  73 
  74         try {
  75             PRINT_POINT = LOOKUP.findStatic(MVTTest.class, "print", methodType(String.class, Point.class))
  76                     .asType(methodType(String.class, DVT));
  77         }
  78         catch (Exception e) {
  79             throw new RuntimeException(e);
  80         }
  81     }
  82 


< prev index next >