equal
deleted
inserted
replaced
46 * If you write code that depends on this, you do so at your own risk. |
46 * If you write code that depends on this, you do so at your own risk. |
47 * This code and its internal interfaces are subject to change or |
47 * This code and its internal interfaces are subject to change or |
48 * deletion without notice.</b> |
48 * deletion without notice.</b> |
49 */ |
49 */ |
50 public class TypeAnnotationWriter extends InstructionDetailWriter { |
50 public class TypeAnnotationWriter extends InstructionDetailWriter { |
51 public enum NoteKind { VISIBLE, INVISIBLE }; |
51 public enum NoteKind { VISIBLE, INVISIBLE } |
|
52 |
52 public static class Note { |
53 public static class Note { |
53 Note(NoteKind kind, TypeAnnotation anno) { |
54 Note(NoteKind kind, TypeAnnotation anno) { |
54 this.kind = kind; |
55 this.kind = kind; |
55 this.anno = anno; |
56 this.anno = anno; |
56 } |
57 } |
72 classWriter = ClassWriter.instance(context); |
73 classWriter = ClassWriter.instance(context); |
73 } |
74 } |
74 |
75 |
75 public void reset(Code_attribute attr) { |
76 public void reset(Code_attribute attr) { |
76 Method m = classWriter.getMethod(); |
77 Method m = classWriter.getMethod(); |
77 pcMap = new HashMap<Integer, List<Note>>(); |
78 pcMap = new HashMap<>(); |
78 check(NoteKind.VISIBLE, (RuntimeVisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeVisibleTypeAnnotations)); |
79 check(NoteKind.VISIBLE, (RuntimeVisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeVisibleTypeAnnotations)); |
79 check(NoteKind.INVISIBLE, (RuntimeInvisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeInvisibleTypeAnnotations)); |
80 check(NoteKind.INVISIBLE, (RuntimeInvisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeInvisibleTypeAnnotations)); |
80 } |
81 } |
81 |
82 |
82 private void check(NoteKind kind, RuntimeTypeAnnotations_attribute attr) { |
83 private void check(NoteKind kind, RuntimeTypeAnnotations_attribute attr) { |
99 } |
100 } |
100 |
101 |
101 private void addNote(int pc, Note note) { |
102 private void addNote(int pc, Note note) { |
102 List<Note> list = pcMap.get(pc); |
103 List<Note> list = pcMap.get(pc); |
103 if (list == null) |
104 if (list == null) |
104 pcMap.put(pc, list = new ArrayList<Note>()); |
105 pcMap.put(pc, list = new ArrayList<>()); |
105 list.add(note); |
106 list.add(note); |
106 } |
107 } |
107 |
108 |
108 @Override |
109 @Override |
109 void writeDetails(Instruction instr) { |
110 void writeDetails(Instruction instr) { |