Skip to content

Provide 'with implementationType' overloads on ResolvableType [SPR-11218] #15843

@spring-projects-issues

Description

@spring-projects-issues

Bruce Brouwer opened SPR-11218 and commented

Add another method to ResolvableType with a signature something like this:

public static ResolvableType forField(Field field, 
    ResolvableType implementationType)

In this way I can use it to resolve a field where the field is a generic field and the implementingClass is generic.

public class MyType<T> {
  public T field;
}

This is roughly the code I would want to use:

ResolvableType type = ResolvableType.forClassWithGenerics(MyType.class, 
    ResolvableType.forClass(String.class));
Field f = MyType.class.getField("field");
ResolvableType field = ResolvableType.forField(f, type);
System.out.println(field); // I want it to print java.lang.String

If there is another, easier way to do this, I would love to hear what it is. I would possibly like to use this to replace a utility class that I wrote that does basically the same thing as ResolvableType.


Affects: 4.0 GA

Referenced from: commits 9076c70

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions