You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2019/05/09 07:28:44 UTC

[groovy] branch GROOVY_2_5_X updated (9456fb2 -> acb827f)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a change to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from 9456fb2  GROOVY-9063: @CompileStatic generates invalid bytecode when accessing protected instance member from 2 level of nested closures
     new d776675  minor refactor: avoid deprecated method usage
     new acb827f  minor refactor: avoid deprecated method usage

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/groovy/groovy/grape/Grape.java            |   5 +-
 .../groovy/transform/options/PropertyHandler.java  |   6 +-
 .../org/codehaus/groovy/runtime/InvokerHelper.java |   2 +-
 .../m12n/StandardPropertiesModuleFactory.java      |   7 +-
 .../runtime/metaclass/MetaClassRegistryImpl.java   |   5 +-
 .../typehandling/DefaultTypeTransformation.java    |   2 +-
 .../ASTTransformationCollectorCodeVisitor.java     |   5 +-
 .../groovy/transform/ASTTransformationVisitor.java |   7 +-
 .../groovy/transform/BuilderASTTransformation.java |   6 +-
 .../groovy/transform/LogASTTransformation.java     |   2 +-
 .../stc/GroovyTypeCheckingExtensionSupport.java    |   6 +-
 .../transform/stc/StaticTypeCheckingVisitor.java   |   9 +-
 .../codehaus/groovy/vmplugin/VMPluginFactory.java  |   2 +-
 src/test/groovy/bugs/Groovy2365Bug.java            |   4 +-
 src/test/groovy/lang/TupleTest.java                | 126 +++++++++++----------
 src/test/org/codehaus/groovy/classgen/ForTest.java |   6 +-
 .../org/codehaus/groovy/classgen/GStringTest.java  |   2 +-
 .../groovy/classgen/GroovyClassLoaderTest.java     |   2 +-
 .../org/codehaus/groovy/classgen/IfElseTest.java   |   2 +-
 .../org/codehaus/groovy/classgen/MethodTest.java   |   2 +-
 .../org/codehaus/groovy/classgen/PropertyTest.java |   4 +-
 .../org/codehaus/groovy/classgen/TestSupport.java  |   2 +-
 .../codehaus/groovy/classgen/TupleListTest.java    |   2 +-
 .../src/test/java/groovy/util/MBeanTest.java       |   2 +-
 .../main/java/groovy/servlet/TemplateServlet.java  |   7 +-
 .../codehaus/groovy/binding/PropertyBinding.java   |   4 +-
 .../groovy/groovy/text/GStringTemplateEngine.java  |   5 +-
 .../groovy/text/StreamingTemplateEngine.java       |   5 +-
 .../src/main/java/groovy/util/AllTestSuite.java    |   3 +-
 .../src/main/java/groovy/xml/XmlUtil.java          |   2 +-
 30 files changed, 123 insertions(+), 121 deletions(-)


[groovy] 01/02: minor refactor: avoid deprecated method usage

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit d77667553e07b3d608d32d966c06ebbd50a5ff05
Author: Paul King <pa...@asert.com.au>
AuthorDate: Wed May 8 19:23:18 2019 +1000

    minor refactor: avoid deprecated method usage
---
 src/main/groovy/groovy/grape/Grape.java                          | 5 +++--
 src/main/groovy/groovy/transform/options/PropertyHandler.java    | 6 +-----
 src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java     | 2 +-
 .../groovy/runtime/m12n/StandardPropertiesModuleFactory.java     | 7 ++++---
 .../codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java | 5 +++--
 .../groovy/runtime/typehandling/DefaultTypeTransformation.java   | 2 +-
 .../groovy/transform/ASTTransformationCollectorCodeVisitor.java  | 5 +++--
 .../org/codehaus/groovy/transform/ASTTransformationVisitor.java  | 7 ++++---
 .../org/codehaus/groovy/transform/BuilderASTTransformation.java  | 6 +-----
 .../java/org/codehaus/groovy/transform/LogASTTransformation.java | 2 +-
 .../groovy/transform/stc/GroovyTypeCheckingExtensionSupport.java | 6 +++---
 .../codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java | 9 +++++----
 src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java  | 2 +-
 src/test/groovy/bugs/Groovy2365Bug.java                          | 4 ++--
 src/test/org/codehaus/groovy/classgen/ForTest.java               | 6 +++---
 src/test/org/codehaus/groovy/classgen/GStringTest.java           | 2 +-
 src/test/org/codehaus/groovy/classgen/GroovyClassLoaderTest.java | 2 +-
 src/test/org/codehaus/groovy/classgen/IfElseTest.java            | 2 +-
 src/test/org/codehaus/groovy/classgen/MethodTest.java            | 2 +-
 src/test/org/codehaus/groovy/classgen/PropertyTest.java          | 4 ++--
 src/test/org/codehaus/groovy/classgen/TestSupport.java           | 2 +-
 src/test/org/codehaus/groovy/classgen/TupleListTest.java         | 2 +-
 subprojects/groovy-jmx/src/test/java/groovy/util/MBeanTest.java  | 2 +-
 .../src/main/java/groovy/servlet/TemplateServlet.java            | 7 ++++---
 .../main/java/org/codehaus/groovy/binding/PropertyBinding.java   | 4 ++--
 .../src/main/groovy/groovy/text/GStringTemplateEngine.java       | 5 +++--
 .../src/main/groovy/groovy/text/StreamingTemplateEngine.java     | 5 +++--
 .../groovy-test/src/main/java/groovy/util/AllTestSuite.java      | 3 +--
 subprojects/groovy-xml/src/main/java/groovy/xml/XmlUtil.java     | 2 +-
 29 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/src/main/groovy/groovy/grape/Grape.java b/src/main/groovy/groovy/grape/Grape.java
index 0bbe9ee..fe0239d 100644
--- a/src/main/groovy/groovy/grape/Grape.java
+++ b/src/main/groovy/groovy/grape/Grape.java
@@ -18,6 +18,7 @@
  */
 package groovy.grape;
 
