changeset 52921:716341307709 datum

adding Class::getRecordParameterTypes
author vromero
date Fri, 26 Oct 2018 12:58:45 -0400
parents 350f92339d2f
children 3486dd38dbda cb7760bcb5b5
files src/java.base/share/classes/java/lang/Class.java
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Class.java	Fri Oct 26 12:41:08 2018 -0400
+++ b/src/java.base/share/classes/java/lang/Class.java	Fri Oct 26 12:58:45 2018 -0400
@@ -3546,6 +3546,7 @@
 
     /**
      * Returns an array with the names of the components
+     *
      * @return an array with the names of the components
      * @since 1.12
      */
@@ -3564,6 +3565,27 @@
         }
     }
 
+    /**
+     * Returns an array with the types of the record parameters
+     *
+     * @return an array with the types of the record parameters
+     * @since 1.12
+     */
+    public Class<?>[] getRecordParameterTypes() {
+        if (isRecord()) {
+            Field[] recordParameters = getRecordParameters();
+            Class<?>[] types = new Class<?>[recordParameters.length];
+            int i = 0;
+            for (Field field : recordParameters) {
+                types[i] = field.getType();
+                i++;
+            }
+            return types;
+        } else {
+            return new Class<?>[0];
+        }
+    }
+
     // Fetches the factory for reflective objects
     private static ReflectionFactory getReflectionFactory() {
         if (reflectionFactory == null) {