+
+ public class Method extends Member {
+ final Type[] argTypes;
+ public final Type returnType;
+ public Type getArgType(int i) { return argTypes[i]; }
+ public int getNumArgs() { return argTypes.length; }
+ public Type getReturnType() { return returnType; }
+ public String debugToString() {
+ StringBuffer sb = new StringBuffer();
+ if (name.equals("<clinit>")) sb.append("static ");
+ else {
+ if (name.equals("<init>"))
+ sb.append(Class.this.getShortName());
+ else
+ sb.append(returnType).append(" ").append(name);
+ sb.append("(");
+ for(int i=0; i<argTypes.length; i++)
+ sb.append((i==0?"":", ")+argTypes[i].debugToString());
+ sb.append(") ");
+ }
+ return sb.toString();
+ }
+ private Method(String name, Type returnType, Type[] argTypes) {
+ super(name);
+ this.argTypes = argTypes;
+ this.returnType = returnType;
+ }
+ public String getDescriptor() {
+ StringBuffer sb = new StringBuffer(argTypes.length*4);
+ sb.append("(");
+ for(int i=0;i<argTypes.length;i++) sb.append(argTypes[i].getDescriptor());
+ sb.append(")");
+ sb.append(returnType.getDescriptor());
+ return sb.toString();
+ }
+ public abstract class Body implements HasFlags {
+ public abstract java.util.Hashtable getThrownExceptions();
+ public abstract void debugBodyToString(StringBuffer sb);
+ public void debugToString(StringBuffer sb, String constructorName) {
+ int flags = getFlags();
+ sb.append(" ").append(ClassFile.flagsToString(flags,false));
+ sb.append(Method.this.debugToString());
+ java.util.Hashtable thrownExceptions = getThrownExceptions();
+ if (thrownExceptions.size() > 0) {
+ sb.append("throws");
+ for(java.util.Enumeration e = thrownExceptions.keys();e.hasMoreElements();)
+ sb.append(" ").append(((Type.Class)e.nextElement()).debugToString()).append(",");
+ sb.setLength(sb.length()-1);
+ sb.append(" ");
+ }
+ if ((flags & (NATIVE|ABSTRACT))==0) {
+ sb.append("{\n");
+ debugBodyToString(sb);
+ sb.append(" }\n");
+ } else {
+ sb.append(";");
+ }
+ }
+ }
+ }
+ }
+
+ // FEATURE: This probably isn't the best place for these
+ static String methodTypeDescriptor(Type[] argTypes, Type returnType) {
+ StringBuffer sb = new StringBuffer(argTypes.length*4);
+ sb.append("(");
+ for(int i=0;i<argTypes.length;i++) sb.append(argTypes[i].getDescriptor());
+ sb.append(")");
+ sb.append(returnType.getDescriptor());
+ return sb.toString();