|
50 | 50 | import static com.oracle.truffle.espresso.classfile.Constants.ACC_SUPER;
|
51 | 51 | import static com.oracle.truffle.espresso.classfile.Constants.ACC_SYNCHRONIZED;
|
52 | 52 | import static com.oracle.truffle.espresso.classfile.Constants.ACC_SYNTHETIC;
|
| 53 | +import static com.oracle.truffle.espresso.classfile.Constants.ACC_VALUE_BASED; |
53 | 54 | import static com.oracle.truffle.espresso.classfile.Constants.ACC_VARARGS;
|
54 | 55 | import static com.oracle.truffle.espresso.classfile.Constants.ACC_VOLATILE;
|
55 | 56 | import static com.oracle.truffle.espresso.classfile.Constants.JVM_RECOGNIZED_CLASS_MODIFIERS;
|
@@ -893,7 +894,7 @@ RuntimeVisibleAnnotationsAttribute parseRuntimeVisibleAnnotations(int attributeS
|
893 | 894 | flags = switch (location) {
|
894 | 895 | case Method -> parseMethodVMAnnotations(subStream);
|
895 | 896 | case Field -> parseFieldVMAnnotations(subStream);
|
896 |
| - case Class -> 0; |
| 897 | + case Class -> parseClassVMAnnotations(subStream); |
897 | 898 | };
|
898 | 899 | }
|
899 | 900 |
|
@@ -943,6 +944,20 @@ private int parseFieldVMAnnotations(ClassfileStream subStream) {
|
943 | 944 | }
|
944 | 945 | return flags;
|
945 | 946 | }
|
| 947 | + |
| 948 | + private int parseClassVMAnnotations(ClassfileStream subStream) { |
| 949 | + int flags = 0; |
| 950 | + int count = subStream.readU2(); |
| 951 | + for (int j = 0; j < count; j++) { |
| 952 | + int typeIndex = parseAnnotation(subStream); |
| 953 | + // Validation of the type is done at runtime by guest java code. |
| 954 | + Symbol<?> annotType = pool.utf8At(typeIndex, "annotation type"); |
| 955 | + if (ParserTypes.jdk_internal_ValueBased.equals(annotType)) { |
| 956 | + flags |= ACC_VALUE_BASED; |
| 957 | + } |
| 958 | + } |
| 959 | + return flags; |
| 960 | + } |
946 | 961 | }
|
947 | 962 |
|
948 | 963 | @SuppressWarnings("unchecked")
|
@@ -1248,6 +1263,10 @@ private Attribute[] parseClassAttributes() throws ValidationException {
|
1248 | 1263 | throw classFormatError("Duplicate PermittedSubclasses attribute");
|
1249 | 1264 | }
|
1250 | 1265 | classAttributes[i] = permittedSubclasses = parsePermittedSubclasses(attributeName);
|
| 1266 | + } else if (attributeName.equals(ParserNames.RuntimeVisibleAnnotations)) { |
| 1267 | + RuntimeVisibleAnnotationsAttribute annotations = commonAttributeParser.parseRuntimeVisibleAnnotations(attributeSize, AnnotationLocation.Class); |
| 1268 | + classFlags |= annotations.flags; |
| 1269 | + classAttributes[i] = annotations.attribute; |
1251 | 1270 | } else {
|
1252 | 1271 | Attribute attr = commonAttributeParser.parseCommonAttribute(attributeName, attributeSize);
|
1253 | 1272 | // stream.skip(attributeSize);
|
|
0 commit comments