changeset 51553:1d32d49d12eb datum

adding method Class::isRecord non-native version
author vromero
date Wed, 11 Jul 2018 14:30:16 -0700
parents a62c46b49b6d
children 1469f48bf928
files src/java.base/share/classes/java/lang/Class.java
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Class.java	Wed Jul 11 14:30:14 2018 -0700
+++ b/src/java.base/share/classes/java/lang/Class.java	Wed Jul 11 14:30:16 2018 -0700
@@ -3505,6 +3505,19 @@
         this.getSuperclass() == java.lang.Enum.class;
     }
 
+    /**
+     * Returns true if and only if this class was declared as a record in the
+     * source code.
+     *
+     * @return true if and only if this class was declared as a record in the
+     *     source code
+     * @since 1.12
+     */
+    public boolean isRecord() {
+        // A record must directly extend java.lang.AbstractRecord
+        return this.getSuperclass() == java.lang.AbstractRecord.class;
+    }
+
     // Fetches the factory for reflective objects
     private static ReflectionFactory getReflectionFactory() {
         if (reflectionFactory == null) {