1.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeParser.java Fri Jun 12 15:18:18 2015 +0200
1.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeParser.java Sat Mar 19 10:31:13 2016 +0100
1.3 @@ -78,6 +78,7 @@
1.4 public static final int ACC_STRICT = 0x00000800;
1.5 public static final int ACC_EXPLICIT = 0x00001000;
1.6 public static final int ACC_SYNTHETIC = 0x00010000; // actually, this is an attribute
1.7 + private static final int ACC_ANNOTATION = 0x00020000;
1.8
1.9 /* Type codes for StackMap attribute */
1.10 public static final int ITEM_Bogus =0; // an unknown or uninitialized value
1.11 @@ -356,14 +357,22 @@
1.12 }
1.13
1.14 protected void visitAttr(
1.15 - String annoType, String attr, String attrType, String value) throws IOException {
1.16 + String annoType, String attr, String attrType, String value
1.17 + ) throws IOException {
1.18 }
1.19
1.20 protected void visitEnumAttr(
1.21 - String annoType, String attr, String attrType, String value) throws IOException {
1.22 + String annoType, String attr, String attrType, String value
1.23 + ) throws IOException {
1.24 visitAttr(annoType, attr, attrType, value);
1.25 }
1.26
1.27 + protected void visitClassAttr(
1.28 + String annoType, String attr, String className
1.29 + ) throws IOException {
1.30 + visitAttr(annoType, attr, className, className);
1.31 + }
1.32 +
1.33 /**
1.34 * Initialize the parsing with constant pool from
1.35 * <code>cd</code>.
1.36 @@ -404,6 +413,16 @@
1.37 }
1.38 }
1.39
1.40 + public void parseDefault(byte[] defaultAttribute, ClassData cd) throws IOException {
1.41 + ByteArrayInputStream is = new ByteArrayInputStream(defaultAttribute);
1.42 + DataInputStream dis = new DataInputStream(is);
1.43 + try {
1.44 + readValue(dis, cd, null, null);
1.45 + } finally {
1.46 + is.close();
1.47 + }
1.48 + }
1.49 +
1.50 private void readValue(
1.51 DataInputStream dis, ClassData cd, String typeName, String attrName) throws IOException {
1.52 char type = (char) dis.readByte();
1.53 @@ -425,6 +444,8 @@
1.54 visitAttr(typeName, attrName, attrType, val);
1.55 } else if (type == 'c') {
1.56 int cls = dis.readUnsignedShort();
1.57 + String attrType = cd.stringValue(cls, textual);
1.58 + visitClassAttr(typeName, attrName, attrType);
1.59 } else if (type == '[') {
1.60 int cnt = dis.readUnsignedShort();
1.61 for (int i = 0; i < cnt; i++) {
1.62 @@ -875,6 +896,10 @@
1.63 return false;
1.64 }
1.65
1.66 + public boolean isAnnotation() {
1.67 + return (access & ACC_ANNOTATION) != 0;
1.68 + }
1.69 +
1.70 /**
1.71 * Returns true if this member is public, false otherwise.
1.72 */
1.73 @@ -1687,6 +1712,7 @@
1.74 int max_stack, max_locals;
1.75 boolean isSynthetic = false;
1.76 boolean isDeprecated = false;
1.77 + private AttrData annotationDefault;
1.78
1.79 public MethodData(ClassData cls) {
1.80 this.cls = cls;
1.81 @@ -1737,6 +1763,12 @@
1.82 attr.read(attr_name_index);
1.83 attrs.addElement(attr);
1.84 break readAttr;
1.85 + } else if (attr_name.equals("AnnotationDefault")) {
1.86 + AttrData attr = new AttrData(cls);
1.87 + attr.read(attr_name_index, in);
1.88 + attrs.addElement(attr);
1.89 + annotationDefault = attr;
1.90 + break readAttr;
1.91 }
1.92 }
1.93 AttrData attr = new AttrData(cls);
1.94 @@ -1994,6 +2026,10 @@
1.95 return code_attrs;
1.96 }
1.97
1.98 + byte[] getDefaultAttribute() {
1.99 + return annotationDefault == null ? null : annotationDefault.getData();
1.100 + }
1.101 +
1.102 /**
1.103 * Return true if method id synthetic.
1.104 */