@@ -683,28 +683,28 @@ public void mergeAnnotations(boolean forSerialization)
683
683
if (forSerialization ) {
684
684
if (_getters != null ) {
685
685
AnnotationMap ann = _mergeAnnotations (0 , _getters , _fields , _ctorParameters , _setters );
686
- _getters = _getters . withValue (_getters . value . withAnnotations ( ann ) );
686
+ _getters = _applyAnnotations (_getters , ann );
687
687
} else if (_fields != null ) {
688
688
AnnotationMap ann = _mergeAnnotations (0 , _fields , _ctorParameters , _setters );
689
- _fields = _fields . withValue (_fields . value . withAnnotations ( ann ) );
689
+ _fields = _applyAnnotations (_fields , ann );
690
690
}
691
691
} else { // for deserialization
692
692
if (_ctorParameters != null ) {
693
693
AnnotationMap ann = _mergeAnnotations (0 , _ctorParameters , _setters , _fields , _getters );
694
- _ctorParameters = _ctorParameters . withValue (_ctorParameters . value . withAnnotations ( ann ) );
694
+ _ctorParameters = _applyAnnotations (_ctorParameters , ann );
695
695
} else if (_setters != null ) {
696
696
AnnotationMap ann = _mergeAnnotations (0 , _setters , _fields , _getters );
697
- _setters = _setters . withValue (_setters . value . withAnnotations ( ann ) );
697
+ _setters = _applyAnnotations (_setters , ann );
698
698
} else if (_fields != null ) {
699
699
AnnotationMap ann = _mergeAnnotations (0 , _fields , _getters );
700
- _fields = _fields . withValue (_fields . value . withAnnotations ( ann ) );
700
+ _fields = _applyAnnotations (_fields , ann );
701
701
}
702
702
}
703
703
}
704
704
705
705
private AnnotationMap _mergeAnnotations (int index , Linked <? extends AnnotatedMember >... nodes )
706
706
{
707
- AnnotationMap ann = nodes [index ]. value . getAllAnnotations ( );
707
+ AnnotationMap ann = _getAllAnnotations ( nodes [index ]);
708
708
++index ;
709
709
for (; index < nodes .length ; ++index ) {
710
710
if (nodes [index ] != null ) {
@@ -713,7 +713,23 @@ private AnnotationMap _mergeAnnotations(int index, Linked<? extends AnnotatedMem
713
713
}
714
714
return ann ;
715
715
}
716
-
716
+
717
+ private <T extends AnnotatedMember > AnnotationMap _getAllAnnotations (Linked <T > node ) {
718
+ AnnotationMap ann = node .value .getAllAnnotations ();
719
+ if (node .next != null ) {
720
+ ann = AnnotationMap .merge (ann , _getAllAnnotations (node .next ));
721
+ }
722
+ return ann ;
723
+ }
724
+
725
+ private <T extends AnnotatedMember > Linked <T > _applyAnnotations (Linked <T > node , AnnotationMap ann ) {
726
+ T value = (T ) node .value .withAnnotations (ann );
727
+ if (node .next != null ) {
728
+ node = node .withNext (_applyAnnotations (node .next , ann ));
729
+ }
730
+ return node .withValue (value );
731
+ }
732
+
717
733
private <T > Linked <T > _removeIgnored (Linked <T > node )
718
734
{
719
735
if (node == null ) {
@@ -1056,7 +1072,7 @@ public void remove() {
1056
1072
* Node used for creating simple linked lists to efficiently store small sets
1057
1073
* of things.
1058
1074
*/
1059
- private final static class Linked <T >
1075
+ protected final static class Linked <T >
1060
1076
{
1061
1077
public final T value ;
1062
1078
public final Linked <T > next ;
0 commit comments