Skip to content

Subtype resolution with unknown generics #442

Closed Answered by CarstenWickner
kevin-yu-0602 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @kevin-yu-0602,

I'm unsure how to respond here, honestly.
This seems different to FasterXML/java-classmate#53, since the issue described there would occur for this:

class Dog extends Animal

with a superclass of

class Animal<T>

The lack of type parameter declaration is the issue there.


In your specific example, resolveSubtype is not technically required, but it is the safe way to go, in case you have this kind of setup:

class Dog<T> extends Animal<T>

and the member where the Subtype Resolver gets applied is something like this:

private Animal<Optional<Void>> field;

When you use typeContext.resolve(Dog.class) you interpret this as:

private Dog<?> field;

Using typeContext.resolveSubtype(…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@CarstenWickner
Comment options

Answer selected by kevin-yu-0602
Comment options

You must be logged in to vote
3 replies
@CarstenWickner
Comment options

@kevin-yu-0602
Comment options

@CarstenWickner
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants