private byte[] op;
private Object[] arg;
- MethodGen(DataInput in) { throw new Error("Brian is lame"); }
+ public String toString() { StringBuffer sb = new StringBuffer(); toString(sb, "<init>"); return sb.toString(); }
+ public void toString(StringBuffer sb, String constructorName) {
+ sb.append(ClassGen.flagsToString(flags));
+ sb.append(ret);
+ sb.append(" ");
+
+ if (name.equals("<clinit>")) sb.append("static ");
+ else {
+ if (name.equals("<init>")) sb.append(constructorName);
+ else sb.append(name);
+ sb.append("(");
+ for(int i=0; i<args.length; i++)
+ sb.append((i==0?"":", ")+args[i]);
+ sb.append(") ");
+ }
+ sb.append("{");
+ sb.append("}");
+ // FIXME: attrs, body
+ }
+
+ MethodGen(CPGen cp, DataInput in) throws IOException {
+ this.cp = cp;
+ flags = in.readShort();
+ name = cp.getUtf8ByIndex(in.readShort());
+ String descriptor = cp.getUtf8ByIndex(in.readShort());
+ String ret = descriptor.substring(descriptor.indexOf(')')+1);
+ this.ret = Type.fromDescriptor(ret);
+ //String args = descriptor.substring(1, descriptor.indexOf(')'));
+ args = new Type[0]; // FIXME
+ codeAttrs = null;
+ attrs = new ClassGen.AttrGen(cp, in);
+ }
+
MethodGen(ClassGen owner, String name, Type ret, Type[] args, int flags) {
if((flags & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE|ACC_ABSTRACT|ACC_STRICT)) != 0)
throw new IllegalArgumentException("invalid flags");
@param handler The instruction of the excepton handler
@param type The type of exception that is to be handled (MUST inherit from Throwable)
*/
- public final void addExceptionHandler(int start, int end, int handler, Type.Object type) {
+ public final void addExceptionHandler(int start, int end, int handler, Type.Class type) {
exnTable.put(type, new ExnTableEnt(start, end, handler, cp.add(type)));
}
NOTE: This isn't enforced by the JVM. This is for reference only. A method can throw exceptions not declared to be thrown
@param type The type of exception that can be thrown
*/
- public final void addThrow(Type.Object type) {
+ public final void addThrow(Type.Class type) {
thrownExceptions.put(type, cp.add(type));
}