* <code>RuntimeInvisibleAnnotations_attribute</code>.
*
* <p>To obtain an AnnotationAttribute object, invoke
- * <code>getAttribute(AnnotationsAttribute.invisibleTag)</code>
+ * <code>getAttribute(AnnotationsAttribute.visibleTag)</code>
* in <code>ClassFile</code>, <code>MethodInfo</code>,
* or <code>FieldInfo</code>. The obtained attribute is a
- * runtime invisible annotations attribute.
+ * runtime visible annotations attribute.
* If the parameter is
- * <code>AnnotationAttribute.visibleTag</code>, then the obtained
- * attribute is a runtime visible one.
+ * <code>AnnotationAttribute.invisibleTag</code>, then the obtained
+ * attribute is a runtime invisible one.
*
* <p>For example,
*
* CtMethod m = ... ;
* MethodInfo minfo = m.getMethodInfo();
* AnnotationsAttribute attr = (AnnotationsAttribute)
- * minfo.getAttribute(AnnotationsAttribute.invisibleTag);
+ * minfo.getAttribute(AnnotationsAttribute.visibleTag);
* Annotation an = attr.getAnnotation("Author");
* String s = ((StringMemberValue)a.getMemberValue("name")).getValue();
* System.out.println("@Author(name=" + s + ")");
* ClassFile cf = ... ;
* ConstPool cp = cf.getConstPool();
* AnnotationsAttribute attr
- * = new AnnotationsAttribute(cp, AnnotationsAttribute.invisibleTag);
+ * = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag);
* Annotation a = new Annotation("Author", cp);
* a.addMemberValue("name", new StringMemberValue("Chiba", cp));
* attr.setAnnotation(a);
* Constructs an empty LocalVariableTable.
*/
public LocalVariableAttribute(ConstPool cp) {
- super(cp, tag, new byte[2]);
+ this(cp, tag);
+ }
+
+ /**
+ * Constructs an empty LocalVariableTable.
+ *
+ * @param name the attribute name.
+ * <code>LocalVariableAttribute.tag</code> or
+ * <code>LocalVariableAttribute.typeTag</code>.
+ * @see #tag
+ * @see #typeTag
+ * @since 3.1
+ */
+ public LocalVariableAttribute(ConstPool cp, String name) {
+ super(cp, name, new byte[2]);
ByteArray.write16bit(0, info, 0);
}
super(cp, n, in);
}
- private LocalVariableAttribute(ConstPool cp, byte[] i) {
- super(cp, tag, i);
+ private LocalVariableAttribute(ConstPool cp, String name, byte[] i) {
+ super(cp, name, i);
}
/**
byte[] src = get();
byte[] dest = new byte[src.length];
ConstPool cp = getConstPool();
- LocalVariableAttribute attr = new LocalVariableAttribute(newCp, dest);
+ LocalVariableAttribute attr
+ = new LocalVariableAttribute(newCp, getName(), dest);
int n = ByteArray.readU16bit(src, 0);
ByteArray.write16bit(n, dest, 0);
int j = 2;