Open AndreasTu opened 5 months ago
This problem can be simplified to a single self-referential type.
import java.lang.reflect.Method;
import java.util.Objects;
public class StackOverflowReproducer {
static abstract class Resource<StatusT> {
}
static class ProjectValidator {
public <T extends Resource<T>>
void validate(long id, Class<T> klass) {
throw new UnsupportedOperationException("Just for testing");
}
}
public static void main(String[] args) throws NoSuchMethodException {
Class<?> cls = ProjectValidator.class;
Method method = Objects.requireNonNull(cls.getMethod("validate", long.class, Class.class));
io.leangen.geantyref.GenericTypeReflector.getParameterTypes(method, cls);
}
}
This can probably be avoided by tracking already seen AnnotatedTypeVariable
s in io.leangen.geantyref.VarMap#map(java.lang.reflect.AnnotatedType, io.leangen.geantyref.VarMap.MappingMode)
. However, I'm unsure what the correct return type would be in this case, maybe just Resource
without any generic information? Or, do we need to throw an UnresolvedTypeVariableException
.
@leonard84 The VarMap.MappingMode.EXACT
mode does already throw an UnresolvedTypeVariableException
in that case, so only the VarMap.MappingMode.ALLOW_INCOMPLETE
case is left, where I would say we shall just return the imcomplete type.
I have created the PR #30, which fixes the issue but returning the incomplete type.
mfriedenhagen reported an issue in Spock https://github.com/spockframework/spock/issues/1909 where geantyref throws a
StackOverflowError
.I have removed the Spock dependency from the reproducer attached to the Spock issue, and the error is still there:
The exception stack looks like:
The used geantyref version is
io.leangen.geantyref:geantyref:1.3.15
Tested for Java8
and17