/*
#!/usr/bin/perl -w
-@ARGV || push @ARGV,$0;
+@ARGV || push @ARGV, $0;
my @a = ();
while(<>) {
chomp;
next unless(m|byte ([A-Z0-9_]+) = .*?([0-9xA-F]+);\s+//\s*(.*)$|i);
- my ($name,$num) = ($1,hex($2));
+ my ($name, $num) = ($1, hex($2));
$_ = $3;
my $n = 1<<5;
- $n |= s/^(\d+)// ? $1 : (s/^V//||die,7);
+ $n |= s/^(\d+)// ? $1 : (s/^V//||die, 7);
$n |= (1<<4) if(s/^C//);
$n |= (1<<3) if(s/^B//);
die if(/./);
}
print "private static final byte[] OP_DATA = {\n\t";
for(my $i=0;$i<256;$i++) {
- printf "0x%02x%s", $a[$i]||1, $i==255?"\n};\n":($i%16)==15?",\n\t":", ";
+ printf "0x%02x%s", $a[$i]||1, $i==255?"\n};\n":($i%16)==15?", \n\t":", ";
}
__END__
*/
// INVARIANTS: tag == 3 || tag == 4
static class IntEnt extends Ent {
int i;
- IntEnt(CPGen owner, int tag) { super(owner,tag); }
+ IntEnt(CPGen owner, int tag) { super(owner, tag); }
void dump(DataOutput o) throws IOException { super.dump(o); o.writeInt(i); }
Object key() {
switch(tag) {
// INVARIANTS: tag == 5 || tag == 6
static class LongEnt extends Ent {
long l;
- LongEnt(CPGen owner, int tag) { super(owner,tag); }
+ LongEnt(CPGen owner, int tag) { super(owner, tag); }
void dump(DataOutput o) throws IOException { super.dump(o); o.writeLong(l); }
Object key() {
switch(tag) {
static class CPRefEnt extends Ent {
Ent e1;
Ent e2;
- CPRefEnt(CPGen owner, int tag) { super(owner,tag); }
+ CPRefEnt(CPGen owner, int tag) { super(owner, tag); }
String debugToString() { return "[" + e1.n + ":" + e1.debugToString() + (e2 == null ? "" : " + " + e2.n + ":" + e2.debugToString()) + "]"; }
static class Utf8Ent extends Ent {
String s;
- Utf8Ent(CPGen owner) { super(owner,1); }
+ Utf8Ent(CPGen owner) { super(owner, 1); }
String debugToString() { return s; }
void dump(DataOutput o) throws IOException { super.dump(o); o.writeUTF(s); }
Object key() { throw new Error("Brian is lame"); }
return e;
}
- public final Ent addNameAndType(String name, String descriptor) { return add(new NameAndTypeKey(name,descriptor)); }
+ public final Ent addNameAndType(String name, String descriptor) { return add(new NameAndTypeKey(name, descriptor)); }
public final Ent addUtf8(String s) { return add(new Utf8Key(s)); }
public final Ent add(Object o) {
}
if(o instanceof Type.Object) {
- CPRefEnt ce = new CPRefEnt(this,7);
+ CPRefEnt ce = new CPRefEnt(this, 7);
ce.e1 = addUtf8(((Type.Object)o).internalForm());
ent = ce;
} else if(o instanceof String) {
- CPRefEnt ce = new CPRefEnt(this,8);
+ CPRefEnt ce = new CPRefEnt(this, 8);
ce.e1 = addUtf8((String)o);
ent = ce;
} else if(o instanceof Integer) {
- IntEnt ue = new IntEnt(this,3);
+ IntEnt ue = new IntEnt(this, 3);
ue.i = ((Integer)o).intValue();
ent = ue;
} else if(o instanceof Float) {
- IntEnt ue = new IntEnt(this,4);
+ IntEnt ue = new IntEnt(this, 4);
ue.i = Float.floatToIntBits(((Float)o).floatValue());
ent = ue;
} else if(o instanceof Long) {
- LongEnt le = new LongEnt(this,5);
+ LongEnt le = new LongEnt(this, 5);
le.l = ((Long)o).longValue();
ent = le;
} else if(o instanceof Double) {
- LongEnt le = new LongEnt(this,6);
+ LongEnt le = new LongEnt(this, 6);
le.l = Double.doubleToLongBits(((Double)o).doubleValue());
ent = le;
} else if(o instanceof Utf8Key) {
ue.s = ((Utf8Key)o).s;
ent = ue;
} else if(o instanceof NameAndTypeKey) {
- CPRefEnt ce = new CPRefEnt(this,12);
+ CPRefEnt ce = new CPRefEnt(this, 12);
NameAndTypeKey key = (NameAndTypeKey) o;
ce.e1 = addUtf8(key.name);
ce.e2 = addUtf8(key.type);
ClassGen.FieldOrMethodRef key = (ClassGen.FieldOrMethodRef) o;
int tag = o instanceof FieldRef ? 9 : o instanceof MethodRef ? 10 : o instanceof MethodRef.I ? 11 : 0;
if(tag == 0) throw new Error("should never happen");
- CPRefEnt ce = new CPRefEnt(this,tag);
+ CPRefEnt ce = new CPRefEnt(this, tag);
ce.e1 = add(key.klass);
- ce.e2 = addNameAndType(key.name,key.descriptor);
+ ce.e2 = addNameAndType(key.name, key.descriptor);
ent = ce;
} else {
throw new IllegalArgumentException("Unknown type passed to add");
usedSlots += spaces;
- entries.put(o,ent);
+ entries.put(o, ent);
return ent;
}
public void optimize() {
if(state != OPEN) throw new IllegalStateException("can't optimize a stable constant pool");
Ent[] ents = asArray();
- Sort.sort(ents,reverseCompareFunc);
+ Sort.sort(ents, reverseCompareFunc);
state = STABLE;
assignIndex(ents);
}
public void dump(DataOutput o) throws IOException {
Ent[] ents = asArray();
- Sort.sort(ents,compareFunc);
+ Sort.sort(ents, compareFunc);
o.writeShort(usedSlots);
for(int i=0;i<ents.length;i++) {
//System.err.println("" + ents[i].n + ": " + ents[i].debugToString());
case 11: // Instance Method Ref
case 12: // NameAndType
{
- e = new CPRefEnt(this,tag);
+ e = new CPRefEnt(this, tag);
e1s[index] = in.readUnsignedShort();;
if(tag != 7 && tag != 8) e2s[index] = in.readUnsignedShort();
break;
case 4: // Float
{
IntEnt ie;
- e = ie = new IntEnt(this,tag);
+ e = ie = new IntEnt(this, tag);
ie.i = in.readInt();
break;
}
case 6: // Double
{
LongEnt le;
- e = le = new LongEnt(this,tag);
+ e = le = new LongEnt(this, tag);
le.l = in.readLong();
index++;
break;
} else if(e instanceof LongEnt) {
index++;
}
- entries.put(e.key(),e);
+ entries.put(e.key(), e);
}
state = STABLE;
}
final CPGen cp;
private final AttrGen attributes;
- /** @see #ClassGen(Type.Object,Type.Object,int) */
+ /** @see #ClassGen(Type.Object, Type.Object, int) */
public ClassGen(String name, String superName, int flags) {
this(Type.fromDescriptor(name).asObject(), Type.fromDescriptor(superName).asObject(), flags);
}
- /** @see #ClassGen(Type.Object,Type.Object,int,Type.Object[]) */
- public ClassGen(Type.Object thisType,Type.Object superType, int flags) {
- this(thisType,superType,flags,null);
+ /** @see #ClassGen(Type.Object, Type.Object, int, Type.Object[]) */
+ public ClassGen(Type.Object thisType, Type.Object superType, int flags) {
+ this(thisType, superType, flags, null);
}
/** Creates a new ClassGen object
@param superType The superclass of the generated class (commonly Type.OBJECT)
@param flags The access flags for this class (ACC_PUBLIC, ACC_FINAL, ACC_SUPER, ACC_INTERFACE, and ACC_ABSTRACT)
*/
- public ClassGen(Type.Object thisType,Type.Object superType, int flags, Type.Object[] interfaces) {
+ public ClassGen(Type.Object thisType, Type.Object superType, int flags, Type.Object[] interfaces) {
if((flags & ~(ACC_PUBLIC|ACC_FINAL|ACC_SUPER|ACC_INTERFACE|ACC_ABSTRACT)) != 0)
throw new IllegalArgumentException("invalid flags");
this.thisType = thisType;
@see CGConst
*/
public final MethodGen addMethod(String name, Type ret, Type[] args, int flags) {
- MethodGen mg = new MethodGen(this,name,ret,args,flags);
+ MethodGen mg = new MethodGen(this, name, ret, args, flags);
methods.addElement(mg);
return mg;
}
@see CGConst
*/
public final FieldGen addField(String name, Type type, int flags) {
- FieldGen fg = new FieldGen(this,name,type,flags);
+ FieldGen fg = new FieldGen(this, name, type, flags);
fields.addElement(fg);
return fg;
}
String[] a = thisType.components();
int i;
for(i=0;i<a.length-1;i++) {
- f = new File(f,a[i]);
+ f = new File(f, a[i]);
f.mkdir();
}
- f = new File(f,a[i] + ".class");
+ f = new File(f, a[i] + ".class");
}
OutputStream os = new FileOutputStream(f);
dump(os);
cp.add(thisType);
cp.add(superType);
if(interfaces != null) for(int i=0;i<interfaces.length;i++) cp.add(interfaces[i]);
- if(sourceFile != null && !attributes.contains("SourceFile")) attributes.add("SourceFile",cp.addUtf8(sourceFile));
+ if(sourceFile != null && !attributes.contains("SourceFile")) attributes.add("SourceFile", cp.addUtf8(sourceFile));
for(int i=0;i<methods.size();i++) ((MethodGen)methods.elementAt(i)).finish();
for(int i=0;i<fields.size();i++) ((FieldGen)fields.elementAt(i)).finish();
public void add(String s, Object data) {
cp.addUtf8(s);
- ht.put(s,data);
+ ht.put(s, data);
}
public boolean contains(String s) { return ht.get(s) != null; }
/*public static void main(String[] args) throws Exception {
Type.Object me = new Type.Object("Test");
- ClassGen cg = new ClassGen("Test","java.lang.Object",ACC_PUBLIC|ACC_SUPER|ACC_FINAL);
- FieldGen fg = cg.addField("foo",Type.INT,ACC_PUBLIC|ACC_STATIC);
+ ClassGen cg = new ClassGen("Test", "java.lang.Object", ACC_PUBLIC|ACC_SUPER|ACC_FINAL);
+ FieldGen fg = cg.addField("foo", Type.INT, ACC_PUBLIC|ACC_STATIC);
- MethodGen mg = cg.addMethod("main",Type.VOID,new Type[]{Type.arrayType(Type.STRING)},ACC_STATIC|ACC_PUBLIC);
+ MethodGen mg = cg.addMethod("main", Type.VOID, new Type[]{Type.arrayType(Type.STRING)}, ACC_STATIC|ACC_PUBLIC);
mg.setMaxLocals(1);
mg.addPushConst(0);
//mg.add(ISTORE_0);
- mg.add(PUTSTATIC, fieldRef(me,"foo",Type.INT));
+ mg.add(PUTSTATIC, fieldRef(me, "foo", Type.INT));
int top = mg.size();
- mg.add(GETSTATIC,cg.fieldRef(new Type.Object("java.lang.System"),"out",new Type.Object("java.io.PrintStream")));
+ mg.add(GETSTATIC, cg.fieldRef(new Type.Object("java.lang.System"), "out", new Type.Object("java.io.PrintStream")));
//mg.add(ILOAD_0);
- mg.add(GETSTATIC,cg.fieldRef(me,"foo",Type.INT));
- mg.add(INVOKEVIRTUAL,cg.methodRef(new Type.Object("java.io.PrintStream"),"println",Type.VOID, new Type[]{Type.INT}));
- //mg.add(IINC,new int[]{0,1});
+ mg.add(GETSTATIC, cg.fieldRef(me, "foo", Type.INT));
+ mg.add(INVOKEVIRTUAL, cg.methodRef(new Type.Object("java.io.PrintStream"), "println", Type.VOID, new Type[]{Type.INT}));
+ //mg.add(IINC, new int[]{0, 1});
//mg.add(ILOAD_0);
- mg.add(GETSTATIC,cg.fieldRef(me,"foo",Type.INT));
+ mg.add(GETSTATIC, cg.fieldRef(me, "foo", Type.INT));
mg.addPushConst(1);
mg.add(IADD);
mg.add(DUP);
- mg.add(PUTSTATIC,cg.fieldRef(me,"foo",Type.INT));
+ mg.add(PUTSTATIC, cg.fieldRef(me, "foo", Type.INT));
mg.addPushConst(10);
- mg.add(IF_ICMPLT,top);
+ mg.add(IF_ICMPLT, top);
mg.add(RETURN);
cg.dump("Test.class");
}*/
private Object constantValue;
FieldGen(DataInput in) { throw new Error("Brian is lame"); }
- FieldGen(ClassGen owner, String name,Type type, int flags) {
+ FieldGen(ClassGen owner, String name, Type type, int flags) {
if((flags & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_VOLATILE|ACC_TRANSIENT|ACC_STATIC|ACC_FINAL)) != 0)
throw new IllegalArgumentException("invalid flags");
this.cp = owner.cp;
void finish() {
if(constantValue != null && !attrs.contains("ConstantValue"))
- attrs.add("ConstantValue",cp.add(constantValue));
+ attrs.add("ConstantValue", cp.add(constantValue));
}
void dump(DataOutput o) throws IOException {
*/
public class FieldRef extends ClassGen.FieldOrMethodRef {
/** Create a reference to field <i>name</i> of class <i>c</i> with the type <i>t</i> */
- public FieldRef(Type.Object c, String name, Type t) { super(c,name,t.getDescriptor()); }
- /** Equivalent to FieldRef(new Type.Object(s),...)
- @see #FieldRef(Type.Object,String,Type,)
+ public FieldRef(Type.Object c, String name, Type t) { super(c, name, t.getDescriptor()); }
+ /** Equivalent to FieldRef(new Type.Object(s), ...)
+ @see #FieldRef(Type.Object, String, Type, )
*/
public FieldRef(String s, String name, Type t) { this(Type.fromDescriptor(s).asObject(), name, t); }
}
if((owner.flags & ACC_INTERFACE) != 0 || (flags & (ACC_ABSTRACT|ACC_NATIVE)) != 0) size = capacity = -1;
- maxLocals = Math.max(args.length + (flags&ACC_STATIC)==0 ? 1 : 0,4);
+ maxLocals = Math.max(args.length + (flags&ACC_STATIC)==0 ? 1 : 0, 4);
}
/** Returns the descriptor string for this method */
- public String getDescriptor() { return MethodRef.getDescriptor(ret,args); }
+ public String getDescriptor() { return MethodRef.getDescriptor(ret, args); }
private class ExnTableEnt {
public int start;
}
}
- /** Adds an exception handler for the range [<i>start</i>,<i>end</i>) pointing to <i>handler</i>
+ /** Adds an exception handler for the range [<i>start</i>, <i>end</i>) pointing to <i>handler</i>
@param start The instruction to start at (inclusive)
@param end The instruction to end at (exclusive)
@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) {
- exnTable.put(type, new ExnTableEnt(start,end,handler,cp.add(type)));
+ exnTable.put(type, new ExnTableEnt(start, end, handler, cp.add(type)));
}
/** Adds a exception type that can be thrown from this method
@param type The type of exception that can be thrown
*/
public final void addThrow(Type.Object type) {
- thrownExceptions.put(type,cp.add(type));
+ thrownExceptions.put(type, cp.add(type));
}
private final void grow() { if(size == capacity) grow(size+1); }
if(capacity == NO_CODE) throw new IllegalStateException("method can't have code");
if(capacity == FINISHED) throw new IllegalStateException("method has been finished");
if(newCap <= capacity) return;
- newCap = Math.max(newCap,capacity == 0 ? 256 : capacity*2);
+ newCap = Math.max(newCap, capacity == 0 ? 256 : capacity*2);
byte[] op2 = new byte[newCap];
- if(capacity != 0) System.arraycopy(op,0,op2,0,size);
+ if(capacity != 0) System.arraycopy(op, 0, op2, 0, size);
op = op2;
Object[] arg2 = new Object[newCap];
- if(capacity != 0) System.arraycopy(arg,0,arg2,0,size);
+ if(capacity != 0) System.arraycopy(arg, 0, arg2, 0, size);
arg = arg2;
capacity = newCap;
/** Adds a bytecode, <i>op</i>, with argument <i>arg</i> to the method
@return The position of the new bytecode
*/
- public final int add(byte op, Object arg) { if(capacity == size) grow(); set(size,op,arg); return size++; }
- /** Adds a bytecode with a boolean argument - equivalent to add(op,arg?1:0);
+ public final int add(byte op, Object arg) { if(capacity == size) grow(); set(size, op, arg); return size++; }
+ /** Adds a bytecode with a boolean argument - equivalent to add(op, arg?1:0);
@return The position of the new bytecode
- @see #add(byte,int)
+ @see #add(byte, int)
*/
- public final int add(byte op, boolean arg) { if(capacity == size) grow(); set(size,op,arg); return size++; }
- /** Adds a bytecode with an integer argument. This is equivalent to add(op,new Integer(arg)), but optimized to prevent the allocation when possible
+ public final int add(byte op, boolean arg) { if(capacity == size) grow(); set(size, op, arg); return size++; }
+ /** Adds a bytecode with an integer argument. This is equivalent to add(op, new Integer(arg)), but optimized to prevent the allocation when possible
@return The position of the new bytecode
- @see #add(byte,Object)
+ @see #add(byte, Object)
*/
- public final int add(byte op, int arg) { if(capacity == size) grow(); set(size,op,arg); return size++; }
+ public final int add(byte op, int arg) { if(capacity == size) grow(); set(size, op, arg); return size++; }
/** Gets the bytecode at position <i>pos</i>
@exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
*/
public final Object getArg(int pos) { return arg[pos]; }
- /** Sets the argument for <i>pos</i> to <i>arg</i>. This is equivalent to set(pos,op,new Integer(arg)), but optimized to prevent the allocation when possible.
+ /** Sets the argument for <i>pos</i> to <i>arg</i>. This is equivalent to set(pos, op, new Integer(arg)), but optimized to prevent the allocation when possible.
@exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
- @see #setArg(int,Object) */
- public final void setArg(int pos, int arg) { set(pos,op[pos],N(arg)); }
+ @see #setArg(int, Object) */
+ public final void setArg(int pos, int arg) { set(pos, op[pos], N(arg)); }
/** Sets the argument for <i>pos</i> to <i>arg</i>.
@exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
*/
- public final void setArg(int pos, Object arg) { set(pos,op[pos],arg); }
+ public final void setArg(int pos, Object arg) { set(pos, op[pos], arg); }
/** Sets the bytecode and argument at <i>pos</i> to <i>op</i> and <i>arg</i> respectivly.
- This is equivalent to set(pos,op,arg?1:0)
+ This is equivalent to set(pos, op, arg?1:0)
@exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
*/
- public final void set(int pos, byte op, boolean arg) { set(pos,op,arg?1:0); }
+ public final void set(int pos, byte op, boolean arg) { set(pos, op, arg?1:0); }
- // This MUST handle x{LOAD,STORE} and LDC with an int arg WITHOUT falling back to set(int,byte,Object)
+ // This MUST handle x{LOAD, STORE} and LDC with an int arg WITHOUT falling back to set(int, byte, Object)
/** Sets the bytecode and argument at <i>pos</i> to <i>op</i> and <i>n</i> respectivly.
- This is equivalent to set(pos,op, new Integer(n)), but optimized to prevent the allocation when possible.
+ This is equivalent to set(pos, op, new Integer(n)), but optimized to prevent the allocation when possible.
@exception ArrayIndexOutOfBoundException if pos < 0 || pos >= size()
*/
public final void set(int pos, byte op, int n) {
}
break;
default:
- set(pos,op,N(n));
+ set(pos, op, N(n));
return;
}
this.op[pos] = op;
switch(op) {
case ILOAD: case ISTORE: case LLOAD: case LSTORE: case FLOAD:
case FSTORE: case DLOAD: case DSTORE: case ALOAD: case ASTORE:
- // set(int,byte,int) always handles these ops itself
- set(pos,op,((Integer)arg).intValue());
+ // set(int, byte, int) always handles these ops itself
+ set(pos, op, ((Integer)arg).intValue());
return;
case LDC:
- // set(int,byte,int) always handles these opts itself
- if(arg instanceof Integer) { set(pos,op,((Integer)arg).intValue()); return; }
- if(arg instanceof Boolean) { set(pos,op,((Boolean)arg).booleanValue()); return; }
+ // set(int, byte, int) always handles these opts itself
+ if(arg instanceof Integer) { set(pos, op, ((Integer)arg).intValue()); return; }
+ if(arg instanceof Boolean) { set(pos, op, ((Boolean)arg).booleanValue()); return; }
if(arg instanceof Long) {
long l = ((Long)arg).longValue();
this.lo = lo;
this.hi = hi;
}
- public void setTargetForVal(int val, Object o) { setTarget(val-lo,o); }
- public void setTargetForVal(int val, int n) { setTarget(val-lo,n); }
+ public void setTargetForVal(int val, Object o) { setTarget(val-lo, o); }
+ public void setTargetForVal(int val, int n) { setTarget(val-lo, n); }
int length() { return 12 + targets.length * 4; } // 4bytes/target, hi, lo, default
}
public final byte op;
public final int varNum;
public final int n;
- Wide(byte op, int varNum) { this(op,varNum,0); }
+ Wide(byte op, int varNum) { this(op, varNum, 0); }
Wide(byte op, int varNum, int n) { this.op = op; this.varNum = varNum; this.n = n; }
}
int[] pc = new int[size];
int[] maxpc = pc;
- int p,i;
+ int p, i;
// Pass1 - Calculate maximum pc of each bytecode, widen some insns, resolve any unresolved jumps, etc
- for(i=0,p=0;i<size;i++) {
+ for(i=0, p=0;i<size;i++) {
byte op = this.op[i];
int opdata = OP_DATA[op&0xff];
int j;
int arg = ((Integer)this.arg[i]).intValue();
if(arg > 255) {
this.op[i] = WIDE;
- this.arg[i] = new Wide(op,arg);
+ this.arg[i] = new Wide(op, arg);
}
break;
}
Pair pair = (Pair) this.arg[i];
if(pair.i1 > 255 || pair.i2 < -128 || pair.i2 > 127) {
this.op[i] = WIDE;
- this.arg[i] = new Wide(IINC,pair.i1,pair.i2);
+ this.arg[i] = new Wide(IINC, pair.i1, pair.i2);
}
break;
}
}
// Pass3 - Calculate actual pc
- for(i=0,p=0;i<size;i++) {
+ for(i=0, p=0;i<size;i++) {
byte op = this.op[i];
pc[i] = p;
switch(op) {
p = (p + 3) & ~3; // padding
p += 4; // default
if(op == TABLESWITCH) p += 4 + 4 + si.size() * 4; // lo, hi, targets
- else p += 4 + si.size() * 4 * 2; // count, key,val * targets
+ else p += 4 + si.size() * 4 * 2; // count, key, val * targets
break;
}
case WIDE:
o.writeShort(exnTable.size());
for(Enumeration e = exnTable.keys();e.hasMoreElements();)
- ((ExnTableEnt)exnTable.get(e.nextElement())).dump(o,pc,codeSize);
+ ((ExnTableEnt)exnTable.get(e.nextElement())).dump(o, pc, codeSize);
o.writeShort(codeAttrs.size());
codeAttrs.dump(o);
baos.close();
byte[] codeAttribute = baos.toByteArray();
- attrs.add("Code",codeAttribute);
+ attrs.add("Code", codeAttribute);
baos.reset();
o.writeShort(thrownExceptions.size());
for(Enumeration e = thrownExceptions.keys();e.hasMoreElements();)
o.writeShort(cp.getIndex((CPGen.Ent)thrownExceptions.get(e.nextElement())));
- attrs.add("Exceptions",baos.toByteArray());
+ attrs.add("Exceptions", baos.toByteArray());
size = capacity = FINISHED;
}
/** Create a reference to method <i>name</i> of class <i>c</i> with the return type <i>ret</i> and the
arguments <i>args</i> */
public MethodRef(Type.Object c, String name, Type ret, Type[] args) {
- super(c,name,getDescriptor(ret,args));
+ super(c, name, getDescriptor(ret, args));
}
- /** Equivalent to MethodRef(new Type.Object(s),...)
- @see #MethodRef(Type.Object,String,Type,Type[])
+ /** Equivalent to MethodRef(new Type.Object(s), ...)
+ @see #MethodRef(Type.Object, String, Type, Type[])
*/
public MethodRef(String s, String name, Type ret, Type[] args) {
this(Type.fromDescriptor(s).asObject(), name, ret, args);
users don't need to be concerned with this though because MethodRef's are automatically converted
to MethodRef.I's when they are applied to an INVOKEINTERFACE bytecode */
public static class I extends MethodRef {
- public I(Type.Object c, String name, Type ret, Type[] args) { super(c,name,ret,args); }
- public I(String s, String name, Type ret, Type[] args) { super(s,name,ret,args); }
+ public I(Type.Object c, String name, Type ret, Type[] args) { super(c, name, ret, args); }
+ public I(String s, String name, Type ret, Type[] args) { super(s, name, ret, args); }
I(MethodRef m) { super(m); }
}
}
@param base The base type
@return A one dimensional array of the base type
*/
- public static Type arrayType(Type base) { return arrayType(base,1); }
+ public static Type arrayType(Type base) { return arrayType(base, 1); }
/** Returns a <i>dim</i> dimensional array type for the base type <i>base</i>
@param base The base type
@param dim Number if dimensions
public boolean isObject() { return true; }
private static String _initHelper(String s) {
- if(!s.startsWith("L") || !s.endsWith(";")) s = "L" + s.replace('.','/') + ";";
+ if(!s.startsWith("L") || !s.endsWith(";")) s = "L" + s.replace('.', '/') + ";";
if(!validDescriptorString(s)) throw new IllegalArgumentException("invalid descriptor string");
return s;
}
String[] components() {
- StringTokenizer st = new StringTokenizer(descriptor.substring(1,descriptor.length()-1),"/");
+ StringTokenizer st = new StringTokenizer(descriptor.substring(1, descriptor.length()-1), "/");
String[] a = new String[st.countTokens()];
for(int i=0;st.hasMoreTokens();i++) a[i] = st.nextToken();
return a;
}
- String internalForm() { return descriptor.substring(1,descriptor.length()-1); }
+ String internalForm() { return descriptor.substring(1, descriptor.length()-1); }
static boolean validDescriptorString(String s) {
return s.startsWith("L") && s.endsWith(";");
}
public static class Array extends Object {
- protected Array(Type t, int dim) { super(arrayify(t,dim)); }
+ protected Array(Type t, int dim) { super(arrayify(t, dim)); }
public Type.Array asArray() { return this; }
public boolean isArray() { return true; }
private static String arrayify(Type t, int dim) {