diff -r 9581e8765176 -r e1953d8b8338 rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeParser.java --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeParser.java Fri Jun 12 15:18:18 2015 +0200 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeParser.java Sat Mar 19 10:31:13 2016 +0100 @@ -78,6 +78,7 @@ public static final int ACC_STRICT = 0x00000800; public static final int ACC_EXPLICIT = 0x00001000; public static final int ACC_SYNTHETIC = 0x00010000; // actually, this is an attribute + private static final int ACC_ANNOTATION = 0x00020000; /* Type codes for StackMap attribute */ public static final int ITEM_Bogus =0; // an unknown or uninitialized value @@ -356,14 +357,22 @@ } protected void visitAttr( - String annoType, String attr, String attrType, String value) throws IOException { + String annoType, String attr, String attrType, String value + ) throws IOException { } protected void visitEnumAttr( - String annoType, String attr, String attrType, String value) throws IOException { + String annoType, String attr, String attrType, String value + ) throws IOException { visitAttr(annoType, attr, attrType, value); } + protected void visitClassAttr( + String annoType, String attr, String className + ) throws IOException { + visitAttr(annoType, attr, className, className); + } + /** * Initialize the parsing with constant pool from * cd. @@ -404,6 +413,16 @@ } } + public void parseDefault(byte[] defaultAttribute, ClassData cd) throws IOException { + ByteArrayInputStream is = new ByteArrayInputStream(defaultAttribute); + DataInputStream dis = new DataInputStream(is); + try { + readValue(dis, cd, null, null); + } finally { + is.close(); + } + } + private void readValue( DataInputStream dis, ClassData cd, String typeName, String attrName) throws IOException { char type = (char) dis.readByte(); @@ -425,6 +444,8 @@ visitAttr(typeName, attrName, attrType, val); } else if (type == 'c') { int cls = dis.readUnsignedShort(); + String attrType = cd.stringValue(cls, textual); + visitClassAttr(typeName, attrName, attrType); } else if (type == '[') { int cnt = dis.readUnsignedShort(); for (int i = 0; i < cnt; i++) { @@ -875,6 +896,10 @@ return false; } + public boolean isAnnotation() { + return (access & ACC_ANNOTATION) != 0; + } + /** * Returns true if this member is public, false otherwise. */ @@ -1687,6 +1712,7 @@ int max_stack, max_locals; boolean isSynthetic = false; boolean isDeprecated = false; + private AttrData annotationDefault; public MethodData(ClassData cls) { this.cls = cls; @@ -1737,6 +1763,12 @@ attr.read(attr_name_index); attrs.addElement(attr); break readAttr; + } else if (attr_name.equals("AnnotationDefault")) { + AttrData attr = new AttrData(cls); + attr.read(attr_name_index, in); + attrs.addElement(attr); + annotationDefault = attr; + break readAttr; } } AttrData attr = new AttrData(cls); @@ -1994,6 +2026,10 @@ return code_attrs; } + byte[] getDefaultAttribute() { + return annotationDefault == null ? null : annotationDefault.getData(); + } + /** * Return true if method id synthetic. */