Skip to content

Commit

Permalink
Adds implementation for accessFlags() in Class.java
Browse files Browse the repository at this point in the history
Signed-off-by: Gengchen Tuo <gengchen.tuo@ibm.com>
  • Loading branch information
thallium committed Nov 16, 2022
1 parent da2ecb9 commit 82456a3
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions jcl/src/java.base/share/classes/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -5673,9 +5673,38 @@ private static ReflectionFactory getReflectionFactory() {
/*[ENDIF] JAVA_SPEC_VERSION >= 11 */

/*[IF JAVA_SPEC_VERSION >= 20]*/
/* ToDo: Real implementation to be added under https://github.com/eclipse-openj9/openj9/issues/15933. */
/**
* For an array class, the PUBLIC, PRIVATE and PROTECTED access flags should be the
* same as those of its component type, and the FINAL access flag should always be
* present. For a primitive type or void, the PUBLIC and FINAL access flags should always
* be present, and the PROTECTED and PRIVATE access flags should always be absent.
*
* {@return an unmodifiable set of the {@linkplain AccessFlag access flags} for this
* class, possibly empty}
*
* @since 20
*/
public Set<AccessFlag> accessFlags() {
return null;
int rawModifiers = getModifiersImpl();
/* Uses the implementation from getModifiers() and adds SUPER access flag to
* the mask, instead of directly invoking getModifiers(), because the SUPER flag
* may or may not be set in the rawModifiers.
*/
AccessFlag.Location location = AccessFlag.Location.CLASS;
if (isArray()) {
rawModifiers &= Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED |
Modifier.ABSTRACT | Modifier.FINAL;
location = AccessFlag.Location.INNER_CLASS;
} else {
rawModifiers &= Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED |
Modifier.STATIC | Modifier.FINAL | Modifier.INTERFACE |
Modifier.ABSTRACT | SYNTHETIC | ENUM | ANNOTATION |
AccessFlag.SUPER.mask() | AccessFlag.MODULE.mask();
if (isMemberClass() || isLocalClass() || isAnonymousClass()) {
location = AccessFlag.Location.INNER_CLASS;
}
}
return AccessFlag.maskToAccessFlags(rawModifiers, location);
}
/*[ENDIF] JAVA_SPEC_VERSION >= 20 */
}

0 comments on commit 82456a3

Please sign in to comment.