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


##########
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:
   Good point! I refactored this part a bit.



-- 
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