From f19b6003aee1f59e68fc685093721ca524f35e77 Mon Sep 17 00:00:00 2001 From: chiba Date: Tue, 18 Jul 2006 15:33:14 +0000 Subject: [PATCH] reformatted. git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@301 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- src/main/javassist/CtBehavior.java | 38 +++++++++----- src/main/javassist/CtClass.java | 11 +++-- src/main/javassist/CtClassType.java | 49 ++++++++++--------- src/main/javassist/CtField.java | 21 ++++---- src/main/javassist/CtMember.java | 15 +++--- .../bytecode/annotation/AnnotationImpl.java | 6 +-- 6 files changed, 78 insertions(+), 62 deletions(-) diff --git a/src/main/javassist/CtBehavior.java b/src/main/javassist/CtBehavior.java index 54ecddd4..9be97eba 100644 --- a/src/main/javassist/CtBehavior.java +++ b/src/main/javassist/CtBehavior.java @@ -139,7 +139,7 @@ public abstract class CtBehavior extends CtMember { * Returns the annotations associated with this method or constructor. * * @return an array of annotation-type objects. - * @see CtMember#getAnnotations() + * @see #getAvailableAnnotations() * @since 3.1 */ public Object[] getAnnotations() throws ClassNotFoundException { @@ -148,27 +148,32 @@ public abstract class CtBehavior extends CtMember { /** * Returns the annotations associated with this method or constructor. - * If any annotations are not on the classpath, they are not returned + * If any annotations are not on the classpath, they are not included + * in the returned array. * * @return an array of annotation-type objects. - * @see CtMember#getAnnotations() + * @see #getAnnotations() * @since 3.3 */ public Object[] getAvailableAnnotations(){ try{ return getAnnotations(true); - }catch (ClassNotFoundException e){ + } + catch (ClassNotFoundException e){ throw new RuntimeException("Unexpected exception", e); } } - private Object[] getAnnotations(boolean ignoreNotFound) throws ClassNotFoundException { + private Object[] getAnnotations(boolean ignoreNotFound) + throws ClassNotFoundException + { MethodInfo mi = getMethodInfo2(); AnnotationsAttribute ainfo = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.invisibleTag); AnnotationsAttribute ainfo2 = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.visibleTag); - return CtClassType.toAnnotationType(ignoreNotFound, getDeclaringClass().getClassPool(), + return CtClassType.toAnnotationType(ignoreNotFound, + getDeclaringClass().getClassPool(), ainfo, ainfo2); } @@ -179,7 +184,8 @@ public abstract class CtBehavior extends CtMember { * equal to the number of the formal parameters. If each parameter has no * annotation, the elements of the returned array are empty arrays. * - * @see CtMember#getAnnotations() + * @see #getAvailableParameterAnnotations() + * @see #getAnnotations() * @since 3.1 */ public Object[][] getParameterAnnotations() throws ClassNotFoundException { @@ -188,33 +194,39 @@ public abstract class CtBehavior extends CtMember { /** * Returns the parameter annotations associated with this method or constructor. - * If any annotations are not on the classpath, they are not returned + * If any annotations are not on the classpath, they are not included in the + * returned array. * * @return an array of annotation-type objects. The length of the returned array is * equal to the number of the formal parameters. If each parameter has no * annotation, the elements of the returned array are empty arrays. * - * @see CtMember#getAnnotations() + * @see #getParameterAnnotations() + * @see #getAvailableAnnotations() * @since 3.3 */ public Object[][] getAvailableParameterAnnotations(){ try { return getParameterAnnotations(true); - }catch(ClassNotFoundException e) { + } + catch(ClassNotFoundException e) { throw new RuntimeException("Unexpected exception", e); } } - Object[][] getParameterAnnotations(boolean ignoreNotFound) throws ClassNotFoundException { + Object[][] getParameterAnnotations(boolean ignoreNotFound) + throws ClassNotFoundException + { MethodInfo mi = getMethodInfo2(); ParameterAnnotationsAttribute ainfo = (ParameterAnnotationsAttribute) mi.getAttribute(ParameterAnnotationsAttribute.invisibleTag); ParameterAnnotationsAttribute ainfo2 = (ParameterAnnotationsAttribute) mi.getAttribute(ParameterAnnotationsAttribute.visibleTag); - return CtClassType.toAnnotationType(ignoreNotFound, getDeclaringClass().getClassPool(), + return CtClassType.toAnnotationType(ignoreNotFound, + getDeclaringClass().getClassPool(), ainfo, ainfo2, mi); } - + /** * Obtains parameter types of this method/constructor. */ diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java index a8261b37..3fb8860b 100644 --- a/src/main/javassist/CtClass.java +++ b/src/main/javassist/CtClass.java @@ -474,6 +474,7 @@ public abstract class CtClass { * the Author object. * * @return an array of annotation-type objects. + * @see CtMember#getAnnotations() * @since 3.1 */ public Object[] getAnnotations() throws ClassNotFoundException { @@ -482,13 +483,13 @@ public abstract class CtClass { /** * Returns the annotations associated with this class. - * For example, if an annotation @Author is associated - * with this class, the returned array contains an Author - * object. The member values can be obtained by calling methods on - * the Author object. If any annotations are not on the - * classpath, they are not returned + * This method is equivalent to getAnnotations() + * except that, if any annotations are not on the classpath, + * they are not included in the returned array. * * @return an array of annotation-type objects. + * @see #getAnnotations() + * @see CtMember#getAvailableAnnotations() * @since 3.3 */ public Object[] getAvailableAnnotations(){ diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java index bc059026..ab0d07ed 100644 --- a/src/main/javassist/CtClassType.java +++ b/src/main/javassist/CtClassType.java @@ -417,27 +417,29 @@ class CtClassType extends CtClass { } public Object[] getAvailableAnnotations(){ - try - { + try { return getAnnotations(true); } - catch (ClassNotFoundException e) - { + catch (ClassNotFoundException e) { throw new RuntimeException("Unexpected exception ", e); } } - private Object[] getAnnotations(boolean ignoreNotFound) throws ClassNotFoundException { - ClassFile cf = getClassFile2(); - AnnotationsAttribute ainfo = (AnnotationsAttribute) - cf.getAttribute(AnnotationsAttribute.invisibleTag); - AnnotationsAttribute ainfo2 = (AnnotationsAttribute) - cf.getAttribute(AnnotationsAttribute.visibleTag); - return toAnnotationType(ignoreNotFound, getClassPool(), ainfo, ainfo2); + private Object[] getAnnotations(boolean ignoreNotFound) + throws ClassNotFoundException + { + ClassFile cf = getClassFile2(); + AnnotationsAttribute ainfo = (AnnotationsAttribute) + cf.getAttribute(AnnotationsAttribute.invisibleTag); + AnnotationsAttribute ainfo2 = (AnnotationsAttribute) + cf.getAttribute(AnnotationsAttribute.visibleTag); + return toAnnotationType(ignoreNotFound, getClassPool(), ainfo, ainfo2); } - static Object[] toAnnotationType(boolean ignoreNotFound, ClassPool cp, AnnotationsAttribute a1, - AnnotationsAttribute a2) throws ClassNotFoundException { + static Object[] toAnnotationType(boolean ignoreNotFound, ClassPool cp, + AnnotationsAttribute a1, AnnotationsAttribute a2) + throws ClassNotFoundException + { Annotation[] anno1, anno2; int size1, size2; @@ -474,23 +476,24 @@ class CtClassType extends CtClass { for (int i = 0 ; i < size1 ; i++){ try{ annotations.add(toAnnoType(anno1[i], cp)); - }catch(ClassNotFoundException e){ } + catch(ClassNotFoundException e){} } - for (int j = 0; j < size2; j++) - { + for (int j = 0; j < size2; j++) { try{ annotations.add(toAnnoType(anno2[j], cp)); - }catch(ClassNotFoundException e){ } + catch(ClassNotFoundException e){} } - + return annotations.toArray(); } } - static Object[][] toAnnotationType(boolean ignoreNotFound, ClassPool cp, ParameterAnnotationsAttribute a1, - ParameterAnnotationsAttribute a2, MethodInfo minfo) + static Object[][] toAnnotationType(boolean ignoreNotFound, ClassPool cp, + ParameterAnnotationsAttribute a1, + ParameterAnnotationsAttribute a2, + MethodInfo minfo) throws ClassNotFoundException { int numParameters = 0; @@ -537,16 +540,16 @@ class CtClassType extends CtClass { for (int j = 0 ; j < size1 ; j++){ try{ annotations.add(toAnnoType(anno1[j], cp)); - }catch(ClassNotFoundException e){ } + catch(ClassNotFoundException e){} } for (int j = 0; j < size2; j++){ try{ annotations.add(toAnnoType(anno2[j], cp)); - }catch(ClassNotFoundException e){ } + catch(ClassNotFoundException e){} } - + result[i] = annotations.toArray(); } } diff --git a/src/main/javassist/CtField.java b/src/main/javassist/CtField.java index ea535290..30ea34e8 100644 --- a/src/main/javassist/CtField.java +++ b/src/main/javassist/CtField.java @@ -237,7 +237,7 @@ public class CtField extends CtMember { * Returns the annotations associated with this field. * * @return an array of annotation-type objects. - * @see CtMember#getAnnotations() + * @see #getAvailableAnnotations() * @since 3.1 */ public Object[] getAnnotations() throws ClassNotFoundException { @@ -246,23 +246,22 @@ public class CtField extends CtMember { /** * Returns the annotations associated with this field. - * If any annotations are not on the classpath, they are not returned + * If any annotations are not on the classpath, they are not included + * in the returned array. * * @return an array of annotation-type objects. - * @see CtMember#getAnnotations() + * @see #getAnnotations() * @since 3.3 */ public Object[] getAvailableAnnotations(){ - try - { - return getAnnotations(true); - } - catch (ClassNotFoundException e) - { + try { + return getAnnotations(true); + } + catch (ClassNotFoundException e) { throw new RuntimeException("Unexpected exception", e); - } + } } - + private Object[] getAnnotations(boolean ignoreNotFound) throws ClassNotFoundException { FieldInfo fi = getFieldInfo2(); AnnotationsAttribute ainfo = (AnnotationsAttribute) diff --git a/src/main/javassist/CtMember.java b/src/main/javassist/CtMember.java index 341521b8..cb944e62 100644 --- a/src/main/javassist/CtMember.java +++ b/src/main/javassist/CtMember.java @@ -158,16 +158,17 @@ public abstract class CtMember { /** * Returns the annotations associated with this member. - * For example, if an annotation @Author is associated - * with this member, the returned array contains an Author - * object. The member values can be obtained by calling methods on - * the Author object. - * If any annotations are not on the classpath, they are not returned + * This method is equivalent to getAnnotations() + * except that, if any annotations are not on the classpath, + * they are not included in the returned array. * * @return an array of annotation-type objects. - * @see CtClass#getAnnotations() + * @see #getAnnotations() + * @see CtClass#getAvailableAnnotations() + * @since 3.3 */ - public abstract Object[] getAvailableAnnotations() throws ClassNotFoundException; + public abstract Object[] getAvailableAnnotations() + throws ClassNotFoundException; /** diff --git a/src/main/javassist/bytecode/annotation/AnnotationImpl.java b/src/main/javassist/bytecode/annotation/AnnotationImpl.java index 9d8e49bc..005ab93e 100644 --- a/src/main/javassist/bytecode/annotation/AnnotationImpl.java +++ b/src/main/javassist/bytecode/annotation/AnnotationImpl.java @@ -63,9 +63,9 @@ public class AnnotationImpl implements InvocationHandler { /** * Executes a method invocation on a proxy instance. - * The implementations of toString, equals, - * and hashCode are directly supplied by the - * AnnotationImpl. The annotationType method + * The implementations of toString(), equals(), + * and hashCode() are directly supplied by the + * AnnotationImpl. The annotationType() method * is also available on the proxy instance. */ public Object invoke(Object proxy, Method method, Object[] args) -- 2.39.5