1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2011 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
26
26
import java .lang .reflect .TypeVariable ;
27
27
import java .util .HashMap ;
28
28
import java .util .Map ;
29
- import java .util .concurrent .ConcurrentHashMap ;
30
- import java .util .concurrent .ConcurrentMap ;
31
29
32
30
import org .springframework .util .Assert ;
33
31
39
37
* @author Juergen Hoeller
40
38
* @author Rob Harrop
41
39
* @author Andy Clement
42
- * @author Nikita Tovstoles
43
- * @author Chris Beams
44
40
* @since 2.0
45
41
* @see GenericCollectionTypeResolver
46
42
*/
47
43
public class MethodParameter {
48
44
49
-
50
- private static final Annotation [][] EMPTY_ANNOTATION_MATRIX = new Annotation [0 ][0 ];
51
-
52
- private static final Annotation [] EMPTY_ANNOTATION_ARRAY = new Annotation [0 ];
53
-
54
- static final ConcurrentMap <Method , Annotation [][]> methodParamAnnotationsCache =
55
- new ConcurrentHashMap <Method , Annotation [][]>();
56
-
57
45
private final Method method ;
58
46
59
47
private final Constructor constructor ;
@@ -291,7 +279,7 @@ public <T extends Annotation> T getMethodAnnotation(Class<T> annotationType) {
291
279
public Annotation [] getParameterAnnotations () {
292
280
if (this .parameterAnnotations == null ) {
293
281
Annotation [][] annotationArray = (this .method != null ?
294
- getMethodParameterAnnotations ( this .method ) : this .constructor .getParameterAnnotations ());
282
+ this .method . getParameterAnnotations ( ) : this .constructor .getParameterAnnotations ());
295
283
if (this .parameterIndex >= 0 && this .parameterIndex < annotationArray .length ) {
296
284
this .parameterAnnotations = annotationArray [this .parameterIndex ];
297
285
}
@@ -450,41 +438,6 @@ else if (methodOrConstructor instanceof Constructor) {
450
438
}
451
439
}
452
440
453
- /**
454
- * Return the parameter annotations for the given method, retrieving cached values
455
- * if a lookup has already been performed for this method, otherwise perform a fresh
456
- * lookup and populate the cache with the result before returning. <strong>For
457
- * internal use only.</strong>
458
- * @param method the method to introspect for parameter annotations
459
- */
460
- static Annotation [][] getMethodParameterAnnotations (Method method ) {
461
- Assert .notNull (method );
462
-
463
- Annotation [][] result = methodParamAnnotationsCache .get (method );
464
- if (result == null ) {
465
- result = method .getParameterAnnotations ();
466
-
467
- if (result .length == 0 ) {
468
- result = EMPTY_ANNOTATION_MATRIX ;
469
- }
470
- else {
471
- for (int i = 0 ; i < result .length ; i ++) {
472
- if (result [i ].length == 0 ) {
473
- result [i ] = EMPTY_ANNOTATION_ARRAY ;
474
- }
475
- }
476
- }
477
- methodParamAnnotationsCache .put (method , result );
478
- }
479
-
480
- //always return deep copy to prevent caller from modifying cache state
481
- Annotation [][] resultCopy = new Annotation [result .length ][0 ];
482
- for (int i = 0 ; i < result .length ; i ++) {
483
- resultCopy [i ] = result [i ].clone ();
484
- }
485
- return resultCopy ;
486
- }
487
-
488
441
@ Override
489
442
public boolean equals (Object obj ) {
490
443
if (this == obj ) {
@@ -506,6 +459,7 @@ else if (this.getMember().equals(other.getMember())) {
506
459
return false ;
507
460
}
508
461
462
+
509
463
@ Override
510
464
public int hashCode () {
511
465
int result = this .hash ;
0 commit comments