Repository: bval
Updated Branches:
  refs/heads/bv2 330afb5b6 -> 30e01238e


ensure to use .getConstructor().newInstance() instead of newInstance() 
(newInstance() is deprecated in j9)


Project: http://git-wip-us.apache.org/repos/asf/bval/repo
Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/30e01238
Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/30e01238
Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/30e01238

Branch: refs/heads/bv2
Commit: 30e01238e1a8143e1b079abc3aec5e7123e528f1
Parents: 330afb5
Author: Romain Manni-Bucau <rmannibu...@gmail.com>
Authored: Fri Feb 23 09:08:56 2018 +0100
Committer: Romain Manni-Bucau <rmannibu...@gmail.com>
Committed: Fri Feb 23 09:08:56 2018 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/bval/util/reflection/Reflection.java | 2 +-
 .../main/java/org/apache/bval/jsr/ApacheValidatorFactory.java | 2 +-
 .../src/main/java/org/apache/bval/jsr/ConfigurationImpl.java  | 4 ++--
 .../apache/bval/jsr/DefaultConstraintValidatorFactory.java    | 2 +-
 .../java/org/apache/bval/jsr/DefaultMessageInterpolator.java  | 3 ++-
 .../apache/bval/jsr/resolver/DefaultTraversableResolver.java  | 2 +-
 .../org/apache/bval/jsr/valueextraction/ValueExtractors.java  | 7 +++++--
 .../src/main/java/org/apache/bval/arquillian/EJBEnricher.java | 2 +-
 .../src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java   | 3 ++-
 9 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bval/blob/30e01238/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java
----------------------------------------------------------------------
diff --git 
a/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java 
b/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java
index 221a277..79e88fb 100644
--- a/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java
+++ b/bval-core/src/main/java/org/apache/bval/util/reflection/Reflection.java
@@ -333,7 +333,7 @@ public class Reflection {
      */
     public static <T> T newInstance(final Class<T> cls) {
         try {
-            return cls.newInstance();
+            return cls.getConstructor().newInstance();
         } catch (final Exception ex) {
             throw new RuntimeException("Cannot instantiate : " + cls, ex);
         }

http://git-wip-us.apache.org/repos/asf/bval/blob/30e01238/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheValidatorFactory.java
----------------------------------------------------------------------
diff --git 
a/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheValidatorFactory.java 
b/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheValidatorFactory.java
index b516a73..3bff1c5 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheValidatorFactory.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheValidatorFactory.java
@@ -554,7 +554,7 @@ public class ApacheValidatorFactory implements 
ValidatorFactory, Cloneable {
             if (c != null) {
                 return c.newInstance(this);
             }
-            return cls.newInstance();
+            return cls.getConstructor().newInstance();
         } catch (Exception e) {
             throw new ValidationException(e);
         }

http://git-wip-us.apache.org/repos/asf/bval/blob/30e01238/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java 
b/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
index 3545383..658273c 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/ConfigurationImpl.java
@@ -430,7 +430,7 @@ public class ConfigurationImpl implements 
ApacheValidatorConfiguration, Configur
             return knownProvider.get();
         }
         try {
-            return providerClass.newInstance();
+            return providerClass.getConstructor().newInstance();
         } catch (Exception e) {
             throw Exceptions.create(ValidationException::new, "Unable to 
find/create %s of type %s",
                 ValidationProvider.class.getSimpleName(), providerClass);
@@ -471,7 +471,7 @@ public class ConfigurationImpl implements 
ApacheValidatorConfiguration, Configur
         } catch (Exception | NoClassDefFoundError e) {
         }
         try {
-            return cls.newInstance();
+            return cls.getConstructor().newInstance();
         } catch (final Exception e) {
             throw new ValidationException(e.getMessage(), e);
         }

http://git-wip-us.apache.org/repos/asf/bval/blob/30e01238/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java
----------------------------------------------------------------------
diff --git 
a/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java
 
b/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java
index 9474705..7bfb7bf 100644
--- 
a/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java
+++ 
b/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultConstraintValidatorFactory.java
@@ -69,7 +69,7 @@ public class DefaultConstraintValidatorFactory implements 
ConstraintValidatorFac
                 } catch (Exception | NoClassDefFoundError e) {
                 }
             }
-            return constraintClass.newInstance();
+            return constraintClass.getConstructor().newInstance();
         } catch (final Exception ex) {
             throw new ValidationException("Cannot instantiate : " + 
constraintClass, ex);
         }

