changeset 52917:f9cc2fc9cf12 datum

adding the pipes to support Class::getRecordParametersCount, JNI, etc
author vromero
date Fri, 26 Oct 2018 12:01:57 -0400
parents 2b7b9c2711b3
children 7d3c741eb854 350f92339d2f
files make/hotspot/symbols/symbols-unix src/hotspot/share/include/jvm.h src/hotspot/share/prims/jvm.cpp src/java.base/share/classes/java/lang/Class.java src/java.base/share/native/libjava/Class.c
diffstat 5 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/make/hotspot/symbols/symbols-unix	Wed Oct 24 17:03:43 2018 -0400
+++ b/make/hotspot/symbols/symbols-unix	Fri Oct 26 12:01:57 2018 -0400
@@ -124,6 +124,7 @@
 JVM_GetPrimitiveArrayElement
 JVM_GetProtectionDomain
 JVM_GetRecordParameters
+JVM_GetRecordParametersCount
 JVM_GetSimpleBinaryName
 JVM_GetStackAccessControlContext
 JVM_GetSystemPackage
--- a/src/hotspot/share/include/jvm.h	Wed Oct 24 17:03:43 2018 -0400
+++ b/src/hotspot/share/include/jvm.h	Fri Oct 26 12:01:57 2018 -0400
@@ -518,6 +518,9 @@
 JNIEXPORT jobjectArray JNICALL
 JVM_GetRecordParameters(JNIEnv *env, jclass ofClass);
 
+JNIEXPORT jint JNICALL
+JVM_GetRecordParametersCount(JNIEnv *env, jclass ofClass);
+
 /* Differs from JVM_GetClassModifiers in treatment of inner classes.
    This returns the access flags for the class as specified in the
    class file rather than searching the InnerClasses attribute (if
--- a/src/hotspot/share/prims/jvm.cpp	Wed Oct 24 17:03:43 2018 -0400
+++ b/src/hotspot/share/prims/jvm.cpp	Fri Oct 26 12:01:57 2018 -0400
@@ -1788,6 +1788,26 @@
 }
 JVM_END
 
+JVM_ENTRY(jint, JVM_GetRecordParametersCount(JNIEnv *env, jclass ofClass))
+{
+  JVMWrapper("JVM_GetRecordParametersCount");
+  JvmtiVMObjectAllocEventCollector oam;
+
+  // Exclude primitive types and array types
+  if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) ||
+      java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->is_array_klass()) {
+    // Return 0
+    return 0;
+  }
+
+  InstanceKlass* k = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)));
+  // Ensure class is linked
+  k->link_class(CHECK_0);
+
+  return k->record_params_count();
+}
+JVM_END
+
 JVM_ENTRY(jobjectArray, JVM_GetRecordParameters(JNIEnv *env, jclass ofClass))
 {
   JVMWrapper("JVM_GetRecordParameters");
--- a/src/java.base/share/classes/java/lang/Class.java	Wed Oct 24 17:03:43 2018 -0400
+++ b/src/java.base/share/classes/java/lang/Class.java	Fri Oct 26 12:01:57 2018 -0400
@@ -2252,6 +2252,13 @@
     }
 
     /**
+     * Returns the number of record parameters if this class is a record, 0 if not
+     * @return the number of record parameters
+     * @since 1.12
+     */
+    public native int getRecordParametersCount();
+
+    /**
      * Returns an array containing {@code Method} objects reflecting all the
      * declared methods of the class or interface represented by this {@code
      * Class} object, including public, protected, default (package)
--- a/src/java.base/share/native/libjava/Class.c	Wed Oct 24 17:03:43 2018 -0400
+++ b/src/java.base/share/native/libjava/Class.c	Fri Oct 26 12:01:57 2018 -0400
@@ -76,7 +76,8 @@
     {"getRawTypeAnnotations", "()" BA,      (void *)&JVM_GetClassTypeAnnotations},
     {"getNestHost0",         "()" CLS,      (void *)&JVM_GetNestHost},
     {"getNestMembers0",      "()[" CLS,     (void *)&JVM_GetNestMembers},
-    {"getRecordParameters0",  "()[" FLD,     (void *)&JVM_GetRecordParameters},
+    {"getRecordParameters0",  "()[" FLD,    (void *)&JVM_GetRecordParameters},
+    {"getRecordParametersCount", "()I",     (void *)&JVM_GetRecordParametersCount},
 };
 
 #undef OBJ