From bd0d1580a7f9f92558eabe7b1fe9f49b259203e4 Mon Sep 17 00:00:00 2001 From: chiba Date: Mon, 31 Jan 2005 14:09:56 +0000 Subject: [PATCH] Added javadoc comments. git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@157 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- src/main/javassist/CtMember.java | 4 ++-- .../bytecode/AnnotationsAttribute.java | 19 +++++++++++++++++++ .../annotation/MemberValueVisitor.java | 3 +-- tutorial/tutorial2.html | 7 +++++++ tutorial/tutorial3.html | 2 +- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/main/javassist/CtMember.java b/src/main/javassist/CtMember.java index 8b2906db..ee8aadbc 100644 --- a/src/main/javassist/CtMember.java +++ b/src/main/javassist/CtMember.java @@ -120,7 +120,7 @@ public abstract class CtMember { public abstract String getName(); /** - * Obtains an attribute with the given name. + * Obtains a user-defined attribute with the given name. * If that attribute is not found in the class file, this * method returns null. * @@ -129,7 +129,7 @@ public abstract class CtMember { public abstract byte[] getAttribute(String name); /** - * Adds an attribute. The attribute is saved in the class file. + * Adds a user-defined attribute. The attribute is saved in the class file. * * @param name attribute name * @param data attribute value diff --git a/src/main/javassist/bytecode/AnnotationsAttribute.java b/src/main/javassist/bytecode/AnnotationsAttribute.java index a9fda536..42ac8a59 100644 --- a/src/main/javassist/bytecode/AnnotationsAttribute.java +++ b/src/main/javassist/bytecode/AnnotationsAttribute.java @@ -35,6 +35,22 @@ import javassist.bytecode.annotation.*; * AnnotationAttribute.visibleTag, then the obtained * attribute is a runtime visible one. * + *

For example, + * + *

+ * + *

This code snippet retrieves an annotation of the type Author + * from the MethodInfo object specified by minfo. + * Then, it prints the value of name in Author. + * *

If you want to record a new AnnotationAttribute object, execute the * following snippet: * @@ -48,6 +64,8 @@ import javassist.bytecode.annotation.*; * attr.setAnnotation(a); * cf.addAttribute(attr); * + * + * @see javassist.bytecode.annotation.Annotation */ public class AnnotationsAttribute extends AttributeInfo { /** @@ -125,6 +143,7 @@ public class AnnotationsAttribute extends AttributeInfo { * getAnnotations() as to the returned data structure. * * @param type the annotation type. + * @return null if the specified annotation type is not included. * @see #getAnnotations() */ public Annotation getAnnotation(String type) { diff --git a/src/main/javassist/bytecode/annotation/MemberValueVisitor.java b/src/main/javassist/bytecode/annotation/MemberValueVisitor.java index d302e9bb..55aabb8f 100644 --- a/src/main/javassist/bytecode/annotation/MemberValueVisitor.java +++ b/src/main/javassist/bytecode/annotation/MemberValueVisitor.java @@ -20,8 +20,7 @@ package javassist.bytecode.annotation; * * @author Bill Burke */ -public interface MemberValueVisitor -{ +public interface MemberValueVisitor { public void visitAnnotationMemberValue(AnnotationMemberValue node); public void visitArrayMemberValue(ArrayMemberValue node); public void visitBooleanMemberValue(BooleanMemberValue node); diff --git a/tutorial/tutorial2.html b/tutorial/tutorial2.html index 63d75ce0..abac129a 100644 --- a/tutorial/tutorial2.html +++ b/tutorial/tutorial2.html @@ -1368,6 +1368,13 @@ CtField f = CtField.make("public int z = 0;", point); point.addField(f); +

Removing a member

+ +

To remove a field or a method, call removeField() +or removeMethod() in CtClass. A +CtConstructor can be removed by removeConstructor() +in CtClass. +


diff --git a/tutorial/tutorial3.html b/tutorial/tutorial3.html index af0a4c1b..635e01b6 100644 --- a/tutorial/tutorial3.html +++ b/tutorial/tutorial3.html @@ -84,7 +84,7 @@ In other words, a FieldInfo (or MethodInfo etc.) objec must not be shared among different ClassFile objects.

-To remove a field or a method, +To remove a field or a method from a ClassFile object, you must first obtain a java.util.List object containing all the fields of the class. getFields() and getMethods() return the lists. A field or a method can -- 2.39.5