]> source.dussan.org Git - javassist.git/commitdiff
Adjusting indentation, adding javadoc comments, etc.
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 13 Feb 2006 16:38:05 +0000 (16:38 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 13 Feb 2006 16:38:05 +0000 (16:38 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@243 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/bytecode/EnclosingMethodAttribute.java
src/main/javassist/bytecode/annotation/AnnotationImpl.java

index 1efcb82ca1f4a4782d3171b3fb610a560c66c57c..cefbfebb5b26004b555e804d978b3ab3600c44db 100644 (file)
@@ -57,6 +57,7 @@ public class EnclosingMethodAttribute extends AttributeInfo {
 
     /**
      * Constructs an EnclosingMethod attribute.
+     * The value of <code>method_index</code> is set to 0.
      *
      * @param cp                a constant pool table.
      * @param className         the name of the innermost enclosing class.
@@ -125,7 +126,8 @@ public class EnclosingMethodAttribute extends AttributeInfo {
     public AttributeInfo copy(ConstPool newCp, Map classnames) {
         if (methodIndex() == 0) 
             return new EnclosingMethodAttribute(newCp, className());
-        return new EnclosingMethodAttribute(newCp, className(),
+        else
+            return new EnclosingMethodAttribute(newCp, className(),
                                             methodName(), methodDescriptor());
     }
 }
index 59f83e0d0c8cd6088fbbbd0bdd3cb7fe13223b2a..63d89f9cbcb1d0226b0b3cac47cdab58459cb4eb 100644 (file)
@@ -24,6 +24,10 @@ import javassist.bytecode.MethodInfo;
 
 import java.lang.reflect.*;
 
+/**
+ * Internal-use only.  This is a helper class internally used for implementing
+ * <code>toAnnotationType()</code> in <code>Annotation</code>.  
+ */
 public class AnnotationImpl implements InvocationHandler {
     private Annotation annotation;
     private ClassPool pool;
@@ -50,33 +54,38 @@ public class AnnotationImpl implements InvocationHandler {
         classLoader = loader;
     }
 
-    public String getTypeName()
-    {
-       return annotation.getTypeName();
+    /**
+     * Obtains the name of the annotation type.
+     */
+    public String getTypeName() {
+        return annotation.getTypeName();
     }
-    
+
+    /**
+     * Executes a method invocation on a proxy instance.
+     */
     public Object invoke(Object proxy, Method method, Object[] args)
         throws Throwable
     {
-       String name = method.getName();
-        if (Object.class == method.getDeclaringClass())
-        {
-           if ("equals".equals(name))
-           {
-              Object obj = args[0];
-              if (obj == null || obj instanceof Proxy == false)
-                 return Boolean.FALSE;
-              Object other = Proxy.getInvocationHandler(obj);
-              if (this.equals(other))
-                 return Boolean.TRUE;
-              else
-                 return Boolean.FALSE;
-           }
-           if ("toString".equals(name))
-              return annotation.getTypeName() + '@' + hashCode();
-           if ("hashCode".equals(name))
-              return new Integer(hashCode());
+        String name = method.getName();
+        if (Object.class == method.getDeclaringClass()) {
+            if ("equals".equals(name)) {
+                Object obj = args[0];
+                if (obj == null || obj instanceof Proxy == false)
+                    return Boolean.FALSE;
+
+                Object other = Proxy.getInvocationHandler(obj);
+                if (this.equals(other))
+                    return Boolean.TRUE;
+                else
+                    return Boolean.FALSE;
+            }
+            else if ("toString".equals(name))
+                return annotation.getTypeName() + '@' + hashCode();
+            else if ("hashCode".equals(name))
+                return new Integer(hashCode());
         }
+
         MemberValue mv = annotation.getMemberValue(name);
         if (mv == null)
             return getDefault(name, method);