Skip to content

Commit

Permalink
Remove redundant Parameter implementation
Browse files Browse the repository at this point in the history
Found a redundant implementation of Parameter 
with a comment on the class stating that this 
class can be removed from the codebase after JDK8.

Stumbled into it just now and so getting rid of it.
  • Loading branch information
krmahadevan committed Jan 7, 2022
1 parent 24cbb56 commit 03ca3d0
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Parameter;
import java.util.*;
import javax.annotation.Nullable;
import org.testng.DataProviderHolder;
Expand Down Expand Up @@ -36,7 +37,6 @@
import org.testng.internal.reflect.InjectableParameter;
import org.testng.internal.reflect.MethodMatcher;
import org.testng.internal.reflect.MethodMatcherContext;
import org.testng.internal.reflect.Parameter;
import org.testng.internal.reflect.ReflectionRecipes;
import org.testng.util.Strings;
import org.testng.xml.XmlSuite;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.testng.internal.reflect;

import java.lang.reflect.Parameter;
import java.util.List;
import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.testng.internal.reflect.InjectableParameter.Assistant.ALL_INJECTS;

import java.lang.reflect.Array;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.testng.internal.reflect.InjectableParameter.Assistant.ALL_INJECTS;
import static org.testng.internal.reflect.InjectableParameter.Assistant.NONE;

import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.testng.internal.reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import org.testng.ITestContext;
import org.testng.ITestResult;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Arrays;
import org.testng.TestNGException;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.testng.internal.reflect;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.*;
import org.testng.ITestContext;
import org.testng.ITestResult;
Expand Down Expand Up @@ -151,7 +151,7 @@ public static Parameter[] getMethodParameters(final Method method) {
if (method == null) {
return new Parameter[] {};
}
return getParameters(method.getParameterTypes(), method.getParameterAnnotations());
return method.getParameters();
}

/**
Expand All @@ -164,16 +164,7 @@ public static Parameter[] getConstructorParameters(final Constructor<?> construc
if (constructor == null) {
return new Parameter[] {};
}
return getParameters(constructor.getParameterTypes(), constructor.getParameterAnnotations());
}

private static Parameter[] getParameters(
Class<?>[] parametersTypes, final Annotation[][] parametersAnnotations) {
final Parameter[] parameters = new Parameter[parametersTypes.length];
for (int i = 0; i < parametersTypes.length; i++) {
parameters[i] = new Parameter(i, parametersTypes[i], parametersAnnotations[i]);
}
return parameters;
return constructor.getParameters();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.lang.annotation.Target;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -19,7 +20,6 @@
import org.testng.annotations.NoInjection;
import org.testng.annotations.Test;
import org.testng.internal.reflect.InjectableParameter;
import org.testng.internal.reflect.Parameter;
import org.testng.internal.reflect.ReflectionRecipes;
import org.testng.log4testng.Logger;
import org.testng.xml.XmlTest;
Expand Down

0 comments on commit 03ca3d0

Please sign in to comment.