RFR [14] 8235550: Clarify record reflective support specification

Chris Hegarty chris.hegarty at oracle.com
Tue Dec 10 14:34:37 UTC 2019


Maurizio,

> On 10 Dec 2019, at 12:39, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> Looks good.
Thank you. I updated and finalised the CSR.
> Minor nits:
> 
> * in getRecordComponents there are some utterings of "true", "false" and "null" which are not surrounded by a {@code } block.
> 
> * any reason as to why the j.l.Record class is not cached in a static field?
> 
No reason. Done.

Changes over the previous webrev:

diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java
--- a/src/java.base/share/classes/java/lang/Class.java
+++ b/src/java.base/share/classes/java/lang/Class.java
@@ -2278,9 +2278,9 @@
      * <p> The components are returned in the same order that they are declared
      * in the record header. The array is empty if this record class has no
      * components. If the class is not a record class, that is {@link
-     * #isRecord()} returns false, then this method returns null. Conversely, if
-     * {@link #isRecord()} returns true, then this method returns a non-null
-     * value.
+     * #isRecord()} returns {@code false}, then this method returns {@code null}.
+     * Conversely, if {@link #isRecord()} returns {@code true}, then this method
+     * returns a non-null value.
      *
      * @return  An array of {@code RecordComponent} objects representing all the
      *          record components of this record class, or {@code null} if this
@@ -3596,8 +3596,7 @@
         this.getSuperclass() == java.lang.Enum.class;
     }
 

-    /** Returns java.lang.Record.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);
@@ -3631,7 +3630,7 @@
     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
                                  essentialAPI=false)
     public boolean isRecord() {
-        return getSuperclass() == javaLangRecordClass() && isRecord0();
+        return getSuperclass() == JAVA_LANG_RECORD_CLASS && isRecord0();
     }
 
     // Fetches the factory for reflective objects
  
Complete webrev:
   https://cr.openjdk.java.net/~chegar/8235550/webrev.01/

-Chris.


More information about the amber-dev mailing list