@Test public void testGetExactReturnType() throws Exception { Method m = B.class.getDeclaredMethod("bar", Object.class); GenericMethod gm = new GenericMethod(m,B.class); Type res = gm.getExactReturnType(m, B.class); Assert.assertEquals(Object.class, res); }
protected Type getExactReturnType(Method m, Type type) throws IllegalArgumentException{ Inputs.checkNull(m,type); Type returnType = m.getGenericReturnType(); Type exactDeclaringType = null; try { exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); } catch(java.lang.TypeNotPresentException e) { } if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getReturnType(); } return mapTypeParameters(returnType, exactDeclaringType); }
GenericMethod extends GenericAccessibleObject<GenericMethod> { protected Type getExactReturnType(Method m, Type type) throws IllegalArgumentException{ Inputs.checkNull(m,type); Type returnType = m.getGenericReturnType(); Type exactDeclaringType = null; try { exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); } catch(java.lang.TypeNotPresentException e) { } if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getReturnType(); } return mapTypeParameters(returnType, exactDeclaringType); } }
GenericMethod extends GenericAccessibleObject<GenericMethod> { protected Type getExactReturnType(Method m, Type type) throws IllegalArgumentException{ Inputs.checkNull(m,type); Type returnType = m.getGenericReturnType(); Type exactDeclaringType = null; try { exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); } catch(java.lang.TypeNotPresentException e) { } if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getReturnType(); } return mapTypeParameters(returnType, exactDeclaringType); } GenericMethod(Method method, GenericClass type);  GenericMethod(Method method, Class<?> type);  GenericMethod(Method method, Type type); }
GenericMethod extends GenericAccessibleObject<GenericMethod> { protected Type getExactReturnType(Method m, Type type) throws IllegalArgumentException{ Inputs.checkNull(m,type); Type returnType = m.getGenericReturnType(); Type exactDeclaringType = null; try { exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); } catch(java.lang.TypeNotPresentException e) { } if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getReturnType(); } return mapTypeParameters(returnType, exactDeclaringType); } 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> { protected Type getExactReturnType(Method m, Type type) throws IllegalArgumentException{ Inputs.checkNull(m,type); Type returnType = m.getGenericReturnType(); Type exactDeclaringType = null; try { exactDeclaringType = GenericTypeReflector.getExactSuperType(GenericTypeReflector.capture(type), m.getDeclaringClass()); } catch(java.lang.TypeNotPresentException e) { } if (exactDeclaringType == null) { logger.info("The method " + m + " is not a member of type " + type + " - declared in " + m.getDeclaringClass()); return m.getReturnType(); } return mapTypeParameters(returnType, exactDeclaringType); } 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);  }