Skip to content

Commit

Permalink
8255904: Remove superfluous use of reflection in Class::isRecord
Browse files Browse the repository at this point in the history
Reviewed-by: redestad, alanb
  • Loading branch information
ChrisHegarty committed Nov 25, 2020
1 parent c45725e commit cdb41ba
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/java.base/share/classes/java/lang/Class.java
Expand Up @@ -3660,16 +3660,6 @@ public boolean isEnum() {
this.getSuperclass() == java.lang.Enum.class;
}

/** java.lang.Record.class */
private static final Class<?> JAVA_LANG_RECORD_CLASS = javaLangRecordClass();
private static Class<?> javaLangRecordClass() {
try {
return Class.forName0("java.lang.Record", false, null, null);
} catch (ClassNotFoundException e) {
throw new InternalError("should not reach here", e);
}
}

/**
* Returns {@code true} if and only if this class is a record class.
*
Expand All @@ -3686,7 +3676,7 @@ private static Class<?> javaLangRecordClass() {
* @since 16
*/
public boolean isRecord() {
return getSuperclass() == JAVA_LANG_RECORD_CLASS && isRecord0();
return getSuperclass() == java.lang.Record.class && isRecord0();
}

// Fetches the factory for reflective objects
Expand Down

0 comments on commit cdb41ba

Please sign in to comment.