http-client-branch: remove usage of deprecated Class::newInstance http-client-branch
authordfuchs
Tue, 21 Nov 2017 16:39:20 +0000
branchhttp-client-branch
changeset 55848 5c13ff6e444b
parent 55847 3bac3bca4adb
child 55849 ad404eb1c8c1
http-client-branch: remove usage of deprecated Class::newInstance
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AuthenticationFilter.java
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/FilterFactory.java
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RedirectFilter.java
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AuthenticationFilter.java	Tue Nov 21 17:17:37 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/AuthenticationFilter.java	Tue Nov 21 16:39:20 2017 +0000
@@ -54,6 +54,9 @@
     static final int UNAUTHORIZED = 401;
     static final int PROXY_UNAUTHORIZED = 407;
 
+    // A public no-arg constructor is required by FilterFactory
+    public AuthenticationFilter() {}
+
     private PasswordAuthentication getCredentials(String header,
                                                   boolean proxy,
                                                   HttpRequestImpl req)
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/FilterFactory.java	Tue Nov 21 17:17:37 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/FilterFactory.java	Tue Nov 21 16:39:20 2017 +0000
@@ -40,8 +40,8 @@
         List<HeaderFilter> l = new LinkedList<>();
         for (Class<? extends HeaderFilter> clazz : filterClasses) {
             try {
-                @SuppressWarnings("deprecation")
-                HeaderFilter headerFilter = clazz.newInstance();
+                // Requires a public no arg constructor.
+                HeaderFilter headerFilter = clazz.getConstructor().newInstance();
                 l.add(headerFilter);
             } catch (ReflectiveOperationException e) {
                 throw new InternalError(e);
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java	Tue Nov 21 17:17:37 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java	Tue Nov 21 16:39:20 2017 +0000
@@ -34,7 +34,6 @@
 import java.net.CookieHandler;
 import java.net.NetPermission;
 import java.net.ProxySelector;
-import java.net.URI;
 import java.nio.channels.CancelledKeyException;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.SelectableChannel;
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RedirectFilter.java	Tue Nov 21 17:17:37 2017 +0300
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RedirectFilter.java	Tue Nov 21 16:39:20 2017 +0000
@@ -44,6 +44,9 @@
             "jdk.httpclient.redirects.retrylimit", DEFAULT_MAX_REDIRECTS
     );
 
+    // A public no-arg constructor is required by FilterFactory
+    public RedirectFilter() {}
+
     @Override
     public synchronized void request(HttpRequestImpl r, MultiExchange<?,?> e) throws IOException {
         this.request = r;