You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/10/05 12:55:11 UTC
svn commit: r1811201 - in /tomcat/trunk/java/org/apache/naming/factory:
BeanFactory.java EjbFactory.java FactoryBase.java ResourceFactory.java
Author: markt
Date: Thu Oct 5 12:55:10 2017
New Revision: 1811201
URL: http://svn.apache.org/viewvc?rev=1811201&view=rev
Log:
Fix some more deprecation warnings when building with Java 9.
Use of Class.newInstance() in o.a.naming
Modified:
tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java
tomcat/trunk/java/org/apache/naming/factory/EjbFactory.java
tomcat/trunk/java/org/apache/naming/factory/FactoryBase.java
tomcat/trunk/java/org/apache/naming/factory/ResourceFactory.java
Modified: tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java?rev=1811201&r1=1811200&r2=1811201&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java (original)
+++ tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java Thu Oct 5 12:55:10 2017
@@ -145,7 +145,7 @@ public class BeanFactory
BeanInfo bi = Introspector.getBeanInfo(beanClass);
PropertyDescriptor[] pda = bi.getPropertyDescriptors();
- Object bean = beanClass.newInstance();
+ Object bean = beanClass.getDeclaredConstructor().newInstance();
/* Look for properties with explicitly configured setter */
RefAddr ra = ref.get("forceString");
@@ -288,24 +288,16 @@ public class BeanFactory
NamingException ne = new NamingException(ie.getMessage());
ne.setRootCause(ie);
throw ne;
- } catch (java.lang.IllegalAccessException iae) {
- NamingException ne = new NamingException(iae.getMessage());
- ne.setRootCause(iae);
- throw ne;
- } catch (java.lang.InstantiationException ie2) {
- NamingException ne = new NamingException(ie2.getMessage());
- ne.setRootCause(ie2);
- throw ne;
- } catch (java.lang.reflect.InvocationTargetException ite) {
- Throwable cause = ite.getCause();
+ } catch (java.lang.ReflectiveOperationException e) {
+ Throwable cause = e.getCause();
if (cause instanceof ThreadDeath) {
throw (ThreadDeath) cause;
}
if (cause instanceof VirtualMachineError) {
throw (VirtualMachineError) cause;
}
- NamingException ne = new NamingException(ite.getMessage());
- ne.setRootCause(ite);
+ NamingException ne = new NamingException(e.getMessage());
+ ne.setRootCause(e);
throw ne;
}
Modified: tomcat/trunk/java/org/apache/naming/factory/EjbFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/EjbFactory.java?rev=1811201&r1=1811200&r2=1811201&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/factory/EjbFactory.java (original)
+++ tomcat/trunk/java/org/apache/naming/factory/EjbFactory.java Thu Oct 5 12:55:10 2017
@@ -44,7 +44,7 @@ public class EjbFactory extends FactoryB
"javax.ejb.Factory", Constants.OPENEJB_EJB_FACTORY);
try {
factory = (ObjectFactory)
- Class.forName(javaxEjbFactoryClassName).newInstance();
+ Class.forName(javaxEjbFactoryClassName).getDeclaredConstructor().newInstance();
} catch(Throwable t) {
if (t instanceof NamingException) {
throw (NamingException) t;
Modified: tomcat/trunk/java/org/apache/naming/factory/FactoryBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/FactoryBase.java?rev=1811201&r1=1811200&r2=1811201&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/factory/FactoryBase.java (original)
+++ tomcat/trunk/java/org/apache/naming/factory/FactoryBase.java Thu Oct 5 12:55:10 2017
@@ -69,7 +69,7 @@ public abstract class FactoryBase implem
throw ex;
}
try {
- factory = (ObjectFactory) factoryClass.newInstance();
+ factory = (ObjectFactory) factoryClass.getDeclaredConstructor().newInstance();
} catch(Throwable t) {
if (t instanceof NamingException) {
throw (NamingException) t;
Modified: tomcat/trunk/java/org/apache/naming/factory/ResourceFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/ResourceFactory.java?rev=1811201&r1=1811200&r2=1811201&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/factory/ResourceFactory.java (original)
+++ tomcat/trunk/java/org/apache/naming/factory/ResourceFactory.java Thu Oct 5 12:55:10 2017
@@ -45,7 +45,7 @@ public class ResourceFactory extends Fac
Constants.DBCP_DATASOURCE_FACTORY);
try {
factory = (ObjectFactory) Class.forName(
- javaxSqlDataSourceFactoryClassName).newInstance();
+ javaxSqlDataSourceFactoryClassName).getDeclaredConstructor().newInstance();
} catch (Exception e) {
NamingException ex = new NamingException(
"Could not create resource factory instance");
@@ -57,8 +57,8 @@ public class ResourceFactory extends Fac
System.getProperty("javax.mail.Session.Factory",
"org.apache.naming.factory.MailSessionFactory");
try {
- factory = (ObjectFactory)
- Class.forName(javaxMailSessionFactoryClassName).newInstance();
+ factory = (ObjectFactory) Class.forName(
+ javaxMailSessionFactoryClassName).getDeclaredConstructor().newInstance();
} catch(Throwable t) {
if (t instanceof NamingException) {
throw (NamingException) t;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org