X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fclassgen%2FMethodRef.java;h=deec8197417d53eca82ad64a721c08dc671d7d08;hb=42a1bb10686a80875ffc209626fedaec95095d0f;hp=cb546bdbf9396824851b85914751936205e2c7b5;hpb=bc9112573cba51be5e7d285ccd3e496be4278c63;p=org.ibex.classgen.git
diff --git a/src/org/ibex/classgen/MethodRef.java b/src/org/ibex/classgen/MethodRef.java
index cb546bd..deec819 100644
--- a/src/org/ibex/classgen/MethodRef.java
+++ b/src/org/ibex/classgen/MethodRef.java
@@ -1,16 +1,25 @@
package org.ibex.classgen;
-public class MethodRef extends ClassGen.FieldMethodRef {
- public MethodRef(Type.Object c, ClassGen.NameAndType t) { super(c,t); }
- public MethodRef(Type.Object c, String name, String descriptor) {
- this(c,new ClassGen.NameAndType(name,descriptor));
- }
+/** This class represents Method references. It is used as an argument to the
+ INVOKESTATIC, INVOKEVIRTUAL, INVOKESPEICAL, and INVOKEINTERFACE bytecodes
+ @see CGConst#INVOKESTATIC
+ @see CGConst#INVOKEVIRTUAL
+ @see CGConst#INVOKESPECIAL
+ @see CGConst#INVOKEINTERFACE
+*/
+public class MethodRef extends ClassGen.FieldOrMethodRef {
+ /** Create a reference to method name of class c with the return type ret and the
+ arguments args */
public MethodRef(Type.Object c, String name, Type ret, Type[] args) {
- this(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[])
+ */
public MethodRef(String s, String name, Type ret, Type[] args) {
- this(new Type.Object(s),name,ret,args);
+ this(Type.fromDescriptor(s).asObject(), name, ret, args);
}
+ MethodRef(MethodRef i) { super(i); }
static String getDescriptor(Type ret, Type[] args) {
StringBuffer sb = new StringBuffer(args.length*4);
@@ -20,5 +29,14 @@ public class MethodRef extends ClassGen.FieldMethodRef {
sb.append(ret.getDescriptor());
return sb.toString();
}
+
+ /** MethodRef class used for the INVOKEINTERFACE bytecode. Although this contains the same
+ data as a normal MethodRef, these are treated differently in the byte code format. In general,
+ 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); }
+ I(MethodRef m) { super(m); }
+ }
}
-