@Test public void testGetExactParameterTypes_staticMethod() throws Exception { Method m = A.class.getDeclaredMethod("bar", Object.class); GenericMethod gm = new GenericMethod(m,A.class); Type res = gm.getExactParameterTypes(m, A.class)[0]; Assert.assertNotNull(res); WildcardTypeImpl wt = (WildcardTypeImpl) res; Assert.assertEquals(0,wt.getLowerBounds().length); Assert.assertEquals(1,wt.getUpperBounds().length); Class<?> upper = (Class<?>) wt.getUpperBounds()[0]; Assert.assertEquals(Object.class,upper); }
public Type[] getExactParameterTypes(Method m, Type type) { Type[] parameterTypes = m.getGenericParameterTypes(); Type exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getParameterTypes(); } Type[] result = new Type[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { result[i] = mapTypeParameters(parameterTypes[i], exactDeclaringType); } return result; }
GenericMethod extends GenericAccessibleObject<GenericMethod> { public Type[] getExactParameterTypes(Method m, Type type) { Type[] parameterTypes = m.getGenericParameterTypes(); Type exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getParameterTypes(); } Type[] result = new Type[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { result[i] = mapTypeParameters(parameterTypes[i], exactDeclaringType); } return result; } }
GenericMethod extends GenericAccessibleObject<GenericMethod> { public Type[] getExactParameterTypes(Method m, Type type) { Type[] parameterTypes = m.getGenericParameterTypes(); Type exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getParameterTypes(); } Type[] result = new Type[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { result[i] = mapTypeParameters(parameterTypes[i], exactDeclaringType); } return result; } GenericMethod(Method method, GenericClass type);  GenericMethod(Method method, Class<?> type);  GenericMethod(Method method, Type type); }
GenericMethod extends GenericAccessibleObject<GenericMethod> { public Type[] getExactParameterTypes(Method m, Type type) { Type[] parameterTypes = m.getGenericParameterTypes(); Type exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getParameterTypes(); } Type[] result = new Type[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { result[i] = mapTypeParameters(parameterTypes[i], exactDeclaringType); } return result; } GenericMethod(Method method, GenericClass type);  GenericMethod(Method method, Class<?> type);  GenericMethod(Method method, Type type); @Override GenericMethod copyWithNewOwner(GenericClass newOwner); @Override GenericMethod copyWithOwnerFromReturnType(GenericClass returnType); @Override GenericMethod copy(); Method getMethod(); @Override AccessibleObject getAccessibleObject(); @Override Class<?> getDeclaringClass(); Type[] getParameterTypes(); List<GenericClass> getParameterClasses(); Type[] getGenericParameterTypes(); Class<?>[] getRawParameterTypes(); @Override Type getGeneratedType(); Type getReturnType(); @Override Type getGenericGeneratedType(); @Override Class<?> getRawGeneratedType(); Type[] getExactParameterTypes(Method m, Type type); @Override TypeVariable<?>[] getTypeParameters(); @Override boolean isAccessible(); @Override boolean isMethod(); boolean isAbstract(); @Override boolean isStatic(); boolean isOverloaded(); boolean isOverloaded(List<VariableReference> parameters); @Override int getNumParameters(); boolean isGenericMethod(); @Override String getName(); String getNameWithDescriptor(); String getDescriptor(); @Override String toString(); @Override void changeClassLoader(ClassLoader loader); @Override boolean isPublic(); @Override boolean isPrivate(); @Override boolean isProtected(); @Override boolean isDefault(); @Override int hashCode(); @Override boolean equals(Object obj); }
GenericMethod extends GenericAccessibleObject<GenericMethod> { public Type[] getExactParameterTypes(Method m, Type type) { Type[] parameterTypes = m.getGenericParameterTypes(); Type exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getParameterTypes(); } Type[] result = new Type[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { result[i] = mapTypeParameters(parameterTypes[i], exactDeclaringType); } return result; } GenericMethod(Method method, GenericClass type);  GenericMethod(Method method, Class<?> type);  GenericMethod(Method method, Type type); @Override GenericMethod copyWithNewOwner(GenericClass newOwner); @Override GenericMethod copyWithOwnerFromReturnType(GenericClass returnType); @Override GenericMethod copy(); Method getMethod(); @Override AccessibleObject getAccessibleObject(); @Override Class<?> getDeclaringClass(); Type[] getParameterTypes(); List<GenericClass> getParameterClasses(); Type[] getGenericParameterTypes(); Class<?>[] getRawParameterTypes(); @Override Type getGeneratedType(); Type getReturnType(); @Override Type getGenericGeneratedType(); @Override Class<?> getRawGeneratedType(); Type[] getExactParameterTypes(Method m, Type type); @Override TypeVariable<?>[] getTypeParameters(); @Override boolean isAccessible(); @Override boolean isMethod(); boolean isAbstract(); @Override boolean isStatic(); boolean isOverloaded(); boolean isOverloaded(List<VariableReference> parameters); @Override int getNumParameters(); boolean isGenericMethod(); @Override String getName(); String getNameWithDescriptor(); String getDescriptor(); @Override String toString(); @Override void changeClassLoader(ClassLoader loader); @Override boolean isPublic(); @Override boolean isPrivate(); @Override boolean isProtected(); @Override boolean isDefault(); @Override int hashCode(); @Override boolean equals(Object obj);  }