changeset 51551:2c5938e024ed datum

adding method Class::isRecord
author vromero
date Wed, 11 Jul 2018 13:02:59 -0700
parents 071e5a606986
children a62c46b49b6d
files make/hotspot/symbols/symbols-unix src/hotspot/share/classfile/systemDictionary.hpp src/hotspot/share/classfile/vmSymbols.hpp src/hotspot/share/include/jvm.h src/hotspot/share/oops/klass.cpp src/hotspot/share/oops/klass.hpp src/hotspot/share/prims/jvm.cpp src/java.base/share/classes/java/lang/Class.java src/java.base/share/native/libjava/Class.c
diffstat 9 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/make/hotspot/symbols/symbols-unix	Tue Jul 03 08:17:31 2018 -0700
+++ b/make/hotspot/symbols/symbols-unix	Wed Jul 11 13:02:59 2018 -0700
@@ -144,6 +144,7 @@
 JVM_IsInterface
 JVM_IsInterrupted
 JVM_IsPrimitiveClass
+JVM_IsRecord
 JVM_IsSameClassPackage
 JVM_IsSupportedJNIVersion
 JVM_IsThreadAlive
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Tue Jul 03 08:17:31 2018 -0700
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Wed Jul 11 13:02:59 2018 -0700
@@ -212,6 +212,9 @@
   do_klass(Integer_klass,                               java_lang_Integer,                         Pre                 ) \
   do_klass(Long_klass,                                  java_lang_Long,                            Pre                 ) \
                                                                                                                          \
+  /* Super class for all records */                                                                                      \
+  do_klass(AbstractRecord_klass,                       java_lang_AbstractRecord,                  Pre                  ) \
+                                                                                                                         \
   /* JVMCI classes. These are loaded on-demand. */                                                                       \
   JVMCI_WK_KLASSES_DO(do_klass)                                                                                          \
                                                                                                                          \
--- a/src/hotspot/share/classfile/vmSymbols.hpp	Tue Jul 03 08:17:31 2018 -0700
+++ b/src/hotspot/share/classfile/vmSymbols.hpp	Wed Jul 11 13:02:59 2018 -0700
@@ -329,6 +329,7 @@
   template(java_lang_StackFrameInfo,                  "java/lang/StackFrameInfo")                 \
   template(java_lang_LiveStackFrameInfo,              "java/lang/LiveStackFrameInfo")             \
   template(java_lang_StackStreamFactory_AbstractStackWalker, "java/lang/StackStreamFactory$AbstractStackWalker") \
+  template(java_lang_AbstractRecord,                  "java/lang/AbstractRecord")                 \
   template(doStackWalk_signature,                     "(JIIII)Ljava/lang/Object;")                \
   template(asPrimitive_name,                          "asPrimitive")                              \
   template(asPrimitive_int_signature,                 "(I)Ljava/lang/LiveStackFrame$PrimitiveSlot;") \
--- a/src/hotspot/share/include/jvm.h	Tue Jul 03 08:17:31 2018 -0700
+++ b/src/hotspot/share/include/jvm.h	Wed Jul 11 13:02:59 2018 -0700
@@ -454,6 +454,9 @@
 JNIEXPORT jboolean JNICALL
 JVM_IsInterface(JNIEnv *env, jclass cls);
 
+JNIEXPORT jboolean JNICALL
+JVM_IsRecord(JNIEnv *env, jclass cls);
+
 JNIEXPORT jobjectArray JNICALL
 JVM_GetClassSigners(JNIEnv *env, jclass cls);
 
--- a/src/hotspot/share/oops/klass.cpp	Tue Jul 03 08:17:31 2018 -0700
+++ b/src/hotspot/share/oops/klass.cpp	Wed Jul 11 13:02:59 2018 -0700
@@ -62,6 +62,10 @@
          is_subtype_of(SystemDictionary::Cloneable_klass());
 }
 
+bool Klass::is_record() const {
+  return is_subtype_of(SystemDictionary::AbstractRecord_klass());
+}
+
 void Klass::set_is_cloneable() {
   if (name() == vmSymbols::java_lang_invoke_MemberName()) {
     assert(is_final(), "no subclasses allowed");
--- a/src/hotspot/share/oops/klass.hpp	Tue Jul 03 08:17:31 2018 -0700
+++ b/src/hotspot/share/oops/klass.hpp	Wed Jul 11 13:02:59 2018 -0700
@@ -624,6 +624,7 @@
   void set_is_shared()                  { _access_flags.set_is_shared_class(); }
 
   bool is_cloneable() const;
+  bool is_record() const;
   void set_is_cloneable();
 
   // Biased locking support
--- a/src/hotspot/share/prims/jvm.cpp	Tue Jul 03 08:17:31 2018 -0700
+++ b/src/hotspot/share/prims/jvm.cpp	Wed Jul 11 13:02:59 2018 -0700
@@ -1108,6 +1108,19 @@
   return result;
 JVM_END
 
+JVM_QUICK_ENTRY(jboolean, JVM_IsRecord(JNIEnv *env, jclass cls))
+  JVMWrapper("JVM_IsRecord");
+  oop mirror = JNIHandles::resolve_non_null(cls);
+  if (java_lang_Class::is_primitive(mirror)) {
+    return JNI_FALSE;
+  }
+  Klass* k = java_lang_Class::as_Klass(mirror);
+  jboolean result = k->is_record();
+  assert(!result || k->is_instance_klass(),
+         "all records are instance types");
+  return result;
+JVM_END
+
 
 JVM_ENTRY(jobjectArray, JVM_GetClassSigners(JNIEnv *env, jclass cls))
   JVMWrapper("JVM_GetClassSigners");
--- a/src/java.base/share/classes/java/lang/Class.java	Tue Jul 03 08:17:31 2018 -0700
+++ b/src/java.base/share/classes/java/lang/Class.java	Wed Jul 11 13:02:59 2018 -0700
@@ -664,6 +664,15 @@
     @HotSpotIntrinsicCandidate
     public native boolean isInterface();
 
+    /**
+     * Determines if the specified {@code Class} object represents a
+     * a record.
+     *
+     * @return  {@code true} if this object represents a record;
+     *          {@code false} otherwise.
+     */
+    public native boolean isRecord();
+
 
     /**
      * Determines if this {@code Class} object represents an array class.
--- a/src/java.base/share/native/libjava/Class.c	Tue Jul 03 08:17:31 2018 -0700
+++ b/src/java.base/share/native/libjava/Class.c	Wed Jul 11 13:02:59 2018 -0700
@@ -56,6 +56,7 @@
     {"getSuperclass",    "()" CLS,          NULL},
     {"getInterfaces0",   "()[" CLS,         (void *)&JVM_GetClassInterfaces},
     {"isInterface",      "()Z",             (void *)&JVM_IsInterface},
+    {"isRecord",         "()Z",             (void *)&JVM_IsRecord},
     {"getSigners",       "()[" OBJ,         (void *)&JVM_GetClassSigners},
     {"setSigners",       "([" OBJ ")V",     (void *)&JVM_SetClassSigners},
     {"isArray",          "()Z",             (void *)&JVM_IsArrayClass},