tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1811203 - in /tomcat/trunk/java/org/apache/tomcat: ./ dbcp/dbcp2/ dbcp/pool2/impl/ util/digester/ util/modeler/ util/net/ util/net/jsse/ websocket/ websocket/pojo/ websocket/server/
Date Thu, 05 Oct 2017 13:08:35 GMT
Author: markt
Date: Thu Oct  5 13:08:33 2017
New Revision: 1811203

URL: http://svn.apache.org/viewvc?rev=1811203&view=rev
Log:
Fix some more deprecation warnings when building with Java 9.
Use of Class.newInstance() in o.a.tomcat

Modified:
    tomcat/trunk/java/org/apache/tomcat/SimpleInstanceManager.java
    tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java
    tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
    tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java
    tomcat/trunk/java/org/apache/tomcat/util/digester/ObjectCreateRule.java
    tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java
    tomcat/trunk/java/org/apache/tomcat/util/modeler/Registry.java
    tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java
    tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEUtil.java
    tomcat/trunk/java/org/apache/tomcat/websocket/Util.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
    tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
    tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
    tomcat/trunk/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java
    tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java
    tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java

Modified: tomcat/trunk/java/org/apache/tomcat/SimpleInstanceManager.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/SimpleInstanceManager.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/SimpleInstanceManager.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/SimpleInstanceManager.java Thu Oct  5 13:08:33 2017
@@ -32,24 +32,24 @@ public class SimpleInstanceManager imple
 
     @Override
     public Object newInstance(Class<?> clazz) throws IllegalAccessException,
