changeset 52918:7d3c741eb854 amber-demo

Automatic merge with datum
author mcimadamore
date Fri, 26 Oct 2018 18:20:35 +0200
parents c40c92b3249b f9cc2fc9cf12
children 30e15200fb90
files
diffstat 5 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/make/hotspot/symbols/symbols-unix	Wed Oct 24 23:15:33 2018 +0200
+++ b/make/hotspot/symbols/symbols-unix	Fri Oct 26 18:20:35 2018 +0200
@@ -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 23:15:33 2018 +0200
+++ b/src/hotspot/share/include/jvm.h	Fri Oct 26 18:20:35 2018 +0200
@@ -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 23:15:33 2018 +0200
+++ b/src/hotspot/share/prims/jvm.cpp	Fri Oct 26 18:20:35 2018 +0200
@@ -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 23:15:33 2018 +0200
+++ b/src/java.base/share/classes/java/lang/Class.java	Fri Oct 26 18:20:35 2018 +0200
@@ -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 23:15:33 2018 +0200
+++ b/src/java.base/share/native/libjava/Class.c	Fri Oct 26 18:20:35 2018 +0200
@@ -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