davidradl commented on code in PR #27500:
URL: https://github.com/apache/flink/pull/27500#discussion_r2754075157


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/extraction/ExtractionUtils.java:
##########
@@ -777,6 +782,49 @@ private AssigningConstructor(Constructor<?> constructor, 
List<String> parameterN
         return fieldNames;
     }
 
+    /**
+     * Returns the record component names for the given class if the current 
JDK supports records
+     * (has Class.isRecord / getRecordComponents), and the given class is 
actually a record.
+     */
+    static @Nullable List<String> extractRecordComponentNames(Class<?> type) {
+        try {
+            // Check Class.isRecord() reflectively so it compiles on Java 11
+            final Method isRecordMethod = Class.class.getMethod("isRecord");
+            final boolean isRecord = (Boolean) isRecordMethod.invoke(type);
+            if (!isRecord) {
+                return null;
+            }
+
+            // Check Class.getRecordComponents() reflectively
+            final Method getRecordComponentsMethod = 
Class.class.getMethod("getRecordComponents");

Review Comment:
   the change looks good - I am wondering what you think about caching the 
classes and records we have reflectively found, to avoid repeating the 
reflection calls. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to