-            InvocationTargetException, NamingException, InstantiationException {
-        return prepareInstance(clazz.newInstance());
+            InvocationTargetException, NamingException, InstantiationException, NoSuchMethodException
{
+        return prepareInstance(clazz.getDeclaredConstructor().newInstance());
     }
 
     @Override
     public Object newInstance(String className) throws IllegalAccessException,
             InvocationTargetException, NamingException, InstantiationException,
-            ClassNotFoundException  {
+            ClassNotFoundException, NoSuchMethodException  {
         Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
-        return prepareInstance(clazz.newInstance());
+        return prepareInstance(clazz.getDeclaredConstructor().newInstance());
     }
 
     @Override
     public Object newInstance(String fqcn, ClassLoader classLoader) throws IllegalAccessException,
             InvocationTargetException, NamingException, InstantiationException,
-            ClassNotFoundException  {
+            ClassNotFoundException, NoSuchMethodException  {
         Class<?> clazz = classLoader.loadClass(fqcn);
-        return prepareInstance(clazz.newInstance());
+        return prepareInstance(clazz.getDeclaredConstructor().newInstance());
     }
 
     @Override

Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java Thu Oct  5 13:08:33
2017
@@ -2153,7 +2153,7 @@ public class BasicDataSource implements
                     // Usage of DriverManager is not possible, as it does not
                     // respect the ContextClassLoader
                     // N.B. This cast may cause ClassCastException which is handled below
-                    driverToUse = (Driver) driverFromCCL.newInstance();
+                    driverToUse = (Driver) driverFromCCL.getDeclaredConstructor().newInstance();
                     if (!driverToUse.acceptsURL(url)) {
                         throw new SQLException("No suitable driver", "08001");
                     }

Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java Thu Oct
 5 13:08:33 2017
@@ -605,7 +605,7 @@ public abstract class BaseGenericObjectP
             } catch (final ClassNotFoundException e) {
                 clazz = Class.forName(evictionPolicyClassName);
             }
-            final Object policy = clazz.newInstance();
+            final Object policy = clazz.getDeclaredConstructor().newInstance();
             if (policy instanceof EvictionPolicy<?>) {
                 @SuppressWarnings("unchecked") // safe, because we just checked the class
                 final
@@ -616,11 +616,7 @@ public abstract class BaseGenericObjectP
             throw new IllegalArgumentException(
                     "Unable to create EvictionPolicy instance of type " +
                     evictionPolicyClassName, e);
-        } catch (final InstantiationException e) {
-            throw new IllegalArgumentException(
-                    "Unable to create EvictionPolicy instance of type " +
-                    evictionPolicyClassName, e);
-        } catch (final IllegalAccessException e) {
+        } catch (final ReflectiveOperationException e) {
             throw new IllegalArgumentException(
                     "Unable to create EvictionPolicy instance of type " +
                     evictionPolicyClassName, e);

Modified: tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java Thu Oct  5 13:08:33 2017
@@ -94,7 +94,8 @@ public class Digester extends DefaultHan
             for (int i = 0; i < cls.length; i++) {
                 try {
                     Class<?> clazz = Class.forName(className, true, cls[i]);
-                    source = (IntrospectionUtils.PropertySource) clazz.newInstance();
+                    source = (IntrospectionUtils.PropertySource)
+                            clazz.getDeclaredConstructor().newInstance();
                     break;
                 } catch (Throwable t) {
                     ExceptionUtils.handleThrowable(t);

Modified: tomcat/trunk/java/org/apache/tomcat/util/digester/ObjectCreateRule.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/digester/ObjectCreateRule.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/digester/ObjectCreateRule.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/digester/ObjectCreateRule.java Thu Oct  5 13:08:33
2017
@@ -114,7 +114,7 @@ public class ObjectCreateRule extends Ru
 
         // Instantiate the new object and push it on the context stack
         Class<?> clazz = digester.getClassLoader().loadClass(realClassName);
-        Object instance = clazz.newInstance();
+        Object instance = clazz.getDeclaredConstructor().newInstance();
         digester.push(instance);
     }
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/modeler/ManagedBean.java Thu Oct  5 13:08:33
2017
@@ -318,7 +318,7 @@ public class ManagedBean implements java
             }
             try {
                 // Stupid - this will set the default minfo first....
-                mbean = (BaseModelMBean) clazz.newInstance();
+                mbean = (BaseModelMBean) clazz.getDeclaredConstructor().newInstance();
             } catch (RuntimeOperationsException e) {
                 throw e;
             } catch (Exception e) {

Modified: tomcat/trunk/java/org/apache/tomcat/util/modeler/Registry.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/modeler/Registry.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/modeler/Registry.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/modeler/Registry.java Thu Oct  5 13:08:33 2017
@@ -711,7 +711,7 @@ public class Registry implements Registr
         }
 
         Class<?> c = Class.forName(type);
-        ModelerSource ds=(ModelerSource)c.newInstance();
+        ModelerSource ds=(ModelerSource)c.getDeclaredConstructor().newInstance();
         return ds;
     }
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SSLImplementation.java Thu Oct  5 13:08:33
2017
@@ -53,7 +53,7 @@ public abstract class SSLImplementation
 
         try {
             Class<?> clazz = Class.forName(className);
-            return (SSLImplementation) clazz.newInstance();
+            return (SSLImplementation) clazz.getDeclaredConstructor().newInstance();
         } catch (Exception e) {
             String msg = sm.getString("sslImplementation.cnfe", className);
             if (logger.isDebugEnabled()) {

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEUtil.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEUtil.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/jsse/JSSEUtil.java Thu Oct  5 13:08:33 2017
@@ -290,7 +290,7 @@ public class JSSEUtil extends SSLUtilBas
                 throw new InstantiationException(sm.getString(
                         "jsse.invalidTrustManagerClassName", className));
              }
-             Object trustManagerObject = clazz.newInstance();
+             Object trustManagerObject = clazz.getDeclaredConstructor().newInstance();
              TrustManager trustManager = (TrustManager) trustManagerObject;
              return new TrustManager[]{ trustManager };
         }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/Util.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/Util.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/Util.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/Util.java Thu Oct  5 13:08:33 2017
@@ -342,8 +342,8 @@ public class Util {
                 @SuppressWarnings("unused")
                 Decoder instance;
                 try {
-                    instance = decoderClazz.newInstance();
-                } catch (InstantiationException | IllegalAccessException e) {
+                    instance = decoderClazz.getDeclaredConstructor().newInstance();
+                } catch (ReflectiveOperationException e) {
                     throw new DeploymentException(
                             sm.getString("pojoMethodMapping.invalidDecoder",
                                     decoderClazz.getName()), e);

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java Thu Oct  5
13:08:33 2017
@@ -676,9 +676,9 @@ public abstract class WsRemoteEndpointIm
                 endpointConfig.getEncoders()) {
             Encoder instance;
             try {
-                instance = encoderClazz.newInstance();
+                instance = encoderClazz.getDeclaredConstructor().newInstance();
                 instance.init(endpointConfig);
-            } catch (InstantiationException | IllegalAccessException e) {
+            } catch (ReflectiveOperationException e) {
                 throw new DeploymentException(
                         sm.getString("wsRemoteEndpoint.invalidEncoder",
                                 encoderClazz.getName()), e);

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Thu Oct  5 13:08:33
2017
@@ -132,8 +132,8 @@ public class WsWebSocketContainer implem
         if (!ClientEndpointConfig.Configurator.class.equals(
                 configuratorClazz)) {
             try {
-                configurator = configuratorClazz.newInstance();
-            } catch (InstantiationException | IllegalAccessException e) {
+                configurator = configuratorClazz.getDeclaredConstructor().newInstance();
+            } catch (ReflectiveOperationException e) {
                 throw new DeploymentException(sm.getString(
                         "wsWebSocketContainer.defaultConfiguratorFail"), e);
             }
@@ -159,8 +159,8 @@ public class WsWebSocketContainer implem
 
         Object pojo;
         try {
-            pojo = annotatedEndpointClass.newInstance();
-        } catch (InstantiationException | IllegalAccessException e) {
+            pojo = annotatedEndpointClass.getDeclaredConstructor().newInstance();
+        } catch (ReflectiveOperationException e) {
             throw new DeploymentException(sm.getString(
                     "wsWebSocketContainer.endpointCreateFail",
                     annotatedEndpointClass.getName()), e);
@@ -177,8 +177,8 @@ public class WsWebSocketContainer implem
 
         Endpoint endpoint;
         try {
-            endpoint = clazz.newInstance();
-        } catch (InstantiationException | IllegalAccessException e) {
+            endpoint = clazz.getDeclaredConstructor().newInstance();
+        } catch (ReflectiveOperationException e) {
             throw new DeploymentException(sm.getString(
                     "wsWebSocketContainer.endpointCreateFail", clazz.getName()),
                     e);

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
Thu Oct  5 13:08:33 2017
@@ -67,13 +67,13 @@ public class PojoMessageHandlerWholeBina
                 for (Class<? extends Decoder> decoderClazz : decoderClazzes) {
                     if (Binary.class.isAssignableFrom(decoderClazz)) {
                         Binary<?> decoder =
-                                (Binary<?>) decoderClazz.newInstance();
+                                (Binary<?>) decoderClazz.getDeclaredConstructor().newInstance();
                         decoder.init(config);
                         decoders.add(decoder);
                     } else if (BinaryStream.class.isAssignableFrom(
                             decoderClazz)) {
-                        BinaryStream<?> decoder =
-                                (BinaryStream<?>) decoderClazz.newInstance();
+                        BinaryStream<?> decoder = (BinaryStream<?>)
+                                decoderClazz.getDeclaredConstructor().newInstance();
                         decoder.init(config);
                         decoders.add(decoder);
                     } else {
@@ -81,7 +81,7 @@ public class PojoMessageHandlerWholeBina
                     }
                 }
             }
-        } catch (IllegalAccessException | InstantiationException e) {
+        } catch (ReflectiveOperationException e) {
             throw new IllegalArgumentException(e);
         }
         this.isForInputStream = isForInputStream;

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java Thu
Oct  5 13:08:33 2017
@@ -75,13 +75,14 @@ public class PojoMessageHandlerWholeText
             if (decoderClazzes != null) {
                 for (Class<? extends Decoder> decoderClazz : decoderClazzes) {
                     if (Text.class.isAssignableFrom(decoderClazz)) {
-                        Text<?> decoder = (Text<?>) decoderClazz.newInstance();
+                        Text<?> decoder =
+                                (Text<?>) decoderClazz.getDeclaredConstructor().newInstance();
                         decoder.init(config);
                         decoders.add(decoder);
                     } else if (TextStream.class.isAssignableFrom(
                             decoderClazz)) {
                         TextStream<?> decoder =
-                                (TextStream<?>) decoderClazz.newInstance();
+                                (TextStream<?>) decoderClazz.getDeclaredConstructor().newInstance();
                         decoder.init(config);
                         decoders.add(decoder);
                     } else {
@@ -89,7 +90,7 @@ public class PojoMessageHandlerWholeText
                     }
                 }
             }
-        } catch (IllegalAccessException | InstantiationException e) {
+        } catch (ReflectiveOperationException e) {
             throw new IllegalArgumentException(e);
         }
     }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java
Thu Oct  5 13:08:33 2017
@@ -33,8 +33,10 @@ public class DefaultServerEndpointConfig
     public <T> T getEndpointInstance(Class<T> clazz)
             throws InstantiationException {
         try {
-            return clazz.newInstance();
-        } catch (IllegalAccessException e) {
+            return clazz.getDeclaredConstructor().newInstance();
+        } catch (InstantiationException e) {
+            throw e;
+        } catch (ReflectiveOperationException e) {
             InstantiationException ie = new InstantiationException();
             ie.initCause(e);
             throw ie;

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/server/WsSci.java Thu Oct  5 13:08:33 2017
@@ -72,7 +72,7 @@ public class WsSci implements ServletCon
                 }
                 if (ServerApplicationConfig.class.isAssignableFrom(clazz)) {
                     serverApplicationConfigs.add(
-                            (ServerApplicationConfig) clazz.newInstance());
+                            (ServerApplicationConfig) clazz.getDeclaredConstructor().newInstance());
                 }
                 if (Endpoint.class.isAssignableFrom(clazz)) {
                     @SuppressWarnings("unchecked")
@@ -84,7 +84,7 @@ public class WsSci implements ServletCon
                     scannedPojoEndpoints.add(clazz);
                 }
             }
-        } catch (InstantiationException | IllegalAccessException e) {
+        } catch (ReflectiveOperationException e) {
             throw new ServletException(e);
         }
 

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java?rev=1811203&r1=1811202&r2=1811203&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/server/WsServerContainer.java Thu Oct  5
13:08:33 2017
@@ -214,8 +214,8 @@ public class WsServerContainer extends W
         Configurator configurator = null;
         if (!configuratorClazz.equals(Configurator.class)) {
             try {
-                configurator = annotation.configurator().newInstance();
-            } catch (InstantiationException | IllegalAccessException e) {
+                configurator = annotation.configurator().getDeclaredConstructor().newInstance();
+            } catch (ReflectiveOperationException e) {
                 throw new DeploymentException(sm.getString(
                         "serverContainer.configuratorFail",
                         annotation.configurator().getName(),
@@ -416,8 +416,8 @@ public class WsServerContainer extends W
             @SuppressWarnings("unused")
             Encoder instance;
             try {
-                encoder.newInstance();
-            } catch(InstantiationException | IllegalAccessException e) {
+                encoder.getDeclaredConstructor().newInstance();
+            } catch(ReflectiveOperationException e) {
                 throw new DeploymentException(sm.getString(
                         "serverContainer.encoderFail", encoder.getName()), e);
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message