1 package org.ibex.classgen;
3 /** This class represents Method references. It is used as an argument to the
4 INVOKESTATIC, INVOKEVIRTUAL, INVOKESPEICAL, and INVOKEINTERFACE bytecodes
5 @see CGConst#INVOKESTATIC
6 @see CGConst#INVOKEVIRTUAL
7 @see CGConst#INVOKESPECIAL
8 @see CGConst#INVOKEINTERFACE
10 public class MethodRef extends MemberRef {
12 final Type[] argTypes;
13 final Type returnType;
15 /** Create a reference to method <i>name</i> of class <i>c</i> with the return type <i>ret</i> and the
16 arguments <i>args</i> */
17 public MethodRef(Type.Class c, String name, Type returnType, Type[] argTypes) {
19 this.argTypes = argTypes;
20 this.returnType = returnType;
23 public String getDescriptor() {
24 StringBuffer sb = new StringBuffer(argTypes.length*4);
26 for(int i=0;i<argTypes.length;i++) sb.append(argTypes[i].getDescriptor());
28 sb.append(returnType.getDescriptor());
32 /** MethodRef class used for the INVOKEINTERFACE bytecode. Although this contains the same
33 data as a normal MethodRef, these are treated differently in the byte code format. In general,
34 users don't need to be concerned with this though because MethodRef's are automatically converted
35 to MethodRef.I's when they are applied to an INVOKEINTERFACE bytecode */
36 public static class I extends MethodRef {
37 public I(Type.Class c, String name, Type ret, Type[] args) { super(c, name, ret, args); }