22
22
import java .lang .annotation .Target ;
23
23
import java .lang .reflect .Constructor ;
24
24
import java .lang .reflect .Method ;
25
+ import java .util .concurrent .Callable ;
25
26
26
27
import org .junit .Before ;
27
28
import org .junit .Test ;
@@ -96,7 +97,7 @@ public void annotatedConstructorParameterInStaticNestedClass() throws Exception
96
97
97
98
@ Test // SPR-16652
98
99
public void annotatedConstructorParameterInInnerClass () throws Exception {
99
- Constructor <?> constructor = InnerClass .class .getConstructor (getClass (), String .class , Integer .class );
100
+ Constructor <?> constructor = InnerClass .class .getConstructor (getClass (), String .class , Callable .class );
100
101
101
102
MethodParameter methodParameter = MethodParameter .forMethodOrConstructor (constructor , 0 );
102
103
assertEquals (getClass (), methodParameter .getParameterType ());
@@ -107,10 +108,28 @@ public void annotatedConstructorParameterInInnerClass() throws Exception {
107
108
assertNotNull ("Failed to find @Param annotation" , methodParameter .getParameterAnnotation (Param .class ));
108
109
109
110
methodParameter = MethodParameter .forMethodOrConstructor (constructor , 2 );
110
- assertEquals (Integer .class , methodParameter .getParameterType ());
111
+ assertEquals (Callable .class , methodParameter .getParameterType ());
111
112
assertNull (methodParameter .getParameterAnnotation (Param .class ));
112
113
}
113
114
115
+ @ Test // SPR-16734
116
+ public void genericConstructorParameterInInnerClass () throws Exception {
117
+ Constructor <?> constructor = InnerClass .class .getConstructor (getClass (), String .class , Callable .class );
118
+
119
+ MethodParameter methodParameter = MethodParameter .forMethodOrConstructor (constructor , 0 );
120
+ assertEquals (getClass (), methodParameter .getParameterType ());
121
+ assertEquals (getClass (), methodParameter .getGenericParameterType ());
122
+
123
+ methodParameter = MethodParameter .forMethodOrConstructor (constructor , 1 );
124
+ assertEquals (String .class , methodParameter .getParameterType ());
125
+ assertEquals (String .class , methodParameter .getGenericParameterType ());
126
+
127
+ methodParameter = MethodParameter .forMethodOrConstructor (constructor , 2 );
128
+ assertEquals (Callable .class , methodParameter .getParameterType ());
129
+ assertEquals (ResolvableType .forClassWithGenerics (Callable .class , Integer .class ).getType (),
130
+ methodParameter .getGenericParameterType ());
131
+ }
132
+
114
133
115
134
public int method (String p1 , long p2 ) {
116
135
return 42 ;
@@ -126,7 +145,7 @@ private static class NestedClass {
126
145
@ SuppressWarnings ("unused" )
127
146
private class InnerClass {
128
147
129
- public InnerClass (@ Param String s , Integer i ) {
148
+ public InnerClass (@ Param String s , Callable < Integer > i ) {
130
149
}
131
150
}
132
151
0 commit comments