+import java.lang.reflect.InvocationTargetException;
 import java.net.URI;
 import java.util.Collections;
 import java.util.List;
@@ -120,8 +121,8 @@ public class Grape {
             try {
                 // by default use GrapeIvy
                 //TODO META-INF/services resolver?
-                instance = (GrapeEngine) Class.forName("groovy.grape.GrapeIvy").newInstance();
-            } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
+                instance = (GrapeEngine) Class.forName("groovy.grape.GrapeIvy").getDeclaredConstructor().newInstance();
+            } catch (InstantiationException | ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
                 //LOGME
             }
         }
diff --git a/src/main/groovy/groovy/transform/options/PropertyHandler.java b/src/main/groovy/groovy/transform/options/PropertyHandler.java
index fc9029a..8469a4d 100644
--- a/src/main/groovy/groovy/transform/options/PropertyHandler.java
+++ b/src/main/groovy/groovy/transform/options/PropertyHandler.java
@@ -102,11 +102,7 @@ public abstract class PropertyHandler {
 
         String className = handlerClass.getName();
         try {
-            Object instance = loader.loadClass(className).newInstance();
-            if (instance == null) {
-                xform.addError("Can't load propertyHandler '" + className + "'", anno);
-                return null;
-            }
+            Object instance = loader.loadClass(className).getDeclaredConstructor().newInstance();
             if (!PropertyHandler.class.isAssignableFrom(instance.getClass())) {
                 xform.addError("The propertyHandler class '" + handlerClass.getName() + "' on " + xform.getAnnotationName() + " is not a propertyHandler", anno);
                 return null;
diff --git a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
index 1e6781f..76fc8b6 100644
--- a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
+++ b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
@@ -439,7 +439,7 @@ public class InvokerHelper {
                 if (Script.class.isAssignableFrom(scriptClass)) {
                     script = newScript(scriptClass, context);
                 } else {
-                    final GroovyObject object = (GroovyObject) scriptClass.newInstance();
+                    final GroovyObject object = (GroovyObject) scriptClass.getDeclaredConstructor().newInstance();
                     // it could just be a class, so let's wrap it in a Script
                     // wrapper; though the bindings will be ignored
                     script = new Script(context) {
diff --git a/src/main/java/org/codehaus/groovy/runtime/m12n/StandardPropertiesModuleFactory.java b/src/main/java/org/codehaus/groovy/runtime/m12n/StandardPropertiesModuleFactory.java
index 87946a6..3c148b6 100644
--- a/src/main/java/org/codehaus/groovy/runtime/m12n/StandardPropertiesModuleFactory.java
+++ b/src/main/java/org/codehaus/groovy/runtime/m12n/StandardPropertiesModuleFactory.java
@@ -20,6 +20,7 @@ package org.codehaus.groovy.runtime.m12n;
 
 import groovy.lang.GroovyRuntimeException;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.Properties;
 
 /**
@@ -38,11 +39,11 @@ public class StandardPropertiesModuleFactory extends PropertiesModuleFactory {
         if (factoryName!=null) {
             try {
                 Class<? extends PropertiesModuleFactory> factoryClass = (Class<? extends PropertiesModuleFactory>) classLoader.loadClass(factoryName);
-                PropertiesModuleFactory delegate = factoryClass.newInstance();
+                PropertiesModuleFactory delegate = factoryClass.getDeclaredConstructor().newInstance();
                 return delegate.newModule(properties, classLoader);
-            } catch (ClassNotFoundException e) {
+            } catch (ClassNotFoundException | NoSuchMethodException e) {
                 throw new GroovyRuntimeException("Unable to load module factory ["+factoryName+"]",e);
-            } catch (InstantiationException | IllegalAccessException e) {
+            } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
                 throw new GroovyRuntimeException("Unable to instantiate module factory ["+factoryName+"]",e);
             }
         }
diff --git a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
index 1c6cc65..569c386 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
@@ -43,6 +43,7 @@ import org.codehaus.groovy.vmplugin.VMPluginFactory;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -254,7 +255,7 @@ public class MetaClassRegistryImpl implements MetaClassRegistry{
 
     private void createMetaMethodFromClass(Map<CachedClass, List<MetaMethod>> map, Class aClass) {
         try {
-            MetaMethod method = (MetaMethod) aClass.newInstance();
+            MetaMethod method = (MetaMethod) aClass.getDeclaredConstructor().newInstance();
             final CachedClass declClass = method.getDeclaringClass();
             List<MetaMethod> arr = map.get(declClass);
             if (arr == null) {
@@ -263,7 +264,7 @@ public class MetaClassRegistryImpl implements MetaClassRegistry{
             }
             arr.add(method);
             instanceMethods.add(method);
-        } catch (InstantiationException | IllegalAccessException e) { /* ignore */
+        } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { /* ignore */
         }
     }
 
diff --git a/src/main/java/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java b/src/main/java/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
index 3f974e9..222bf67 100644
--- a/src/main/java/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
+++ b/src/main/java/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
@@ -259,7 +259,7 @@ public class DefaultTypeTransformation {
                 // let's call the collections constructor
                 // passing in the list wrapper
                 try {
-                    answer = (Collection) type.newInstance();
+                    answer = (Collection) type.getDeclaredConstructor().newInstance();
                 } catch (Exception e) {
                     throw new GroovyCastException("Could not instantiate instance of: " + type.getName() + ". Reason: " + e);
                 }
diff --git a/src/main/java/org/codehaus/groovy/transform/ASTTransformationCollectorCodeVisitor.java b/src/main/java/org/codehaus/groovy/transform/ASTTransformationCollectorCodeVisitor.java
index d6e8dd5..0ed0f11 100644
--- a/src/main/java/org/codehaus/groovy/transform/ASTTransformationCollectorCodeVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/ASTTransformationCollectorCodeVisitor.java
@@ -39,6 +39,7 @@ import org.codehaus.groovy.transform.trait.TraitASTTransformation;
 import org.codehaus.groovy.transform.trait.Traits;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -219,8 +220,8 @@ public class ASTTransformationCollectorCodeVisitor extends ClassCodeVisitorSuppo
                     Class klass = loadTransformClass(className, aliasNode);
                     if (klass != null) {
                         try {
-                            act = (AnnotationCollectorTransform) klass.newInstance();
-                        } catch (InstantiationException | IllegalAccessException e) {
+                            act = (AnnotationCollectorTransform) klass.getDeclaredConstructor().newInstance();
+                        } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
                             source.getErrorCollector().addErrorAndContinue(new ExceptionMessage(e, true, source));
                         }
                     }
diff --git a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
index 28eee64..696ea5f 100644
--- a/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/ASTTransformationVisitor.java
@@ -39,6 +39,7 @@ import org.codehaus.groovy.util.URLStreams;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -106,8 +107,8 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
             final Map<Class<? extends ASTTransformation>, ASTTransformation> transformInstances = new HashMap<Class<? extends ASTTransformation>, ASTTransformation>();
             for (Class<? extends ASTTransformation> transformClass : baseTransforms.keySet()) {
                 try {
-                    transformInstances.put(transformClass, transformClass.newInstance());
-                } catch (InstantiationException | IllegalAccessException e) {
+                    transformInstances.put(transformClass, transformClass.getDeclaredConstructor().newInstance());
+                } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
                     source.getErrorCollector().addError(
                             new SimpleMessage(
                                     "Could not instantiate Transformation Processor " + transformClass
@@ -309,7 +310,7 @@ public final class ASTTransformationVisitor extends ClassCodeVisitorSupport {
                     continue;
                 }
                 if (ASTTransformation.class.isAssignableFrom(gTransClass)) {
-                    final ASTTransformation instance = (ASTTransformation)gTransClass.newInstance();
+                    final ASTTransformation instance = (ASTTransformation)gTransClass.getDeclaredConstructor().newInstance();
                     if (instance instanceof CompilationUnitAware) {
                         ((CompilationUnitAware)instance).setCompilationUnit(compilationUnit);
                     }
diff --git a/src/main/java/org/codehaus/groovy/transform/BuilderASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/BuilderASTTransformation.java
index 3f4ea27..7c9964a 100644
--- a/src/main/java/org/codehaus/groovy/transform/BuilderASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/BuilderASTTransformation.java
@@ -255,11 +255,7 @@ public class BuilderASTTransformation extends AbstractASTTransformation implemen
 
         String className = strategyClass.getName();
         try {
-            Object instance = loader.loadClass(className).newInstance();
-            if (instance == null) {
-                addError("Can't load builderStrategy '" + className + "'", anno);
-                return null;
-            }
+            Object instance = loader.loadClass(className).getDeclaredConstructor().newInstance();
             if (!BuilderStrategy.class.isAssignableFrom(instance.getClass())) {
                 addError("The builderStrategy class '" + strategyClass.getName() + "' on " + MY_TYPE_NAME + " is not a builderStrategy", anno);
                 return null;
diff --git a/src/main/java/org/codehaus/groovy/transform/LogASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/LogASTTransformation.java
index 1895062..ac9af0b 100644
--- a/src/main/java/org/codehaus/groovy/transform/LogASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/LogASTTransformation.java
@@ -223,7 +223,7 @@ public class LogASTTransformation extends AbstractASTTransformation implements C
             if (AbstractLoggingStrategy.class.isAssignableFrom(strategyClass)) {
                 return DefaultGroovyMethods.newInstance(strategyClass, new Object[]{loader});
             } else {
-                return strategyClass.newInstance();
+                return strategyClass.getDeclaredConstructor().newInstance();
             }
         } catch (Exception e) {
             return null;
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/GroovyTypeCheckingExtensionSupport.java b/src/main/java/org/codehaus/groovy/transform/stc/GroovyTypeCheckingExtensionSupport.java
index dd6ffa3..d456331 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/GroovyTypeCheckingExtensionSupport.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/GroovyTypeCheckingExtensionSupport.java
@@ -129,7 +129,7 @@ public class GroovyTypeCheckingExtensionSupport extends AbstractTypeCheckingExte
         try {
             Class<?> clazz = transformLoader.loadClass(scriptPath, false, true);
             if (TypeCheckingDSL.class.isAssignableFrom(clazz)) {
-                script = (TypeCheckingDSL) clazz.newInstance();
+                script = (TypeCheckingDSL) clazz.getDeclaredConstructor().newInstance();
             } else if (TypeCheckingExtension.class.isAssignableFrom(clazz)) {
                 // since 2.4, we can also register precompiled type checking extensions which are not scripts
                 try {
@@ -147,9 +147,9 @@ public class GroovyTypeCheckingExtensionSupport extends AbstractTypeCheckingExte
                     );
                 }
             }
-        } catch (ClassNotFoundException e) {
+        } catch (ClassNotFoundException | NoSuchMethodException e) {
             // silent
-        } catch (InstantiationException | IllegalAccessException e) {
+        } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
             addLoadingError(config);
         }
         if (script==null) {
diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index edb8e8d..2eade00 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -109,6 +109,7 @@ import org.codehaus.groovy.transform.trait.Traits;
 import org.codehaus.groovy.util.ListHashMap;
 import org.objectweb.asm.Opcodes;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -2841,13 +2842,13 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             ClassLoader transformLoader = getTransformLoader();
             @SuppressWarnings("unchecked")
             Class<? extends ClosureSignatureHint> hint = (Class<? extends ClosureSignatureHint>) transformLoader.loadClass(hintClass.getText());
-            ClosureSignatureHint hintInstance = hint.newInstance();
+            ClosureSignatureHint hintInstance = hint.getDeclaredConstructor().newInstance();
             closureSignatures = hintInstance.getClosureSignatures(
                     selectedMethod instanceof ExtensionMethodNode ? ((ExtensionMethodNode) selectedMethod).getExtensionMethodNode() : selectedMethod,
                     typeCheckingContext.source,
                     typeCheckingContext.compilationUnit,
                     convertToStringArray(options), expression);
-        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
+        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
             throw new GroovyBugError(e);
         }
         return closureSignatures;
@@ -2859,7 +2860,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
             ClassLoader transformLoader = getTransformLoader();
             @SuppressWarnings("unchecked")
             Class<? extends ClosureSignatureConflictResolver> resolver = (Class<? extends ClosureSignatureConflictResolver>) transformLoader.loadClass(resolverClass.getText());
-            ClosureSignatureConflictResolver resolverInstance = resolver.newInstance();
+            ClosureSignatureConflictResolver resolverInstance = resolver.getDeclaredConstructor().newInstance();
             return resolverInstance.resolve(
                     candidates,
                     receiver,
@@ -2869,7 +2870,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                     typeCheckingContext.source,
                     typeCheckingContext.compilationUnit,
                     convertToStringArray(options));
-        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
+        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
             throw new GroovyBugError(e);
         }
     }
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java b/src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java
index 25a1269..f6cf64a 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java
@@ -54,7 +54,7 @@ public class VMPluginFactory {
         try {
             ClassLoader loader = VMPluginFactory.class.getClassLoader();
             loader.loadClass(classNameCheck);
-            return (VMPlugin) loader.loadClass(pluginName).newInstance();
+            return (VMPlugin) loader.loadClass(pluginName).getDeclaredConstructor().newInstance();
         } catch (Throwable ex) {
             return null;
         }
diff --git a/src/test/groovy/bugs/Groovy2365Bug.java b/src/test/groovy/bugs/Groovy2365Bug.java
index 7e11ace..b70aeec 100644
--- a/src/test/groovy/bugs/Groovy2365Bug.java
+++ b/src/test/groovy/bugs/Groovy2365Bug.java
@@ -49,7 +49,7 @@ public class Groovy2365Bug extends Groovy2365Base {
                     Thread thread1 = new Thread() {
                         public void run() {
                             try {
-                                Script script = (Script) script1Class.newInstance();
+                                Script script = (Script) script1Class.getDeclaredConstructor().newInstance();
                                 script.run();
                                 completed [0] = true;
                             } catch (Exception e) {
@@ -62,7 +62,7 @@ public class Groovy2365Bug extends Groovy2365Base {
                         public void run() {
                             try {
                                 Class cls = groovyLoader.loadClass("Script2", true, true);
-                                Script script = (Script) cls.newInstance();
+                                Script script = (Script) cls.getDeclaredConstructor().newInstance();
                                 script.run();
                                 completed [1] = true;
                             } catch (Exception e) {
diff --git a/src/test/org/codehaus/groovy/classgen/ForTest.java b/src/test/org/codehaus/groovy/classgen/ForTest.java
index 83de44b..165d1a3 100644
--- a/src/test/org/codehaus/groovy/classgen/ForTest.java
+++ b/src/test/org/codehaus/groovy/classgen/ForTest.java
@@ -40,7 +40,7 @@ public class ForTest extends TestSupport {
         Class fooClass = loadClass(classNode);
         assertTrue("Loaded a new class", fooClass != null);
 
-        Object bean = fooClass.newInstance();
+        Object bean = fooClass.getDeclaredConstructor().newInstance();
         assertTrue("Managed to create bean", bean != null);
 
         System.out.println("################ Now about to invoke a method without looping");
@@ -71,7 +71,7 @@ public class ForTest extends TestSupport {
         Class fooClass = loadClass(classNode);
         assertTrue("Loaded a new class", fooClass != null);
 
-        Object bean = fooClass.newInstance();
+        Object bean = fooClass.getDeclaredConstructor().newInstance();
         assertTrue("Managed to create bean", bean != null);
 
         System.out.println("################ Now about to invoke a method with looping");
@@ -103,7 +103,7 @@ public class ForTest extends TestSupport {
         Class fooClass = loadClass(classNode);
         assertTrue("Loaded a new class", fooClass != null);
 
-        Object bean = fooClass.newInstance();
+        Object bean = fooClass.getDeclaredConstructor().newInstance();
         assertTrue("Managed to create bean", bean != null);
 
         System.out.println("################ Now about to invoke a method with many parameters");
diff --git a/src/test/org/codehaus/groovy/classgen/GStringTest.java b/src/test/org/codehaus/groovy/classgen/GStringTest.java
index 4cdaa5d..1513f32 100644
--- a/src/test/org/codehaus/groovy/classgen/GStringTest.java
+++ b/src/test/org/codehaus/groovy/classgen/GStringTest.java
@@ -78,7 +78,7 @@ public class GStringTest extends TestSupport {
         Class fooClass = loadClass(classNode);
         assertTrue("Loaded a new class", fooClass != null);
 
-        Object bean = fooClass.newInstance();
+        Object bean = fooClass.getDeclaredConstructor().newInstance();
         assertTrue("Managed to create bean", bean != null);
 
         //Object[] array = { new Integer(1234), "abc", "def" };
diff --git a/src/test/org/codehaus/groovy/classgen/GroovyClassLoaderTest.java b/src/test/org/codehaus/groovy/classgen/GroovyClassLoaderTest.java
index f7e86a8..76d2f63 100644
--- a/src/test/org/codehaus/groovy/classgen/GroovyClassLoaderTest.java
+++ b/src/test/org/codehaus/groovy/classgen/GroovyClassLoaderTest.java
@@ -34,7 +34,7 @@ public class GroovyClassLoaderTest extends TestSupport {
 
         System.out.println("Invoking main...");
 
-        GroovyObject object = (GroovyObject) groovyClass.newInstance();
+        GroovyObject object = (GroovyObject) groovyClass.getDeclaredConstructor().newInstance();
 
         assertTrue(object != null);
 
diff --git a/src/test/org/codehaus/groovy/classgen/IfElseTest.java b/src/test/org/codehaus/groovy/classgen/IfElseTest.java
index 3622041..7d72581 100644
--- a/src/test/org/codehaus/groovy/classgen/IfElseTest.java
+++ b/src/test/org/codehaus/groovy/classgen/IfElseTest.java
@@ -62,7 +62,7 @@ public class IfElseTest extends TestSupport {
         Class fooClass = loadClass(classNode);
         assertTrue("Loaded a new class", fooClass != null);
 
-        Object bean = fooClass.newInstance();
+        Object bean = fooClass.getDeclaredConstructor().newInstance();
         assertTrue("Managed to create bean", bean != null);
 
         assertSetProperty(bean, "bar", "abc");
diff --git a/src/test/org/codehaus/groovy/classgen/MethodTest.java b/src/test/org/codehaus/groovy/classgen/MethodTest.java
index 8b295f2..6769adc 100644
--- a/src/test/org/codehaus/groovy/classgen/MethodTest.java
+++ b/src/test/org/codehaus/groovy/classgen/MethodTest.java
@@ -46,7 +46,7 @@ public class MethodTest extends TestSupport {
         Class fooClass = loadClass(classNode);
         assertTrue("Loaded a new class", fooClass != null);
 
-        Object bean = fooClass.newInstance();
+        Object bean = fooClass.getDeclaredConstructor().newInstance();
         assertTrue("Created instance of class: " + bean, bean != null);
 
         assertCallMethod(bean, "a", "calledA");
diff --git a/src/test/org/codehaus/groovy/classgen/PropertyTest.java b/src/test/org/codehaus/groovy/classgen/PropertyTest.java
index 187be59..31834ca 100644
--- a/src/test/org/codehaus/groovy/classgen/PropertyTest.java
+++ b/src/test/org/codehaus/groovy/classgen/PropertyTest.java
@@ -48,7 +48,7 @@ public class PropertyTest extends TestSupport {
         Class fooClass = loadClass(classNode);
         assertTrue("Loaded a new class", fooClass != null);
 
-        Object bean = fooClass.newInstance();
+        Object bean = fooClass.getDeclaredConstructor().newInstance();
         assertTrue("Managed to create bean", bean != null);
 
         assertField(fooClass, "bar", 0, ClassHelper.STRING_TYPE);
@@ -64,7 +64,7 @@ public class PropertyTest extends TestSupport {
         Class fooClass = loadClass(classNode);
         assertTrue("Loaded a new class", fooClass != null);
 
-        Object bean = fooClass.newInstance();
+        Object bean = fooClass.getDeclaredConstructor().newInstance();
         assertTrue("Managed to create bean", bean != null);
 
         assertField(fooClass, "bar", 0, ClassHelper.STRING_TYPE);
diff --git a/src/test/org/codehaus/groovy/classgen/TestSupport.java b/src/test/org/codehaus/groovy/classgen/TestSupport.java
index b9b7b87..a984174 100644
--- a/src/test/org/codehaus/groovy/classgen/TestSupport.java
+++ b/src/test/org/codehaus/groovy/classgen/TestSupport.java
@@ -170,7 +170,7 @@ public class TestSupport extends GroovyTestCase implements Opcodes {
 
     protected GroovyObject compile(String fileName) throws Exception {
         Class groovyClass = loader.parseClass(new GroovyCodeSource(new File(fileName)));
-        GroovyObject object = (GroovyObject) groovyClass.newInstance();
+        GroovyObject object = (GroovyObject) groovyClass.getDeclaredConstructor().newInstance();
         assertTrue(object != null);
         return object;
     }
diff --git a/src/test/org/codehaus/groovy/classgen/TupleListTest.java b/src/test/org/codehaus/groovy/classgen/TupleListTest.java
index 65a0019..84e1ed7 100644
--- a/src/test/org/codehaus/groovy/classgen/TupleListTest.java
+++ b/src/test/org/codehaus/groovy/classgen/TupleListTest.java
@@ -64,7 +64,7 @@ public class TupleListTest extends TestSupport {
         Class fooClass = loadClass(classNode);
         assertTrue("Loaded a new class", fooClass != null);
 
-        Object bean = fooClass.newInstance();
+        Object bean = fooClass.getDeclaredConstructor().newInstance();
         assertTrue("Managed to create bean", bean != null);
 
         System.out.println("################ Now about to invoke method");
diff --git a/subprojects/groovy-jmx/src/test/java/groovy/util/MBeanTest.java b/subprojects/groovy-jmx/src/test/java/groovy/util/MBeanTest.java
index c71f017..017ae6e 100644
--- a/subprojects/groovy-jmx/src/test/java/groovy/util/MBeanTest.java
+++ b/subprojects/groovy-jmx/src/test/java/groovy/util/MBeanTest.java
@@ -35,7 +35,7 @@ public class MBeanTest extends GroovyTestCase {
         MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
         ObjectName name = new ObjectName("groovy.test:role=TestMBean,type=Dummy");
         // use Class.forName instead of new Dummy() to allow separate compilation
-        mbeanServer.registerMBean(Class.forName("groovy.util.Dummy").newInstance(), name);
+        mbeanServer.registerMBean(Class.forName("groovy.util.Dummy").getDeclaredConstructor().newInstance(), name);
 
         assertEquals("JMX value of Name", "James", mbeanServer.getAttribute(name, "Name"));
 
diff --git a/subprojects/groovy-servlet/src/main/java/groovy/servlet/TemplateServlet.java b/subprojects/groovy-servlet/src/main/java/groovy/servlet/TemplateServlet.java
index ba43617..d085d4a 100644
--- a/subprojects/groovy-servlet/src/main/java/groovy/servlet/TemplateServlet.java
+++ b/subprojects/groovy-servlet/src/main/java/groovy/servlet/TemplateServlet.java
@@ -33,6 +33,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.util.Date;
 import java.util.Map;
@@ -385,12 +386,12 @@ public class TemplateServlet extends AbstractHttpServlet {
             return new SimpleTemplateEngine();
         }
         try {
-            return (TemplateEngine) Class.forName(name).newInstance();
-        } catch (InstantiationException e) {
+            return (TemplateEngine) Class.forName(name).getDeclaredConstructor().newInstance();
+        } catch (InstantiationException | InvocationTargetException e) {
             log("Could not instantiate template engine: " + name, e);
         } catch (IllegalAccessException e) {
             log("Could not access template engine class: " + name, e);
-        } catch (ClassNotFoundException e) {
+        } catch (ClassNotFoundException | NoSuchMethodException e) {
             log("Could not find template engine class: " + name, e);
         }
         return null;
diff --git a/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/binding/PropertyBinding.java b/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/binding/PropertyBinding.java
index c577872..47149f5 100644
--- a/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/binding/PropertyBinding.java
+++ b/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/binding/PropertyBinding.java
@@ -155,8 +155,8 @@ public class PropertyBinding implements SourceBinding, TargetBinding, TriggerBin
         }
 
         try {
-            return accessorClass.newInstance();
-        } catch (InstantiationException | IllegalAccessException e) {
+            return accessorClass.getDeclaredConstructor().newInstance();
+        } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
             return DefaultPropertyAccessor.INSTANCE;
         }
     }
diff --git a/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java b/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
index 1b2fa8c..27c53de 100644
--- a/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
+++ b/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
@@ -30,6 +30,7 @@ import org.codehaus.groovy.control.CompilationFailedException;
 
 import java.io.IOException;
 import java.io.Reader;
+import java.lang.reflect.InvocationTargetException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Map;
@@ -202,14 +203,14 @@ public class GStringTemplateEngine extends TemplateEngine {
             }
 
             try {
-                final GroovyObject script = (GroovyObject) groovyClass.newInstance();
+                final GroovyObject script = (GroovyObject) groovyClass.getDeclaredConstructor().newInstance();
 
                 this.template = (Closure) script.invokeMethod("getTemplate", null);
                 // GROOVY-6521: must set strategy to DELEGATE_FIRST, otherwise writing
                 // books = 'foo' in a template would store 'books' in the binding of the template script itself ("script")
                 // instead of storing it in the delegate, which is a Binding too
                 this.template.setResolveStrategy(Closure.DELEGATE_FIRST);
-            } catch (InstantiationException | IllegalAccessException e) {
+            } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
                 throw new ClassNotFoundException(e.getMessage());
             }
         }
diff --git a/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java b/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
index 8be0abc..09b8b0c 100644
--- a/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
+++ b/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
@@ -36,6 +36,7 @@ import java.io.IOException;
 import java.io.LineNumberReader;
 import java.io.Reader;
 import java.io.StringReader;
+import java.lang.reflect.InvocationTargetException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -609,11 +610,11 @@ public class StreamingTemplateEngine extends TemplateEngine {
 
             Closure result;
             try {
-                final GroovyObject object = (GroovyObject) groovyClass.newInstance();
+                final GroovyObject object = (GroovyObject) groovyClass.getDeclaredConstructor().newInstance();
                 Closure chicken = (Closure) object.invokeMethod("getTemplate", null);
                 //bind the two first parameters of the generated closure to this class and the sections list
                 result = chicken.curry(this, sections);
-            } catch (InstantiationException | IllegalAccessException e) {
+            } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
                 throw new ClassNotFoundException(e.getMessage());
             }
 
diff --git a/subprojects/groovy-test/src/main/java/groovy/util/AllTestSuite.java b/subprojects/groovy-test/src/main/java/groovy/util/AllTestSuite.java
index fe06867..c926003 100644
--- a/subprojects/groovy-test/src/main/java/groovy/util/AllTestSuite.java
+++ b/subprojects/groovy-test/src/main/java/groovy/util/AllTestSuite.java
@@ -92,8 +92,7 @@ public class AllTestSuite extends TestSuite {
     static { // this is only needed since the Groovy Build compiles *.groovy files after *.java files
         try {
             // TODO: dk: make FileNameFinder injectable
-            Class finderClass = Class.forName("groovy.util.FileNameFinder");
-            finder = (IFileNameFinder) finderClass.newInstance();
+            finder = (IFileNameFinder) Class.forName("groovy.util.FileNameFinder").getDeclaredConstructor().newInstance();
         } catch (Exception e) {
             throw new RuntimeException("Cannot find and instantiate class FileNameFinder", e);
         }
diff --git a/subprojects/groovy-xml/src/main/java/groovy/xml/XmlUtil.java b/subprojects/groovy-xml/src/main/java/groovy/xml/XmlUtil.java
index 0594fd1..012769f 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/XmlUtil.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/XmlUtil.java
@@ -409,7 +409,7 @@ public class XmlUtil {
     private static String asString(GPathResult node) {
         // little bit of hackery to avoid Groovy dependency in this file
         try {
-            Object builder = ((Class) Class.forName("groovy.xml.StreamingMarkupBuilder")).newInstance();
+            Object builder = Class.forName("groovy.xml.StreamingMarkupBuilder").getDeclaredConstructor().newInstance();
             InvokerHelper.setProperty(builder, "encoding", "UTF-8");
             Writable w = (Writable) InvokerHelper.invokeMethod(builder, "bindNode", node);
             return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + w.toString();


[groovy] 02/02: minor refactor: avoid deprecated method usage

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit acb827fa9f7f36dfd895612e03759a336f266dce
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu May 9 17:28:21 2019 +1000

    minor refactor: avoid deprecated method usage
---
 src/test/groovy/lang/TupleTest.java | 126 ++++++++++++++++++------------------
 1 file changed, 64 insertions(+), 62 deletions(-)

diff --git a/src/test/groovy/lang/TupleTest.java b/src/test/groovy/lang/TupleTest.java
index 4fbef75..7cf0f7c 100644
--- a/src/test/groovy/lang/TupleTest.java
+++ b/src/test/groovy/lang/TupleTest.java
@@ -22,10 +22,12 @@ import junit.framework.TestCase;
 
 import java.util.List;
 
+import static org.junit.Assert.assertNotEquals;
+
 public class TupleTest extends TestCase {
 
-    final Object[] data = {"a", "b", "c"};
-    final Tuple t = new Tuple(data);
+    private final Object[] data = {"a", "b", "c"};
+    final Tuple t = new Tuple<Object>(data);
 
     public void testSize() {
         assertEquals("Size of " + t, 3, t.size());
@@ -59,25 +61,25 @@ public class TupleTest extends TestCase {
 
     public void testSubList() {
         List s = t.subList(1, 2);
-
         assertTrue("is a Tuple", s instanceof Tuple);
-
         assertEquals("size", 1, s.size());
     }
 
     public void testSubTuple() {
         Tuple s = t.subTuple(1, 2);
-
-        assertTrue("is a Tuple", s instanceof Tuple);
-
+        assertTrue("is a Tuple", isTuple(s));
         assertEquals("size", 1, s.size());
     }
 
+    private boolean isTuple(Object s) {
+        return s instanceof Tuple;
+    }
+
     public void testHashCodeAndEquals() {
-        Tuple a = new Tuple(new Object[]{"a", "b", "c"});
-        Tuple b = new Tuple(new Object[]{"a", "b", "c"});
-        Tuple c = new Tuple(new Object[]{"d", "b", "c"});
-        Tuple d = new Tuple(new Object[]{"a", "b"});
+        Tuple a = new Tuple<Object>("a", "b", "c");
+        Tuple b = new Tuple<Object>("a", "b", "c");
+        Tuple c = new Tuple<Object>("d", "b", "c");
+        Tuple d = new Tuple<Object>("a", "b");
         Tuple2<String, String> e = new Tuple2<String, String>("a", "b");
         Tuple2<String, String> f = new Tuple2<String, String>("a", "c");
 
@@ -85,14 +87,14 @@ public class TupleTest extends TestCase {
         assertTrue("hashcode", a.hashCode() != c.hashCode());
 
         assertEquals("a and b", a, b);
-        assertFalse("a != c", a.equals(c));
+        assertNotEquals("a != c", a, c);
 
-        assertFalse("!a.equals(null)", a.equals(null));
+        assertNotEquals("!a.equals(null)", null, a);
 
-        assertTrue("d.equals(e)", d.equals(e));
-        assertTrue("e.equals(d)", e.equals(d));
-        assertFalse("!e.equals(f)", e.equals(f));
-        assertFalse("!f.equals(e)", f.equals(e));
+        assertEquals("d.equals(e)", d, e);
+        assertEquals("e.equals(d)", e, d);
+        assertNotEquals("!e.equals(f)", e, f);
+        assertNotEquals("!f.equals(e)", f, e);
     }
 
     public void testIterator() {
@@ -103,7 +105,7 @@ public class TupleTest extends TestCase {
 
         assertEquals(1, t.size());
 
-        assertEquals(new Integer(1), t.getFirst());
+        assertEquals(Integer.valueOf(1), t.getFirst());
         assertEquals(1, t.get(0));
 
         assertEquals(t, t.subTuple(0, t.size()));
@@ -114,10 +116,10 @@ public class TupleTest extends TestCase {
 
         assertEquals(2, t.size());
 
-        assertEquals(new Integer(1), t.getFirst());
+        assertEquals(Integer.valueOf(1), t.getFirst());
         assertEquals(1, t.get(0));
 
-        assertEquals(new Integer(2), t.getSecond());
+        assertEquals(Integer.valueOf(2), t.getSecond());
         assertEquals(2, t.get(1));
 
         assertEquals(t, t.subTuple(0, t.size()));
@@ -128,13 +130,13 @@ public class TupleTest extends TestCase {
 
         assertEquals(3, t.size());
 
-        assertEquals(new Integer(1), t.getFirst());
+        assertEquals(Integer.valueOf(1), t.getFirst());
         assertEquals(1, t.get(0));
 
-        assertEquals(new Integer(2), t.getSecond());
+        assertEquals(Integer.valueOf(2), t.getSecond());
         assertEquals(2, t.get(1));
 
-        assertEquals(new Integer(3), t.getThird());
+        assertEquals(Integer.valueOf(3), t.getThird());
         assertEquals(3, t.get(2));
 
         assertEquals(t, t.subTuple(0, t.size()));
@@ -145,16 +147,16 @@ public class TupleTest extends TestCase {
 
         assertEquals(4, t.size());
 
-        assertEquals(new Integer(1), t.getFirst());
+        assertEquals(Integer.valueOf(1), t.getFirst());
         assertEquals(1, t.get(0));
 
-        assertEquals(new Integer(2), t.getSecond());
+        assertEquals(Integer.valueOf(2), t.getSecond());
         assertEquals(2, t.get(1));
 
-        assertEquals(new Integer(3), t.getThird());
+        assertEquals(Integer.valueOf(3), t.getThird());
         assertEquals(3, t.get(2));
 
-        assertEquals(new Integer(4), t.getFourth());
+        assertEquals(Integer.valueOf(4), t.getFourth());
         assertEquals(4, t.get(3));
 
         assertEquals(t, t.subTuple(0, t.size()));
@@ -165,19 +167,19 @@ public class TupleTest extends TestCase {
 
         assertEquals(5, t.size());
 
-        assertEquals(new Integer(1), t.getFirst());
+        assertEquals(Integer.valueOf(1), t.getFirst());
         assertEquals(1, t.get(0));
 
-        assertEquals(new Integer(2), t.getSecond());
+        assertEquals(Integer.valueOf(2), t.getSecond());
         assertEquals(2, t.get(1));
 
-        assertEquals(new Integer(3), t.getThird());
+        assertEquals(Integer.valueOf(3), t.getThird());
         assertEquals(3, t.get(2));
 
-        assertEquals(new Integer(4), t.getFourth());
+        assertEquals(Integer.valueOf(4), t.getFourth());
         assertEquals(4, t.get(3));
 
-        assertEquals(new Integer(5), t.getFifth());
+        assertEquals(Integer.valueOf(5), t.getFifth());
         assertEquals(5, t.get(4));
 
         assertEquals(t, t.subTuple(0, t.size()));
@@ -188,22 +190,22 @@ public class TupleTest extends TestCase {
 
         assertEquals(6, t.size());
 
-        assertEquals(new Integer(1), t.getFirst());
+        assertEquals(Integer.valueOf(1), t.getFirst());
         assertEquals(1, t.get(0));
 
-        assertEquals(new Integer(2), t.getSecond());
+        assertEquals(Integer.valueOf(2), t.getSecond());
         assertEquals(2, t.get(1));
 
-        assertEquals(new Integer(3), t.getThird());
+        assertEquals(Integer.valueOf(3), t.getThird());
         assertEquals(3, t.get(2));
 
-        assertEquals(new Integer(4), t.getFourth());
+        assertEquals(Integer.valueOf(4), t.getFourth());
         assertEquals(4, t.get(3));
 
-        assertEquals(new Integer(5), t.getFifth());
+        assertEquals(Integer.valueOf(5), t.getFifth());
         assertEquals(5, t.get(4));
 
-        assertEquals(new Integer(6), t.getSixth());
+        assertEquals(Integer.valueOf(6), t.getSixth());
         assertEquals(6, t.get(5));
 
         assertEquals(t, t.subTuple(0, t.size()));
@@ -214,25 +216,25 @@ public class TupleTest extends TestCase {
 
         assertEquals(7, t.size());
 
-        assertEquals(new Integer(1), t.getFirst());
+        assertEquals(Integer.valueOf(1), t.getFirst());
         assertEquals(1, t.get(0));
 
-        assertEquals(new Integer(2), t.getSecond());
+        assertEquals(Integer.valueOf(2), t.getSecond());
         assertEquals(2, t.get(1));
 
-        assertEquals(new Integer(3), t.getThird());
+        assertEquals(Integer.valueOf(3), t.getThird());
         assertEquals(3, t.get(2));
 
-        assertEquals(new Integer(4), t.getFourth());
+        assertEquals(Integer.valueOf(4), t.getFourth());
         assertEquals(4, t.get(3));
 
-        assertEquals(new Integer(5), t.getFifth());
+        assertEquals(Integer.valueOf(5), t.getFifth());
         assertEquals(5, t.get(4));
 
-        assertEquals(new Integer(6), t.getSixth());
+        assertEquals(Integer.valueOf(6), t.getSixth());
         assertEquals(6, t.get(5));
 
-        assertEquals(new Integer(7), t.getSeventh());
+        assertEquals(Integer.valueOf(7), t.getSeventh());
         assertEquals(7, t.get(6));
 
         assertEquals(t, t.subTuple(0, t.size()));
@@ -243,28 +245,28 @@ public class TupleTest extends TestCase {
 
         assertEquals(8, t.size());
 
-        assertEquals(new Integer(1), t.getFirst());
+        assertEquals(Integer.valueOf(1), t.getFirst());
         assertEquals(1, t.get(0));
 
-        assertEquals(new Integer(2), t.getSecond());
+        assertEquals(Integer.valueOf(2), t.getSecond());
         assertEquals(2, t.get(1));
 
-        assertEquals(new Integer(3), t.getThird());
+        assertEquals(Integer.valueOf(3), t.getThird());
         assertEquals(3, t.get(2));
 
-        assertEquals(new Integer(4), t.getFourth());
+        assertEquals(Integer.valueOf(4), t.getFourth());
         assertEquals(4, t.get(3));
 
-        assertEquals(new Integer(5), t.getFifth());
+        assertEquals(Integer.valueOf(5), t.getFifth());
         assertEquals(5, t.get(4));
 
-        assertEquals(new Integer(6), t.getSixth());
+        assertEquals(Integer.valueOf(6), t.getSixth());
         assertEquals(6, t.get(5));
 
-        assertEquals(new Integer(7), t.getSeventh());
+        assertEquals(Integer.valueOf(7), t.getSeventh());
         assertEquals(7, t.get(6));
 
-        assertEquals(new Integer(8), t.getEighth());
+        assertEquals(Integer.valueOf(8), t.getEighth());
         assertEquals(8, t.get(7));
 
         assertEquals(t, t.subTuple(0, t.size()));
@@ -275,31 +277,31 @@ public class TupleTest extends TestCase {
 
         assertEquals(9, t.size());
 
-        assertEquals(new Integer(1), t.getFirst());
+        assertEquals(Integer.valueOf(1), t.getFirst());
         assertEquals(1, t.get(0));
 
-        assertEquals(new Integer(2), t.getSecond());
+        assertEquals(Integer.valueOf(2), t.getSecond());
         assertEquals(2, t.get(1));
 
-        assertEquals(new Integer(3), t.getThird());
+        assertEquals(Integer.valueOf(3), t.getThird());
         assertEquals(3, t.get(2));
 
-        assertEquals(new Integer(4), t.getFourth());
+        assertEquals(Integer.valueOf(4), t.getFourth());
         assertEquals(4, t.get(3));
 
-        assertEquals(new Integer(5), t.getFifth());
+        assertEquals(Integer.valueOf(5), t.getFifth());
         assertEquals(5, t.get(4));
 
-        assertEquals(new Integer(6), t.getSixth());
+        assertEquals(Integer.valueOf(6), t.getSixth());
         assertEquals(6, t.get(5));
 
-        assertEquals(new Integer(7), t.getSeventh());
+        assertEquals(Integer.valueOf(7), t.getSeventh());
         assertEquals(7, t.get(6));
 
-        assertEquals(new Integer(8), t.getEighth());
+        assertEquals(Integer.valueOf(8), t.getEighth());
         assertEquals(8, t.get(7));
 
-        assertEquals(new Integer(9), t.getNinth());
+        assertEquals(Integer.valueOf(9), t.getNinth());
         assertEquals(9, t.get(8));
 
         assertEquals(t, t.subTuple(0, t.size()));