8291734: Return accurate ACC_SUPER access flag for classes
Reviewed-by: mchung
This commit is contained in:
parent
e4925a3959
commit
68af7c1365
@ -1346,16 +1346,18 @@ public final class Class<T> implements java.io.Serializable,
|
|||||||
* @since 20
|
* @since 20
|
||||||
*/
|
*/
|
||||||
public Set<AccessFlag> accessFlags() {
|
public Set<AccessFlag> accessFlags() {
|
||||||
// This likely needs some refinement. Exploration of hidden
|
// Location.CLASS allows SUPER and AccessFlag.MODULE which
|
||||||
// classes, array classes. Location.CLASS allows SUPER and
|
// INNER_CLASS forbids. INNER_CLASS allows PRIVATE, PROTECTED,
|
||||||
// AccessFlag.MODULE which INNER_CLASS forbids. INNER_CLASS
|
// and STATIC, which are not allowed on Location.CLASS.
|
||||||
// allows PRIVATE, PROTECTED, and STATIC, which are not
|
// Use getClassAccessFlagsRaw to expose SUPER status.
|
||||||
// allowed on Location.CLASS.
|
var location = (isMemberClass() || isLocalClass() ||
|
||||||
return AccessFlag.maskToAccessFlags(getModifiers(),
|
isAnonymousClass() || isArray()) ?
|
||||||
(isMemberClass() || isLocalClass() ||
|
AccessFlag.Location.INNER_CLASS :
|
||||||
isAnonymousClass() || isArray()) ?
|
AccessFlag.Location.CLASS;
|
||||||
AccessFlag.Location.INNER_CLASS :
|
return AccessFlag.maskToAccessFlags((location == AccessFlag.Location.CLASS) ?
|
||||||
AccessFlag.Location.CLASS);
|
getClassAccessFlagsRaw() :
|
||||||
|
getModifiers(),
|
||||||
|
location);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8266670
|
* @bug 8266670 8291734
|
||||||
* @summary Test expected AccessFlag's on classes.
|
* @summary Test expected AccessFlag's on classes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -46,16 +46,11 @@ import java.util.*;
|
|||||||
* return the Class object created from a module-info.class
|
* return the Class object created from a module-info.class
|
||||||
* file. Therefore, this test does not attempt to probe the setting of
|
* file. Therefore, this test does not attempt to probe the setting of
|
||||||
* that access flag.
|
* that access flag.
|
||||||
*
|
|
||||||
* For a class, the VM must treat the class as if the ACC_SUPER bit
|
|
||||||
* were set, but that bit is cleared by HotSpot when it is passed out
|
|
||||||
* to the core reflection libraries. Therefore, this test does not
|
|
||||||
* attempt to check whether or not AccessFlag.SUPER is set.
|
|
||||||
*/
|
*/
|
||||||
@ExpectedClassFlags("[PUBLIC, FINAL]")
|
@ExpectedClassFlags("[PUBLIC, FINAL, SUPER]")
|
||||||
public final class ClassAccessFlagTest {
|
public final class ClassAccessFlagTest {
|
||||||
public static void main(String... args) {
|
public static void main(String... args) {
|
||||||
// Top-level and axuillary classes; i.e. non-inner classes
|
// Top-level and auxiliary classes; i.e. non-inner classes
|
||||||
Class<?>[] testClasses = {
|
Class<?>[] testClasses = {
|
||||||
ClassAccessFlagTest.class,
|
ClassAccessFlagTest.class,
|
||||||
TestInterface.class,
|
TestInterface.class,
|
||||||
@ -226,7 +221,7 @@ public final class ClassAccessFlagTest {
|
|||||||
interface TestInterface {}
|
interface TestInterface {}
|
||||||
|
|
||||||
|
|
||||||
@ExpectedClassFlags("[FINAL, ENUM]")
|
@ExpectedClassFlags("[FINAL, SUPER, ENUM]")
|
||||||
enum TestOuterEnum {
|
enum TestOuterEnum {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user