You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by GitBox <gi...@apache.org> on 2022/03/31 23:42:58 UTC

[GitHub] [thrift] Jimexist commented on a change in pull request #2552: add type parameter to java lib field metadata

Jimexist commented on a change in pull request #2552:
URL: https://github.com/apache/thrift/pull/2552#discussion_r840109944



##########
File path: lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java
##########
@@ -68,21 +64,24 @@ public static void addStructMetaDataMap(Class<? extends TBase> sClass, Map<? ext
    *               {@link FieldMetaData#addStructMetaDataMap(Class, Map)} from a different
    *               thread during static initialization of the Thrift class is possible.
    */
-  public static Map<? extends TFieldIdEnum, FieldMetaData> getStructMetaDataMap(
-      Class<? extends TBase> sClass) {
+  public static <T extends TBase<T, F>, F extends TFieldIdEnum> Map<F, FieldMetaData> getStructMetaDataMap(
+      Class<T> sClass) {
     // Note: Do not use synchronized on this method declaration - it leads to a deadlock.
     // Similarly, do not trigger sClass.newInstance() while holding a lock on structMap,
     // it will lead to the same deadlock.
     // See: https://issues.apache.org/jira/browse/THRIFT-5430 for details.
-    if (!structMap.containsKey(sClass)){ // Load class if it hasn't been loaded
-      try{
-        sClass.newInstance();
-      } catch (InstantiationException e){
+    if (!structMap.containsKey(sClass)) { // Load class if it hasn't been loaded
+      try {
+        sClass.getDeclaredConstructor().newInstance();

Review comment:
       `T.newInstance()` is deprecated since Java 9.




-- 
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: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org