89 /** Switch: read constant pool and code sections. This switch is initially |
89 /** Switch: read constant pool and code sections. This switch is initially |
90 * set to false but can be turned on from outside. |
90 * set to false but can be turned on from outside. |
91 */ |
91 */ |
92 public boolean readAllOfClassFile = false; |
92 public boolean readAllOfClassFile = false; |
93 |
93 |
94 /** Switch: read GJ signature information. |
|
95 */ |
|
96 boolean allowGenerics; |
|
97 |
|
98 /** Switch: read varargs attribute. |
|
99 */ |
|
100 boolean allowVarargs; |
|
101 |
|
102 /** Switch: allow annotations. |
|
103 */ |
|
104 boolean allowAnnotations; |
|
105 |
|
106 /** Switch: allow simplified varargs. |
94 /** Switch: allow simplified varargs. |
107 */ |
95 */ |
108 boolean allowSimplifiedVarargs; |
96 boolean allowSimplifiedVarargs; |
109 |
97 |
110 /** Lint option: warn about classfile issues |
98 /** Lint option: warn about classfile issues |
221 annotate = Annotate.instance(context); |
209 annotate = Annotate.instance(context); |
222 verbose = options.isSet(VERBOSE); |
210 verbose = options.isSet(VERBOSE); |
223 checkClassFile = options.isSet("-checkclassfile"); |
211 checkClassFile = options.isSet("-checkclassfile"); |
224 |
212 |
225 Source source = Source.instance(context); |
213 Source source = Source.instance(context); |
226 allowGenerics = source.allowGenerics(); |
|
227 allowVarargs = source.allowVarargs(); |
|
228 allowAnnotations = source.allowAnnotations(); |
|
229 allowSimplifiedVarargs = source.allowSimplifiedVarargs(); |
214 allowSimplifiedVarargs = source.allowSimplifiedVarargs(); |
230 |
215 |
231 saveParameterNames = options.isSet("save-parameter-names"); |
216 saveParameterNames = options.isSet("save-parameter-names"); |
232 |
217 |
233 profile = Profile.instance(context); |
218 profile = Profile.instance(context); |
1024 } |
1009 } |
1025 }, |
1010 }, |
1026 |
1011 |
1027 new AttributeReader(names.Synthetic, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { |
1012 new AttributeReader(names.Synthetic, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { |
1028 protected void read(Symbol sym, int attrLen) { |
1013 protected void read(Symbol sym, int attrLen) { |
1029 // bridge methods are visible when generics not enabled |
1014 sym.flags_field |= SYNTHETIC; |
1030 if (allowGenerics || (sym.flags_field & BRIDGE) == 0) |
|
1031 sym.flags_field |= SYNTHETIC; |
|
1032 } |
1015 } |
1033 }, |
1016 }, |
1034 |
1017 |
1035 // standard v49 attributes |
1018 // standard v49 attributes |
1036 |
1019 |
1041 bp = newbp; |
1024 bp = newbp; |
1042 } |
1025 } |
1043 }, |
1026 }, |
1044 |
1027 |
1045 new AttributeReader(names.Signature, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
1028 new AttributeReader(names.Signature, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
1046 @Override |
|
1047 protected boolean accepts(AttributeKind kind) { |
|
1048 return super.accepts(kind) && allowGenerics; |
|
1049 } |
|
1050 |
|
1051 protected void read(Symbol sym, int attrLen) { |
1029 protected void read(Symbol sym, int attrLen) { |
1052 if (sym.kind == TYP) { |
1030 if (sym.kind == TYP) { |
1053 ClassSymbol c = (ClassSymbol) sym; |
1031 ClassSymbol c = (ClassSymbol) sym; |
1054 readingClassAttr = true; |
1032 readingClassAttr = true; |
1055 try { |
1033 try { |
1108 |
1086 |
1109 // additional "legacy" v49 attributes, superceded by flags |
1087 // additional "legacy" v49 attributes, superceded by flags |
1110 |
1088 |
1111 new AttributeReader(names.Annotation, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
1089 new AttributeReader(names.Annotation, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
1112 protected void read(Symbol sym, int attrLen) { |
1090 protected void read(Symbol sym, int attrLen) { |
1113 if (allowAnnotations) |
1091 sym.flags_field |= ANNOTATION; |
1114 sym.flags_field |= ANNOTATION; |
|
1115 } |
1092 } |
1116 }, |
1093 }, |
1117 |
1094 |
1118 new AttributeReader(names.Bridge, V49, MEMBER_ATTRIBUTE) { |
1095 new AttributeReader(names.Bridge, V49, MEMBER_ATTRIBUTE) { |
1119 protected void read(Symbol sym, int attrLen) { |
1096 protected void read(Symbol sym, int attrLen) { |
1120 sym.flags_field |= BRIDGE; |
1097 sym.flags_field |= BRIDGE; |
1121 if (!allowGenerics) |
|
1122 sym.flags_field &= ~SYNTHETIC; |
|
1123 } |
1098 } |
1124 }, |
1099 }, |
1125 |
1100 |
1126 new AttributeReader(names.Enum, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
1101 new AttributeReader(names.Enum, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
1127 protected void read(Symbol sym, int attrLen) { |
1102 protected void read(Symbol sym, int attrLen) { |
1129 } |
1104 } |
1130 }, |
1105 }, |
1131 |
1106 |
1132 new AttributeReader(names.Varargs, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
1107 new AttributeReader(names.Varargs, V49, CLASS_OR_MEMBER_ATTRIBUTE) { |
1133 protected void read(Symbol sym, int attrLen) { |
1108 protected void read(Symbol sym, int attrLen) { |
1134 if (allowVarargs) |
1109 sym.flags_field |= VARARGS; |
1135 sym.flags_field |= VARARGS; |
|
1136 } |
1110 } |
1137 }, |
1111 }, |
1138 |
1112 |
1139 new AttributeReader(names.RuntimeVisibleTypeAnnotations, V52, CLASS_OR_MEMBER_ATTRIBUTE) { |
1113 new AttributeReader(names.RuntimeVisibleTypeAnnotations, V52, CLASS_OR_MEMBER_ATTRIBUTE) { |
1140 protected void read(Symbol sym, int attrLen) { |
1114 protected void read(Symbol sym, int attrLen) { |
2411 |
2385 |
2412 long adjustMethodFlags(long flags) { |
2386 long adjustMethodFlags(long flags) { |
2413 if ((flags & ACC_BRIDGE) != 0) { |
2387 if ((flags & ACC_BRIDGE) != 0) { |
2414 flags &= ~ACC_BRIDGE; |
2388 flags &= ~ACC_BRIDGE; |
2415 flags |= BRIDGE; |
2389 flags |= BRIDGE; |
2416 if (!allowGenerics) |
|
2417 flags &= ~SYNTHETIC; |
|
2418 } |
2390 } |
2419 if ((flags & ACC_VARARGS) != 0) { |
2391 if ((flags & ACC_VARARGS) != 0) { |
2420 flags &= ~ACC_VARARGS; |
2392 flags &= ~ACC_VARARGS; |
2421 flags |= VARARGS; |
2393 flags |= VARARGS; |
2422 } |
2394 } |