475 public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, ClassOutputStream out) { |
476 public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, ClassOutputStream out) { |
476 annotationWriter.write(attr.annotations, out); |
477 annotationWriter.write(attr.annotations, out); |
477 return null; |
478 return null; |
478 } |
479 } |
479 |
480 |
|
481 public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, ClassOutputStream out) { |
|
482 annotationWriter.write(attr.annotations, out); |
|
483 return null; |
|
484 } |
|
485 |
|
486 public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, ClassOutputStream out) { |
|
487 annotationWriter.write(attr.annotations, out); |
|
488 return null; |
|
489 } |
|
490 |
480 public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, ClassOutputStream out) { |
491 public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, ClassOutputStream out) { |
481 out.writeByte(attr.parameter_annotations.length); |
492 out.writeByte(attr.parameter_annotations.length); |
482 for (Annotation[] annos: attr.parameter_annotations) |
493 for (Annotation[] annos: attr.parameter_annotations) |
483 annotationWriter.write(annos, out); |
494 annotationWriter.write(annos, out); |
484 return null; |
495 return null; |
634 out.writeShort(annos.length); |
645 out.writeShort(annos.length); |
635 for (Annotation anno: annos) |
646 for (Annotation anno: annos) |
636 write(anno, out); |
647 write(anno, out); |
637 } |
648 } |
638 |
649 |
|
650 public void write(ExtendedAnnotation[] annos, ClassOutputStream out) { |
|
651 out.writeShort(annos.length); |
|
652 for (ExtendedAnnotation anno: annos) |
|
653 write(anno, out); |
|
654 } |
|
655 |
639 public void write(Annotation anno, ClassOutputStream out) { |
656 public void write(Annotation anno, ClassOutputStream out) { |
640 out.writeShort(anno.type_index); |
657 out.writeShort(anno.type_index); |
641 out.writeShort(anno.element_value_pairs.length); |
658 out.writeShort(anno.element_value_pairs.length); |
642 for (element_value_pair p: anno.element_value_pairs) |
659 for (element_value_pair p: anno.element_value_pairs) |
643 write(p, out); |
660 write(p, out); |
644 } |
661 } |
645 |
662 |
|
663 public void write(ExtendedAnnotation anno, ClassOutputStream out) { |
|
664 write(anno.annotation, out); |
|
665 write(anno.position, out); |
|
666 } |
|
667 |
646 public void write(element_value_pair pair, ClassOutputStream out) { |
668 public void write(element_value_pair pair, ClassOutputStream out) { |
647 out.writeShort(pair.element_name_index); |
669 out.writeShort(pair.element_name_index); |
648 write(pair.value, out); |
670 write(pair.value, out); |
649 } |
671 } |
650 |
672 |
678 out.writeShort(ev.num_values); |
700 out.writeShort(ev.num_values); |
679 for (element_value v: ev.values) |
701 for (element_value v: ev.values) |
680 write(v, out); |
702 write(v, out); |
681 return null; |
703 return null; |
682 } |
704 } |
|
705 |
|
706 private void write(ExtendedAnnotation.Position p, ClassOutputStream out) { |
|
707 out.writeByte(p.type.targetTypeValue()); |
|
708 switch (p.type) { |
|
709 // type case |
|
710 case TYPECAST: |
|
711 case TYPECAST_GENERIC_OR_ARRAY: |
|
712 // object creation |
|
713 case INSTANCEOF: |
|
714 case INSTANCEOF_GENERIC_OR_ARRAY: |
|
715 // new expression |
|
716 case NEW: |
|
717 case NEW_GENERIC_OR_ARRAY: |
|
718 case NEW_TYPE_ARGUMENT: |
|
719 case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY: |
|
720 out.writeShort(p.offset); |
|
721 break; |
|
722 // local variable |
|
723 case LOCAL_VARIABLE: |
|
724 case LOCAL_VARIABLE_GENERIC_OR_ARRAY: |
|
725 int table_length = p.lvarOffset.length; |
|
726 out.writeShort(table_length); |
|
727 for (int i = 0; i < table_length; ++i) { |
|
728 out.writeShort(1); // for table length |
|
729 out.writeShort(p.lvarOffset[i]); |
|
730 out.writeShort(p.lvarLength[i]); |
|
731 out.writeShort(p.lvarIndex[i]); |
|
732 } |
|
733 break; |
|
734 // method receiver |
|
735 case METHOD_RECEIVER: |
|
736 // Do nothing |
|
737 break; |
|
738 // type parameters |
|
739 case CLASS_TYPE_PARAMETER: |
|
740 case METHOD_TYPE_PARAMETER: |
|
741 out.writeByte(p.parameter_index); |
|
742 break; |
|
743 // type parameters bounds |
|
744 case CLASS_TYPE_PARAMETER_BOUND: |
|
745 case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: |
|
746 case METHOD_TYPE_PARAMETER_BOUND: |
|
747 case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY: |
|
748 out.writeByte(p.parameter_index); |
|
749 out.writeByte(p.bound_index); |
|
750 break; |
|
751 // wildcards |
|
752 case WILDCARD_BOUND: |
|
753 case WILDCARD_BOUND_GENERIC_OR_ARRAY: |
|
754 write(p.wildcard_position, out); |
|
755 break; |
|
756 // Class extends and implements clauses |
|
757 case CLASS_EXTENDS: |
|
758 case CLASS_EXTENDS_GENERIC_OR_ARRAY: |
|
759 out.writeByte(p.type_index); |
|
760 break; |
|
761 // throws |
|
762 case THROWS: |
|
763 out.writeByte(p.type_index); |
|
764 break; |
|
765 case CLASS_LITERAL: |
|
766 out.writeShort(p.offset); |
|
767 break; |
|
768 // method parameter: not specified |
|
769 case METHOD_PARAMETER_GENERIC_OR_ARRAY: |
|
770 out.writeByte(p.parameter_index); |
|
771 break; |
|
772 // method type argument: wasn't specified |
|
773 case METHOD_TYPE_ARGUMENT: |
|
774 case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY: |
|
775 out.writeShort(p.offset); |
|
776 out.writeByte(p.type_index); |
|
777 break; |
|
778 // We don't need to worry abut these |
|
779 case METHOD_RETURN_GENERIC_OR_ARRAY: |
|
780 case FIELD_GENERIC_OR_ARRAY: |
|
781 break; |
|
782 case UNKNOWN: |
|
783 break; |
|
784 default: |
|
785 throw new AssertionError("unknown type: " + p); |
|
786 } |
|
787 |
|
788 // Append location data for generics/arrays. |
|
789 if (p.type.hasLocation()) { |
|
790 out.writeShort(p.location.size()); |
|
791 for (int i : p.location) |
|
792 out.writeByte((byte)i); |
|
793 } |
|
794 } |
683 } |
795 } |
684 } |
796 } |