< prev index next >

test/jdk/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template

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

*** 19,12 ***
--- 19,18 ---
   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  
+ #warn
+ 
  /*
   * @test
+ #if[Value]
+  * @enablePreview
+  * @modules java.base/jdk.internal.vm.annotation
+ #end[Value]
   * @run testng/othervm -Diters=10   -Xint                                                   VarHandleTestAccess$Type$
   *
   * @comment Set CompileThresholdScaling to 0.1 so that the warmup loop sets to 2000 iterations
   *          to hit compilation thresholds
   *

*** 70,13 ***
  
      VarHandle vhStaticFinalField;
  
      VarHandle vhArray;
  
! #if[String]
      VarHandle vhArrayObject;
! #end[String]
  
      VarHandle[] allocate(boolean same) {
          List<VarHandle> vhs = new ArrayList<>();
  
          String postfix = same ? "" : "2";
--- 76,13 ---
  
      VarHandle vhStaticFinalField;
  
      VarHandle vhArray;
  
! #if[Object]
      VarHandle vhArrayObject;
! #end[Object]
  
      VarHandle[] allocate(boolean same) {
          List<VarHandle> vhs = new ArrayList<>();
  
          String postfix = same ? "" : "2";

*** 128,13 ***
  
          vhStaticField = MethodHandles.lookup().findStaticVarHandle(
              VarHandleTestAccess$Type$.class, "static_v", $type$.class);
  
          vhArray = MethodHandles.arrayElementVarHandle($type$[].class);
! #if[String]
          vhArrayObject = MethodHandles.arrayElementVarHandle(Object[].class);
! #end[String]
      }
  
  
      @DataProvider
      public Object[][] varHandlesProvider() throws Exception {
--- 134,13 ---
  
          vhStaticField = MethodHandles.lookup().findStaticVarHandle(
              VarHandleTestAccess$Type$.class, "static_v", $type$.class);
  
          vhArray = MethodHandles.arrayElementVarHandle($type$[].class);
! #if[Object]
          vhArrayObject = MethodHandles.arrayElementVarHandle(Object[].class);
! #end[Object]
      }
  
  
      @DataProvider
      public Object[][] varHandlesProvider() throws Exception {

*** 312,25 ***
                                                vhStaticField, VarHandleTestAccess$Type$::testStaticFieldUnsupported,
                                                false));
  
          cases.add(new VarHandleAccessTestCase("Array",
                                                vhArray, VarHandleTestAccess$Type$::testArray));
! #if[String]
          cases.add(new VarHandleAccessTestCase("Array Object[]",
                                                vhArrayObject, VarHandleTestAccess$Type$::testArray));
! #end[String]
          cases.add(new VarHandleAccessTestCase("Array unsupported",
                                                vhArray, VarHandleTestAccess$Type$::testArrayUnsupported,
                                                false));
          cases.add(new VarHandleAccessTestCase("Array index out of bounds",
                                                vhArray, VarHandleTestAccess$Type$::testArrayIndexOutOfBounds,
                                                false));
! #if[String]
          cases.add(new VarHandleAccessTestCase("Array store exception",
                                                vhArrayObject, VarHandleTestAccess$Type$::testArrayStoreException,
                                                false));
! #end[String]
          // Work around issue with jtreg summary reporting which truncates
          // the String result of Object.toString to 30 characters, hence
          // the first dummy argument
          return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new);
      }
--- 318,25 ---
                                                vhStaticField, VarHandleTestAccess$Type$::testStaticFieldUnsupported,
                                                false));
  
          cases.add(new VarHandleAccessTestCase("Array",
                                                vhArray, VarHandleTestAccess$Type$::testArray));
! #if[Object]
          cases.add(new VarHandleAccessTestCase("Array Object[]",
                                                vhArrayObject, VarHandleTestAccess$Type$::testArray));
! #end[Object]
          cases.add(new VarHandleAccessTestCase("Array unsupported",
                                                vhArray, VarHandleTestAccess$Type$::testArrayUnsupported,
                                                false));
          cases.add(new VarHandleAccessTestCase("Array index out of bounds",
                                                vhArray, VarHandleTestAccess$Type$::testArrayIndexOutOfBounds,
                                                false));
! #if[Object]
          cases.add(new VarHandleAccessTestCase("Array store exception",
                                                vhArrayObject, VarHandleTestAccess$Type$::testArrayStoreException,
                                                false));
! #end[Object]
          // Work around issue with jtreg summary reporting which truncates
          // the String result of Object.toString to 30 characters, hence
          // the first dummy argument
          return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new);
      }

*** 2001,11 ***
              });
  #end[Bitwise]
          }
      }
  
! #if[String]
      static void testArrayStoreException(VarHandle vh) throws Throwable {
          Object[] array = new $type$[10];
          Arrays.fill(array, $value1$);
          Object value = new Object();
  
--- 2007,11 ---
              });
  #end[Bitwise]
          }
      }
  
! #if[Object]
      static void testArrayStoreException(VarHandle vh) throws Throwable {
          Object[] array = new $type$[10];
          Arrays.fill(array, $value1$);
          Object value = new Object();
  

*** 2082,8 ***
          // GetAndSetRelease
          checkASE(() -> { // receiver reference class
              $type$ x = ($type$) vh.getAndSetRelease(array, 0, value);
          });
      }
! #end[String]
  }
  
--- 2088,8 ---
          // GetAndSetRelease
          checkASE(() -> { // receiver reference class
              $type$ x = ($type$) vh.getAndSetRelease(array, 0, value);
          });
      }
! #end[Object]
  }
  
< prev index next >