From: chiba Date: Wed, 2 Feb 2005 16:14:34 +0000 (+0000) Subject: fixed a bug in LocalVariableAttribute X-Git-Tag: rel_3_17_1_ga~460 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=16ecc51f8205e1cfb39d475a7ddddc820f78fff6;p=javassist.git fixed a bug in LocalVariableAttribute git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@158 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java index 16fab666..2acd5776 100644 --- a/src/main/javassist/CtClass.java +++ b/src/main/javassist/CtClass.java @@ -44,7 +44,7 @@ public abstract class CtClass { /** * The version number of this release. */ - public static final String version = "3.0"; + public static final String version = "3.1"; /** * Prints the version number and the copyright notice. diff --git a/src/main/javassist/bytecode/AnnotationsAttribute.java b/src/main/javassist/bytecode/AnnotationsAttribute.java index 42ac8a59..34c82c4c 100644 --- a/src/main/javassist/bytecode/AnnotationsAttribute.java +++ b/src/main/javassist/bytecode/AnnotationsAttribute.java @@ -27,13 +27,13 @@ import javassist.bytecode.annotation.*; * RuntimeInvisibleAnnotations_attribute. * *

To obtain an AnnotationAttribute object, invoke - * getAttribute(AnnotationsAttribute.invisibleTag) + * getAttribute(AnnotationsAttribute.visibleTag) * in ClassFile, MethodInfo, * or FieldInfo. The obtained attribute is a - * runtime invisible annotations attribute. + * runtime visible annotations attribute. * If the parameter is - * AnnotationAttribute.visibleTag, then the obtained - * attribute is a runtime visible one. + * AnnotationAttribute.invisibleTag, then the obtained + * attribute is a runtime invisible one. * *

For example, * @@ -41,7 +41,7 @@ import javassist.bytecode.annotation.*; * 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 + ")"); @@ -58,7 +58,7 @@ import javassist.bytecode.annotation.*; * 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); diff --git a/src/main/javassist/bytecode/LocalVariableAttribute.java b/src/main/javassist/bytecode/LocalVariableAttribute.java index 6ccdd321..686fd8d1 100644 --- a/src/main/javassist/bytecode/LocalVariableAttribute.java +++ b/src/main/javassist/bytecode/LocalVariableAttribute.java @@ -38,7 +38,21 @@ public class LocalVariableAttribute extends AttributeInfo { * 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. + * LocalVariableAttribute.tag or + * LocalVariableAttribute.typeTag. + * @see #tag + * @see #typeTag + * @since 3.1 + */ + public LocalVariableAttribute(ConstPool cp, String name) { + super(cp, name, new byte[2]); ByteArray.write16bit(0, info, 0); } @@ -48,8 +62,8 @@ public class LocalVariableAttribute extends AttributeInfo { 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); } /** @@ -222,7 +236,8 @@ public class LocalVariableAttribute extends AttributeInfo { 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;