@@ -49,13 +49,21 @@ class MethodParameterTests {
49
49
50
50
private MethodParameter intReturnType ;
51
51
52
+ private MethodParameter jspecifyNullableParameter ;
53
+
54
+ private MethodParameter springNullableParameter ;
55
+
52
56
53
57
@ BeforeEach
54
58
void setup () throws NoSuchMethodException {
55
59
method = getClass ().getMethod ("method" , String .class , long .class );
56
60
stringParameter = new MethodParameter (method , 0 );
57
61
longParameter = new MethodParameter (method , 1 );
58
62
intReturnType = new MethodParameter (method , -1 );
63
+ Method jspecifyNullableMethod = getClass ().getMethod ("jspecifyNullableMethod" , String .class );
64
+ jspecifyNullableParameter = new MethodParameter (jspecifyNullableMethod , 0 );
65
+ Method springNullableMethod = getClass ().getMethod ("springNullableMethod" , String .class );
66
+ springNullableParameter = new MethodParameter (springNullableMethod , 0 );
59
67
}
60
68
61
69
@@ -238,21 +246,29 @@ void nestedWithTypeIndexReturnsNewInstance() throws Exception {
238
246
}
239
247
240
248
@ Test
241
- void nullableWithSpringAnnotation () {
242
- MethodParameter m = MethodParameter .forExecutable (method , 1 );
243
- assertThat (m .isOptional ()).isTrue ();
249
+ void jspecifyNullableParameter () {
250
+ assertThat (jspecifyNullableParameter .isOptional ()).isTrue ();
244
251
}
245
252
246
253
@ Test
247
- void nullableWithJSpecifyAnnotation () {
248
- MethodParameter m = MethodParameter .forExecutable (method , 0 );
249
- assertThat (m .isOptional ()).isTrue ();
254
+ void springNullableParameter () {
255
+ assertThat (springNullableParameter .isOptional ()).isTrue ();
250
256
}
251
257
252
- public int method (@ org . jspecify . annotations . Nullable String p1 , @ org . springframework . lang . Nullable long p2 ) {
258
+ public int method (String p1 , long p2 ) {
253
259
return 42 ;
254
260
}
255
261
262
+ public @ org .jspecify .annotations .Nullable String jspecifyNullableMethod (@ org .jspecify .annotations .Nullable String parameter ) {
263
+ return parameter ;
264
+ }
265
+
266
+ @ SuppressWarnings ("deprecation" )
267
+ @ org .springframework .lang .Nullable
268
+ public String springNullableMethod (@ org .springframework .lang .Nullable String parameter ) {
269
+ return parameter ;
270
+ }
271
+
256
272
@ SuppressWarnings ("unused" )
257
273
private static class NestedClass {
258
274
0 commit comments