Hi!

When creating a MethodGen using the
  MethodGen(Method m, java.lang.String class_name, ConstantPoolGen cp) 
constructor, the getArgumentNames()  method always returns dummy names (arg0, 
arg1 ...).

I don't understand the comment in line 169, which may give a reason for not 
setting the argument names:
/* may be overridden anyway */

The following patch is not very nice, but seems to work (Probably adding 
methods getArgumentNames/Types to Method is a better approach?).

===================================================================
RCS file: 
/home/cvspublic/jakarta-bcel/src/java/org/apache/bcel/generic/MethodGen.java,v
retrieving revision 1.5
diff -u -r1.5 MethodGen.java
--- src/java/org/apache/bcel/generic/MethodGen.java     24 Apr 2002 08:11:30 
-0000      1.5
+++ src/java/org/apache/bcel/generic/MethodGen.java     3 Sep 2002 15:02:04 
-0000
@@ -247,6 +247,17 @@
       } else
        addAttribute(a);
     }
+
+    String[] argNames = new String[getArgumentTypes().length];
+    for (int i=0; i<argNames.length; i++) {
+        if (isStatic()) {
+            argNames[i] = getLocalVariables()[i].getName();
+        } else {
+            argNames[i] = getLocalVariables()[i + 1].getName();
+        }
+    }
+    setArgumentNames(argNames);
+
   }

   /**

Niklas

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to