-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[master] IndexOutOfBoundsException with generic superclass #58
Comments
Battled this for a day, can't see a really good out, due to shitty generics. In the meantime, I've managed to stop the exception by using the following code: private static Map<String, String> getTypeVariables(final String type) {
final Map<String, String> variables = new HashMap<>();
final List<String> actualTypeParameters = getTypeParameters(type);
final Class<?> loadedClass = loadClass(toClassName(type));
if (loadedClass == null) {
LogProvider.debug("could not load class for type " + type);
return Collections.emptyMap();
}
final TypeVariable<? extends Class<?>>[] typeParameters = loadedClass.getTypeParameters();
for (int i = 0; i < actualTypeParameters.size(); i++) {
variables.put(typeParameters[i].getName(), actualTypeParameters.get(i));
}
return variables;
} JavaTypeAnalyzer does not pass in a generic signature for superclass, so while there are expected parameters (such as T), the type information is simply not in the classname after erasure. I'll keep this in my local fixes for now. Let me know if you want a PR. |
@sdaschner just did another similar repro for this issue. |
Looked further into it and of course you were right. Changed that line but we should in general add more generic tests, maybe in the system test project... Thanks! |
Haven't really had the time to look into the system tests, sorry. Not really sure how it fits in with this repository (do I need to mvn install it and have mvn pick it up as a plugin or something?). Being able to run the tests in intellij while I'm developing is easier for me currently obviously.
Thanks! I'm flattered ;) |
The reason for the system test is that we don't want to loose any test scenarios in which we invested time. Running in the IDE is more productive, yes, but how about having some (temporary) tests in the IDE and then moving it to the system test project after fixing it -- as regression tests? The system test project takes the Analyzer from either Maven central (snapshot) or your local version in your Maven repository. So if you build a new JAX-RS Analyzer version via Hehe, well deserved :) |
Took me awhile to figure out what was happening. The type analyzer does not handle concrete subclasses of generic types. Not sure if this is fixable in its current state due to erasure but I'll give it another crack tomorrow.
Code fails to identify the generic return type of getData().
Use case:
The text was updated successfully, but these errors were encountered: