diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-02-02 16:14:34 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2005-02-02 16:14:34 +0000 |
commit | 16ecc51f8205e1cfb39d475a7ddddc820f78fff6 (patch) | |
tree | 4e972eaf7eaf0fcdac5cebeb81a128c78f01499f | |
parent | bd0d1580a7f9f92558eabe7b1fe9f49b259203e4 (diff) | |
download | javassist-16ecc51f8205e1cfb39d475a7ddddc820f78fff6.tar.gz javassist-16ecc51f8205e1cfb39d475a7ddddc820f78fff6.zip |
fixed a bug in LocalVariableAttribute
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@158 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r-- | src/main/javassist/CtClass.java | 2 | ||||
-rw-r--r-- | src/main/javassist/bytecode/AnnotationsAttribute.java | 12 | ||||
-rw-r--r-- | src/main/javassist/bytecode/LocalVariableAttribute.java | 23 |
3 files changed, 26 insertions, 11 deletions
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.*; * <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, * @@ -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. + * <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); } @@ -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; |