@@ -683,28 +683,28 @@ public void mergeAnnotations(boolean forSerialization)
683683 if (forSerialization ) {
684684 if (_getters != null ) {
685685 AnnotationMap ann = _mergeAnnotations (0 , _getters , _fields , _ctorParameters , _setters );
686- _getters = _getters . withValue (_getters . value . withAnnotations ( ann ) );
686+ _getters = _applyAnnotations (_getters , ann );
687687 } else if (_fields != null ) {
688688 AnnotationMap ann = _mergeAnnotations (0 , _fields , _ctorParameters , _setters );
689- _fields = _fields . withValue (_fields . value . withAnnotations ( ann ) );
689+ _fields = _applyAnnotations (_fields , ann );
690690 }
691691 } else { // for deserialization
692692 if (_ctorParameters != null ) {
693693 AnnotationMap ann = _mergeAnnotations (0 , _ctorParameters , _setters , _fields , _getters );
694- _ctorParameters = _ctorParameters . withValue (_ctorParameters . value . withAnnotations ( ann ) );
694+ _ctorParameters = _applyAnnotations (_ctorParameters , ann );
695695 } else if (_setters != null ) {
696696 AnnotationMap ann = _mergeAnnotations (0 , _setters , _fields , _getters );
697- _setters = _setters . withValue (_setters . value . withAnnotations ( ann ) );
697+ _setters = _applyAnnotations (_setters , ann );
698698 } else if (_fields != null ) {
699699 AnnotationMap ann = _mergeAnnotations (0 , _fields , _getters );
700- _fields = _fields . withValue (_fields . value . withAnnotations ( ann ) );
700+ _fields = _applyAnnotations (_fields , ann );
701701 }
702702 }
703703 }
704704
705705 private AnnotationMap _mergeAnnotations (int index , Linked <? extends AnnotatedMember >... nodes )
706706 {
707- AnnotationMap ann = nodes [index ]. value . getAllAnnotations ( );
707+ AnnotationMap ann = _getAllAnnotations ( nodes [index ]);
708708 ++index ;
709709 for (; index < nodes .length ; ++index ) {
710710 if (nodes [index ] != null ) {
@@ -713,7 +713,23 @@ private AnnotationMap _mergeAnnotations(int index, Linked<? extends AnnotatedMem
713713 }
714714 return ann ;
715715 }
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+
717733 private <T > Linked <T > _removeIgnored (Linked <T > node )
718734 {
719735 if (node == null ) {
@@ -1056,7 +1072,7 @@ public void remove() {
10561072 * Node used for creating simple linked lists to efficiently store small sets
10571073 * of things.
10581074 */
1059- private final static class Linked <T >
1075+ protected final static class Linked <T >
10601076 {
10611077 public final T value ;
10621078 public final Linked <T > next ;
0 commit comments