8266670: Better modeling of access flags in core reflection

Reviewed-by: mchung, rriggs, asotona
This commit is contained in:
Joe Darcy 2022-06-25 19:09:43 +00:00
parent a5c25d8837
commit de7467146f
14 changed files with 1480 additions and 16 deletions

View file

@ -28,6 +28,7 @@ package java.lang.reflect;
import java.lang.annotation.*;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.Objects;
import java.util.StringJoiner;
import java.util.stream.Stream;
@ -204,9 +205,25 @@ public abstract sealed class Executable extends AccessibleObject
/**
* {@return the Java language {@linkplain Modifier modifiers} for
* the executable represented by this object}
* @see #accessFlags
*/
public abstract int getModifiers();
/**
* {@return an unmodifiable set of the {@linkplain AccessFlag
* access flags} for the executable represented by this object,
* possibly empty}
*
* @see #getModifiers()
* @jvms 4.6 Methods
* @since 20
*/
@Override
public Set<AccessFlag> accessFlags() {
return AccessFlag.maskToAccessFlags(getModifiers(),
AccessFlag.Location.METHOD);
}
/**
* Returns an array of {@code TypeVariable} objects that represent the
* type variables declared by the generic declaration represented by this