Skip to content

Commit

Permalink
Merge pull request #16217 from thallium/accessFlags
Browse files Browse the repository at this point in the history
Adds implementation for accessFlags() in Class.java
  • Loading branch information
babsingh committed Nov 17, 2022
2 parents f21a361 + 82456a3 commit fddfd3f
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
Expand Up @@ -5682,9 +5682,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 fddfd3f

Please sign in to comment.