< prev index next >

test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessString.java

Print this page
@@ -19,10 +19,12 @@
   * 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.
   */
  
+ // -- This file was mechanically generated: Do not edit! -- //
+ 
  /*
   * @test
   * @run testng/othervm -Diters=10    -Xint                   VarHandleTestAccessString
   * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessString
   * @run testng/othervm -Diters=20000                         VarHandleTestAccessString

@@ -40,10 +42,12 @@
  import java.util.List;
  
  import static org.testng.Assert.*;
  
  public class VarHandleTestAccessString extends VarHandleBaseTest {
+     static final Class<?> type = String.class;
+ 
      static final String static_final_v = "foo";
  
      static String static_v;
  
      final String final_v = "foo";

@@ -75,23 +79,23 @@
  
          String postfix = same ? "" : "2";
          VarHandle vh;
          try {
              vh = MethodHandles.lookup().findVarHandle(
-                     VarHandleTestAccessString.class, "final_v" + postfix, String.class);
+                     VarHandleTestAccessString.class, "final_v" + postfix, type);
              vhs.add(vh);
  
              vh = MethodHandles.lookup().findVarHandle(
-                     VarHandleTestAccessString.class, "v" + postfix, String.class);
+                     VarHandleTestAccessString.class, "v" + postfix, type);
              vhs.add(vh);
  
              vh = MethodHandles.lookup().findStaticVarHandle(
-                 VarHandleTestAccessString.class, "static_final_v" + postfix, String.class);
+                 VarHandleTestAccessString.class, "static_final_v" + postfix, type);
              vhs.add(vh);
  
              vh = MethodHandles.lookup().findStaticVarHandle(
-                 VarHandleTestAccessString.class, "static_v" + postfix, String.class);
+                 VarHandleTestAccessString.class, "static_v" + postfix, type);
              vhs.add(vh);
  
              if (same) {
                  vh = MethodHandles.arrayElementVarHandle(String[].class);
              }

@@ -106,23 +110,24 @@
      }
  
      @BeforeClass
      public void setup() throws Exception {
          vhFinalField = MethodHandles.lookup().findVarHandle(
-                 VarHandleTestAccessString.class, "final_v", String.class);
+                 VarHandleTestAccessString.class, "final_v", type);
  
          vhField = MethodHandles.lookup().findVarHandle(
-                 VarHandleTestAccessString.class, "v", String.class);
+                 VarHandleTestAccessString.class, "v", type);
  
          vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
-             VarHandleTestAccessString.class, "static_final_v", String.class);
+             VarHandleTestAccessString.class, "static_final_v", type);
  
          vhStaticField = MethodHandles.lookup().findStaticVarHandle(
-             VarHandleTestAccessString.class, "static_v", String.class);
+             VarHandleTestAccessString.class, "static_v", type);
  
          vhArray = MethodHandles.arrayElementVarHandle(String[].class);
          vhArrayObject = MethodHandles.arrayElementVarHandle(Object[].class);
+ 
      }
  
  
      @DataProvider
      public Object[][] varHandlesProvider() throws Exception {

@@ -203,11 +208,11 @@
          return types.stream().toArray(Object[][]::new);
      }
  
      @Test(dataProvider = "typesProvider")
      public void testTypes(VarHandle vh, List<Class<?>> pts) {
-         assertEquals(vh.varType(), String.class);
+         assertEquals(vh.varType(), type);
  
          assertEquals(vh.coordinateTypes(), pts);
  
          testTypes(vh);
      }

@@ -215,29 +220,29 @@
  
      @Test
      public void testLookupInstanceToStatic() {
          checkIAE("Lookup of static final field to instance final field", () -> {
              MethodHandles.lookup().findStaticVarHandle(
-                     VarHandleTestAccessString.class, "final_v", String.class);
+                     VarHandleTestAccessString.class, "final_v", type);
          });
  
          checkIAE("Lookup of static field to instance field", () -> {
              MethodHandles.lookup().findStaticVarHandle(
-                     VarHandleTestAccessString.class, "v", String.class);
+                     VarHandleTestAccessString.class, "v", type);
          });
      }
  
      @Test
      public void testLookupStaticToInstance() {
          checkIAE("Lookup of instance final field to static final field", () -> {
              MethodHandles.lookup().findVarHandle(
-                 VarHandleTestAccessString.class, "static_final_v", String.class);
+                 VarHandleTestAccessString.class, "static_final_v", type);
          });
  
          checkIAE("Lookup of instance field to static field", () -> {
              vhStaticField = MethodHandles.lookup().findVarHandle(
-                 VarHandleTestAccessString.class, "static_v", String.class);
+                 VarHandleTestAccessString.class, "static_v", type);
          });
      }
  
  
      @DataProvider
< prev index next >