http://git-wip-us.apache.org/repos/asf/bval/blob/30e01238/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java
----------------------------------------------------------------------
diff --git 
a/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java 
b/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java
index 6a85a2a..624a32b 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java
@@ -86,7 +86,8 @@ public class DefaultMessageInterpolator implements 
MessageInterpolator {
         MessageEvaluator ev;
         try {
             ev = MessageEvaluator.class
-                
.cast(getClass().getClassLoader().loadClass("org.apache.bval.el.ELFacade").newInstance());
+                
.cast(getClass().getClassLoader().loadClass("org.apache.bval.el.ELFacade")
+                                .getConstructor().newInstance());
         } catch (final Throwable e) { // can be exception or error
             ev = null;
         }

http://git-wip-us.apache.org/repos/asf/bval/blob/30e01238/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
----------------------------------------------------------------------
diff --git 
a/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
 
b/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
index d8b392e..d09299a 100644
--- 
a/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
+++ 
b/bval-jsr/src/main/java/org/apache/bval/jsr/resolver/DefaultTraversableResolver.java
@@ -89,7 +89,7 @@ public class DefaultTraversableResolver implements 
TraversableResolver, CachingR
             Class<? extends TraversableResolver> jpaAwareResolverClass =
                 (Class<? extends TraversableResolver>) 
Reflection.toClass(JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME,
                     classLoader);
-            jpaTR = jpaAwareResolverClass.newInstance();
+            jpaTR = jpaAwareResolverClass.getConstructor().newInstance();
             if (LOG_FINEST) {
                 log.log(Level.FINEST,
                     String.format("Instantiated an instance of %s.", 
JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME));

http://git-wip-us.apache.org/repos/asf/bval/blob/30e01238/bval-jsr/src/main/java/org/apache/bval/jsr/valueextraction/ValueExtractors.java
----------------------------------------------------------------------
diff --git 
a/bval-jsr/src/main/java/org/apache/bval/jsr/valueextraction/ValueExtractors.java
 
b/bval-jsr/src/main/java/org/apache/bval/jsr/valueextraction/ValueExtractors.java
index 50feb6c..3adc541 100644
--- 
a/bval-jsr/src/main/java/org/apache/bval/jsr/valueextraction/ValueExtractors.java
+++ 
b/bval-jsr/src/main/java/org/apache/bval/jsr/valueextraction/ValueExtractors.java
@@ -17,6 +17,7 @@
 package org.apache.bval.jsr.valueextraction;
 
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.util.Collection;
@@ -95,9 +96,11 @@ public class ValueExtractors {
 
     private static <T> T newInstance(Class<T> t) {
         try {
-            return t.newInstance();
-        } catch (InstantiationException | IllegalAccessException e) {
+            return t.getConstructor().newInstance();
+        } catch (NoSuchMethodException | InstantiationException | 
IllegalAccessException e) {
             throw new IllegalStateException(e);
+        } catch (InvocationTargetException e) {
+            throw new IllegalStateException(e.getTargetException());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/bval/blob/30e01238/bval-tck11/src/main/java/org/apache/bval/arquillian/EJBEnricher.java
----------------------------------------------------------------------
diff --git 
a/bval-tck11/src/main/java/org/apache/bval/arquillian/EJBEnricher.java 
b/bval-tck11/src/main/java/org/apache/bval/arquillian/EJBEnricher.java
index 36c738d..da55ba5 100644
--- a/bval-tck11/src/main/java/org/apache/bval/arquillian/EJBEnricher.java
+++ b/bval-tck11/src/main/java/org/apache/bval/arquillian/EJBEnricher.java
@@ -32,7 +32,7 @@ public class EJBEnricher implements TestEnricher {
         for (final Field field : testCase.getClass().getDeclaredFields()) {
             if (field.getAnnotation(EJB.class) != null) {
                 try {
-                    final Object instance = field.getType().newInstance();
+                    final Object instance = 
field.getType().getConstructor().newInstance();
                     for (final Field f : field.getType().getDeclaredFields()) {
                         if (f.getAnnotation(Resource.class) != null) {
                             if (f.getType().equals(Validator.class)) {

http://git-wip-us.apache.org/repos/asf/bval/blob/30e01238/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
----------------------------------------------------------------------
diff --git 
a/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java 
b/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
index 7bbeac6..0126fc6 100644
--- a/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
+++ b/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanInfos.java
@@ -108,7 +108,8 @@ public class XMLMetaBeanInfos {
         final HashMap<String, XMLMetaValidator> map = new HashMap<String, 
XMLMetaValidator>(validators.size());
         for (XMLMetaValidator xv : validators) {
             if (xv.getJava() != null) {
-                Validation validation = (Validation) 
Reflection.toClass(xv.getJava()).newInstance();
+                Validation validation = (Validation) 
Reflection.toClass(xv.getJava())
+                                                               
.getConstructor().newInstance();
                 xv.setValidation(validation);
                 map.put(xv.getId(), xv);
             }

Reply via email to