[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-lib/master] Remove deprecation warning.



commit 25ea064dc8214385f2077706b2635f2da0d530fa
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Wed Nov 20 10:34:35 2019 +0100

    Remove deprecation warning.
    
    Class#newInstance is deprecated in Java 9 and higher, which doesn't
    affect us yet in Java 8. But the suggested replacement already works
    in Java 8, so that we can safely switch to that.
---
 src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java b/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java
index e755e42..55fbcf3 100644
--- a/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java
+++ b/src/main/java/org/torproject/descriptor/DescriptorSourceFactory.java
@@ -146,10 +146,9 @@ public final class DescriptorSourceFactory {
               + ".");
       }
       object = ClassLoader.getSystemClassLoader().loadClass(clazzName)
-          .newInstance();
+          .getDeclaredConstructor().newInstance();
       log.info("Serving implementation {} for {}.", clazzName, type);
-    } catch (ClassNotFoundException | InstantiationException
-             | IllegalAccessException ex) {
+    } catch (ReflectiveOperationException ex) {
       throw new RuntimeException("Cannot load class "
           + clazzName + "for type " + type, ex);
     }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits