8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
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 * @test
26 * @bug 8266670 8291734 8296743
27 * @summary Test expected AccessFlag's on classes.
28 */
29
30 import java.lang.annotation.*;
31 import java.lang.reflect.*;
32 import java.util.*;
33
34 /*
35 * Class access flags that can directly or indirectly declared in
36 * source include:
37 * public, private, protected, static, final, interface, abstract,
38 * annotation, enum.
39 *
40 * Additionally, the access flags super and synthetic cannot be
41 * explicitly applied.
42 *
43 * This test is written on top of the facilities of core reflection.
44 *
45 * Note that core reflection does not offer a supported mechanism to
46 * return the Class object created from a module-info.class
47 * file. Therefore, this test does not attempt to probe the setting of
48 * that access flag.
49 */
50 @ExpectedClassFlags("[PUBLIC, FINAL, SUPER]")
51 public final class ClassAccessFlagTest {
52 public static void main(String... args) {
53 // Top-level and auxiliary classes; i.e. non-inner classes
54 Class<?>[] testClasses = {
55 ClassAccessFlagTest.class,
56 TestInterface.class,
57 ExpectedClassFlags.class,
58 TestOuterEnum.class
59 };
60 checkClasses(testClasses);
61
62 // Nested classes of ClassAccessFlagTest
63 checkClasses(ClassAccessFlagTest.class.getDeclaredClasses());
64
65 checkPrimitives();
66 checkArrays();
67 }
68
69 private static void checkClasses(Class<?>[] classes) {
70 for (var clazz : classes) {
71 checkClass(clazz);
72 }
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
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 * @test
26 * @bug 8266670 8291734 8296743
27 * @summary Test expected AccessFlag's on classes.
28 * @modules java.base/jdk.internal.misc
29 * @library /test/lib ..
30 * @enablePreview
31 */
32
33
34 import jdk.internal.misc.PreviewFeatures;
35
36 import java.lang.annotation.*;
37 import java.lang.reflect.*;
38 import java.util.*;
39
40 import jtreg.SkippedException;
41
42
43 /*
44 * Class access flags that can directly or indirectly declared in
45 * source include:
46 * public, private, protected, static, final, interface, abstract,
47 * annotation, enum.
48 *
49 * Additionally, the access flags super and synthetic cannot be
50 * explicitly applied.
51 *
52 * This test is written on top of the facilities of core reflection.
53 *
54 * Note that core reflection does not offer a supported mechanism to
55 * return the Class object created from a module-info.class
56 * file. Therefore, this test does not attempt to probe the setting of
57 * that access flag.
58 */
59 @ExpectedClassFlags("[PUBLIC, FINAL, SUPER]")
60 public final class ClassAccessFlagTest {
61 public static void main(String... args) {
62 if (PreviewFeatures.isEnabled()) {
63 throw new SkippedException("Preview mode not supported");
64 }
65 // Top-level and auxiliary classes; i.e. non-inner classes
66 Class<?>[] testClasses = {
67 ClassAccessFlagTest.class,
68 TestInterface.class,
69 ExpectedClassFlags.class,
70 TestOuterEnum.class
71 };
72 checkClasses(testClasses);
73
74 // Nested classes of ClassAccessFlagTest
75 checkClasses(ClassAccessFlagTest.class.getDeclaredClasses());
76
77 checkPrimitives();
78 checkArrays();
79 }
80
81 private static void checkClasses(Class<?>[] classes) {
82 for (var clazz : classes) {
83 checkClass(clazz);
84 }
|