< prev index next >

test/compiler/intrinsics/unsafe/AllocateUninitializedArray.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


  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 /*
  26  * @test
  27  * @bug 8150465
  28  * @summary Unsafe methods to produce uninitialized arrays
  29  * @modules java.base/jdk.internal.misc
  30  * @run main/othervm -ea -Diters=200   -Xint                   AllocateUninitializedArray
  31  * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=1 AllocateUninitializedArray
  32  * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=4 AllocateUninitializedArray




  33  */
  34 import java.lang.reflect.Field;


  35 import java.lang.reflect.Array;

  36 import java.util.concurrent.Callable;
  37 
  38 public class AllocateUninitializedArray {
  39     static final int ITERS = Integer.getInteger("iters", 1);
  40     static final jdk.internal.misc.Unsafe UNSAFE;
  41 
  42     static {
  43         try {
  44             Field f = jdk.internal.misc.Unsafe.class.getDeclaredField("theUnsafe");
  45             f.setAccessible(true);
  46             UNSAFE = (jdk.internal.misc.Unsafe) f.get(null);
  47         } catch (Exception e) {
  48             throw new RuntimeException("Unable to get Unsafe instance.", e);
  49         }
  50     }
  51 
  52     public static void main(String... args) throws Exception {
  53         testIAE(AllConstants::testObject);
  54         testIAE(LengthIsConstant::testObject);
  55         testIAE(ClassIsConstant::testObject);




  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 /*
  26  * @test
  27  * @bug 8150465
  28  * @summary Unsafe methods to produce uninitialized arrays
  29  * @modules java.base/jdk.internal.misc
  30  *
  31  * @run main/othervm -ea -Diters=200   -Xint
  32  *      compiler.intrinsics.unsafe.AllocateUninitializedArray
  33  * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=1
  34  *      compiler.intrinsics.unsafe.AllocateUninitializedArray
  35  * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=4
  36  *      compiler.intrinsics.unsafe.AllocateUninitializedArray
  37  */
  38 
  39 package compiler.intrinsics.unsafe;
  40 
  41 import java.lang.reflect.Array;
  42 import java.lang.reflect.Field;
  43 import java.util.concurrent.Callable;
  44 
  45 public class AllocateUninitializedArray {
  46     static final int ITERS = Integer.getInteger("iters", 1);
  47     static final jdk.internal.misc.Unsafe UNSAFE;
  48 
  49     static {
  50         try {
  51             Field f = jdk.internal.misc.Unsafe.class.getDeclaredField("theUnsafe");
  52             f.setAccessible(true);
  53             UNSAFE = (jdk.internal.misc.Unsafe) f.get(null);
  54         } catch (Exception e) {
  55             throw new RuntimeException("Unable to get Unsafe instance.", e);
  56         }
  57     }
  58 
  59     public static void main(String... args) throws Exception {
  60         testIAE(AllConstants::testObject);
  61         testIAE(LengthIsConstant::testObject);
  62         testIAE(ClassIsConstant::testObject);


< prev index next >