668 } else |
668 } else |
669 return 0; |
669 return 0; |
670 } |
670 } |
671 |
671 |
672 |
672 |
|
673 private void writeParamAnnotations(List<VarSymbol> params, |
|
674 RetentionPolicy retention) { |
|
675 for (VarSymbol s : params) { |
|
676 ListBuffer<Attribute.Compound> buf = new ListBuffer<>(); |
|
677 for (Attribute.Compound a : s.getRawAttributes()) |
|
678 if (types.getRetention(a) == retention) |
|
679 buf.append(a); |
|
680 databuf.appendChar(buf.length()); |
|
681 for (Attribute.Compound a : buf) |
|
682 writeCompoundAttribute(a); |
|
683 } |
|
684 |
|
685 } |
|
686 |
|
687 private void writeParamAnnotations(MethodSymbol m, |
|
688 RetentionPolicy retention) { |
|
689 databuf.appendByte(m.params.length() + m.extraParams.length()); |
|
690 writeParamAnnotations(m.extraParams, retention); |
|
691 writeParamAnnotations(m.params, retention); |
|
692 } |
|
693 |
673 /** Write method parameter annotations; |
694 /** Write method parameter annotations; |
674 * return number of attributes written. |
695 * return number of attributes written. |
675 */ |
696 */ |
676 int writeParameterAttrs(MethodSymbol m) { |
697 int writeParameterAttrs(MethodSymbol m) { |
677 boolean hasVisible = false; |
698 boolean hasVisible = false; |
690 } |
711 } |
691 |
712 |
692 int attrCount = 0; |
713 int attrCount = 0; |
693 if (hasVisible) { |
714 if (hasVisible) { |
694 int attrIndex = writeAttr(names.RuntimeVisibleParameterAnnotations); |
715 int attrIndex = writeAttr(names.RuntimeVisibleParameterAnnotations); |
695 databuf.appendByte(m.params.length()); |
716 writeParamAnnotations(m, RetentionPolicy.RUNTIME); |
696 for (VarSymbol s : m.params) { |
|
697 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>(); |
|
698 for (Attribute.Compound a : s.getRawAttributes()) |
|
699 if (types.getRetention(a) == RetentionPolicy.RUNTIME) |
|
700 buf.append(a); |
|
701 databuf.appendChar(buf.length()); |
|
702 for (Attribute.Compound a : buf) |
|
703 writeCompoundAttribute(a); |
|
704 } |
|
705 endAttr(attrIndex); |
717 endAttr(attrIndex); |
706 attrCount++; |
718 attrCount++; |
707 } |
719 } |
708 if (hasInvisible) { |
720 if (hasInvisible) { |
709 int attrIndex = writeAttr(names.RuntimeInvisibleParameterAnnotations); |
721 int attrIndex = writeAttr(names.RuntimeInvisibleParameterAnnotations); |
710 databuf.appendByte(m.params.length()); |
722 writeParamAnnotations(m, RetentionPolicy.CLASS); |
711 for (VarSymbol s : m.params) { |
|
712 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>(); |
|
713 for (Attribute.Compound a : s.getRawAttributes()) |
|
714 if (types.getRetention(a) == RetentionPolicy.CLASS) |
|
715 buf.append(a); |
|
716 databuf.appendChar(buf.length()); |
|
717 for (Attribute.Compound a : buf) |
|
718 writeCompoundAttribute(a); |
|
719 } |
|
720 endAttr(attrIndex); |
723 endAttr(attrIndex); |
721 attrCount++; |
724 attrCount++; |
722 } |
725 } |
723 return attrCount; |
726 return attrCount; |
724 } |
727 } |