Is there a way to figure out which type will be returned by a method called from a generic class?
There is an example:
Generified<Integer, Double> generified = new Generified<Integer, Double>(); Method method = generified.getClass().getMethod("getDoubleValue"); Class<?> returnType = ........
Ok guys there is a class:
public class Generified<T, Z> { private T tValue; private Z doubleValue; private List<T> tValueList; public Generified() { } public T gettValue() { return tValue; } public void settValue(T tValue) { this.tValue = tValue; } public Z getDoubleValue() { return doubleValue; } public void setDoubleValue(Z doubleValue) { this.doubleValue = doubleValue; } public List<T> gettValueList() { return tValueList; } public void settValueList(List<T> tValueList) { this.tValueList = tValueList; } }
Update:
This is why I ask:
I am trying to make lib that can do simple clusters for collections. There is what I have now: github.README.md
But I have a lot of problems with return types from methods of generic classes. I need to know the actual return type in order to wrap it with CGLIB and add an interceptor for all methods for this return class in order to know the call hierarchy in the future.
But after a lot of debugging, I see that now there is a way to do what I want, and I want to cry :)
source share