< prev index next > test/jdk/java/lang/reflect/AccessFlag/BasicAccessFlagTest.java
Print this page
/*
! * Copyright (c) 2022, 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.
/*
! * 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.
* questions.
*/
/*
* @test
! * @bug 8266670 8293626
* @summary Basic tests of AccessFlag
*/
import java.lang.reflect.AccessFlag;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
* questions.
*/
/*
* @test
! * @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;
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();
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);
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)) {
throw new RuntimeException("Bad set computation on " +
accessFlag + ", " + location);
}
}
}
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 (!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 >