< prev index next >

test/hotspot/jtreg/runtime/ClassFile/ClassAccessFlagsRawTest.java

Print this page
*** 22,13 ***
   *
   */
  
  /**
   * @test
!  * @bug 8291360
   * @summary Test getting a class's raw access flags using java.lang.Class API
   * @modules java.base/java.lang:open
   * @compile classAccessFlagsRaw.jcod
   * @run main/othervm ClassAccessFlagsRawTest
   */
  
  import java.lang.reflect.*;
--- 22,14 ---
   *
   */
  
  /**
   * @test
!  * @bug 8291360 8293448
   * @summary Test getting a class's raw access flags using java.lang.Class API
   * @modules java.base/java.lang:open
+  * @enablePreview
   * @compile classAccessFlagsRaw.jcod
   * @run main/othervm ClassAccessFlagsRawTest
   */
  
  import java.lang.reflect.*;

*** 50,12 ***
      public static void main(String argv[]) throws Throwable {
          Class<?> cl = java.lang.Class.class;
          m = cl.getDeclaredMethod("getClassFileAccessFlags", new Class[0]);
          m.setAccessible(true);
  
!         testIt("SUPERset", 0x21);  // ACC_SUPER 0x20 + ACC_PUBLIC 0x1
!         testIt("SUPERnotset", Modifier.PUBLIC);
  
          // Test that primitive should return ACC_ABSTRACT | ACC_FINAL | ACC_PUBLIC.
          int[] arr = new int[3];
          if (!arr.getClass().getComponentType().isPrimitive()) {
              throw new RuntimeException("not primitive");
--- 51,13 ---
      public static void main(String argv[]) throws Throwable {
          Class<?> cl = java.lang.Class.class;
          m = cl.getDeclaredMethod("getClassFileAccessFlags", new Class[0]);
          m.setAccessible(true);
  
!         testIt("SUPERset", Modifier.PUBLIC | Modifier.IDENTITY);
!         // Because of the repurposing of ACC_SUPER into ACC_IDENTITY by JEP 401, the VM now fixes missing ACC_IDENTITY flags in old class files
+         testIt("SUPERnotset", Modifier.PUBLIC | Modifier.IDENTITY);
  
          // Test that primitive should return ACC_ABSTRACT | ACC_FINAL | ACC_PUBLIC.
          int[] arr = new int[3];
          if (!arr.getClass().getComponentType().isPrimitive()) {
              throw new RuntimeException("not primitive");

*** 73,13 ***
                  "expected 0x0 got 0x" + Integer.toHexString(flags) + " for primitive array");
          }
  
          // Test that the modifier flags return element type flags.
          flags = (int)arr.getClass().getModifiers();
!         if (flags != (Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC)) {
              throw new RuntimeException(
!                 "expected 0x411, got 0x" + Integer.toHexString(flags) + " for primitive type");
          }
  
          // Test that AccessFlags set will return element type access flags.
          Set<AccessFlag> aacc = arr.getClass().accessFlags();
          if (!aacc.containsAll(Set.of(AccessFlag.FINAL, AccessFlag.ABSTRACT, AccessFlag.PUBLIC))) {
--- 75,13 ---
                  "expected 0x0 got 0x" + Integer.toHexString(flags) + " for primitive array");
          }
  
          // Test that the modifier flags return element type flags.
          flags = (int)arr.getClass().getModifiers();
!         if (flags != (Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC | Modifier.IDENTITY)) {
              throw new RuntimeException(
!                 "expected 0x431, got 0x" + Integer.toHexString(flags) + " for primitive type");
          }
  
          // Test that AccessFlags set will return element type access flags.
          Set<AccessFlag> aacc = arr.getClass().accessFlags();
          if (!aacc.containsAll(Set.of(AccessFlag.FINAL, AccessFlag.ABSTRACT, AccessFlag.PUBLIC))) {

*** 94,11 ***
                  "expected 0x0, got 0x" + Integer.toHexString(flags) + " for object array");
          }
  
          // Test object array component type.
          flags = (int)m.invoke((new SUPERnotset[2]).getClass().getComponentType());
!         if (flags != Modifier.PUBLIC) {
              throw new RuntimeException(
                  "expected 0x1, got 0x" + Integer.toHexString(flags) + " for object array");
          }
      }
  }
--- 96,19 ---
                  "expected 0x0, got 0x" + Integer.toHexString(flags) + " for object array");
          }
  
          // Test object array component type.
          flags = (int)m.invoke((new SUPERnotset[2]).getClass().getComponentType());
!         // Because of the repurposing of ACC_SUPER into ACC_IDENTITY by JEP 401, the VM now fixes missing ACC_IDENTITY flags in old class files
+         if (flags != (Modifier.PUBLIC | Modifier.IDENTITY)) {
              throw new RuntimeException(
                  "expected 0x1, got 0x" + Integer.toHexString(flags) + " for object array");
          }
+ 
+         // test multi-dimensional object array.  should return flags of component.
+         flags = (int)m.invoke((new SUPERnotset[4][2]).getClass());
+         if (flags != 0) {
+             throw new RuntimeException(
+                 "expected 0x0, got 0x" + Integer.toHexString(flags) + " for object array");
+         }
      }
  }
< prev index next >