< prev index next >

test/jdk/java/lang/reflect/AccessFlag/BasicAccessFlagTest.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2022, 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.

@@ -21,12 +21,15 @@
   * questions.
   */
  
  /*
   * @test
-  * @bug 8266670 8293626
+  * @bug 8266670 8281463 8293626
   * @summary Basic tests of AccessFlag
+  * @modules java.base/jdk.internal.misc
+  * @run main/othervm --enable-preview BasicAccessFlagTest
+  * @run main BasicAccessFlagTest
   */
  
  import java.lang.reflect.AccessFlag;
  import java.lang.reflect.Field;
  import java.lang.reflect.Modifier;

@@ -34,10 +37,13 @@
  import java.util.Map;
  import java.util.LinkedHashMap;
  import java.util.HashSet;
  import java.util.Set;
  
+ import jdk.internal.misc.PreviewFeatures;
+ 
+ 
  public class BasicAccessFlagTest {
      public static void main(String... args) throws Exception {
          testSourceModifiers();
          testMaskOrdering();
          testDisjoint();

@@ -110,10 +116,12 @@
                  continue;
              }
  
              Set<AccessFlag.Location> locations = new HashSet<>();
              for (var accessFlag : value) {
+                 if (accessFlag.equals(AccessFlag.SUPER))
+                     continue;       // SUPER is defined to overlap with IDENTITY
                  for (var location : accessFlag.locations()) {
                      boolean added = locations.add(location);
                      if (!added) {
                          reportError(location, accessFlag,
                                      entry.getKey(), value);

@@ -139,11 +147,13 @@
          for (var accessFlag : AccessFlag.values()) {
              Set<AccessFlag> expectedSet = EnumSet.of(accessFlag);
              for (var location : accessFlag.locations()) {
                  Set<AccessFlag> computedSet =
                      AccessFlag.maskToAccessFlags(accessFlag.mask(), location);
-                 if (!expectedSet.equals(computedSet)) {
+                 if (!computedSet.containsAll(expectedSet)) {
+                     System.out.println("expected: " + expectedSet);
+                     System.out.println("computed: " + computedSet);
                      throw new RuntimeException("Bad set computation on " +
                                                 accessFlag + ", " + location);
                  }
              }
          }
< prev index next >