1 cananian 1.30.2.8 // HMethod.java, created Fri Jul 31 22:02:43 1998 by cananian 2 cananian 1.23 // Copyright (C) 1998 C. Scott Ananian <cananian@alumni.princeton.edu> 3 cananian 1.23 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 cananian 1.1 package harpoon.ClassFile; 5 cananian 1.1 6 cananian 1.30.2.1 import harpoon.Util.ArrayFactory; 7 cananian 1.1 8 cananian 1.1 /** 9 cananian 1.13 * An <code>HMethod</code> provides information about, and access to, a 10 cananian 1.1 * single method on a class or interface. The reflected method 11 cananian 1.1 * may be a class method or an instance method (including an abstract 12 cananian 1.1 * method). 13 cananian 1.1 * 14 cananian 1.4 * @author C. Scott Ananian <cananian@alumni.princeton.edu> 15 salcianu 1.34 * @version $Id: HMethod.java,v 1.34 2003/03/18 03:52:53 salcianu Exp $ 16 cananian 1.1 * @see HMember 17 cananian 1.1 * @see HClass 18 cananian 1.1 */ 19 cananian 1.30.2.12 public interface HMethod extends HMember { 20 cananian 1.1 /** 21 cananian 1.1 * Returns the <code>HClass</code> object representing the class or 22 cananian 1.1 * interface that declares the method represented by this 23 cananian 1.1 * <code>HMethod</code> object. 24 cananian 1.1 */ 25 cananian 1.30.2.12 public HClass getDeclaringClass(); 26 cananian 1.9 27 cananian 1.1 /** 28 cananian 1.1 * Returns the name of the method represented by this <code>HMethod</code> 29 cananian 1.1 * object, as a <code>String</code>. 30 cananian 1.1 */ 31 cananian 1.30.2.12 public String getName(); 32 cananian 1.9 33 cananian 1.1 /** 34 cananian 1.1 * Returns the Java language modifiers for the method represented by this 35 cananian 1.22 * <code>HMethod</code> object, as an integer. The 36 cananian 1.22 * <code>java.lang.reflect.Modifier</code> 37 cananian 1.1 * class should be used to decode the modifiers. 38 cananian 1.1 * @see java.lang.reflect.Modifier 39 cananian 1.1 */ 40 cananian 1.30.2.12 public int getModifiers(); 41 cananian 1.9 42 cananian 1.1 /** 43 cananian 1.1 * Returns a <code>HClass</code> object that represents the formal 44 cananian 1.1 * return type of the method represented by this <code>HMethod</code> 45 cananian 1.30.2.14 * object. Returns <code>HClass.Void</code> if the method returns 46 cananian 1.30.2.14 * no value. 47 cananian 1.1 */ 48 cananian 1.30.2.12 public HClass getReturnType(); 49 cananian 1.12 50 cananian 1.12 /** 51 salcianu 1.34 * Returns the descriptor for this method. The format of a method 52 salcianu 1.34 * string descriptor is defined in <a 53 salcianu 1.34 * href="http://java.sun.com/docs/books/vmspec/html/ClassFile.doc.html#1169">Section 54 salcianu 1.34 * 4.3</a> of the JVM specification. */ 55 cananian 1.30.2.12 public String getDescriptor(); 56 cananian 1.9 57 cananian 1.1 /** 58 cananian 1.1 * Returns an array of <code>HClass</code> objects that represent the 59 cananian 1.1 * formal parameter types, in declaration order, of the method 60 cananian 1.1 * represented by this <code>HMethod</code> object. Returns an array 61 cananian 1.1 * of length 0 is the underlying method takes no parameters. 62 cananian 1.1 */ 63 cananian 1.30.2.12 public HClass[] getParameterTypes(); 64 cananian 1.9 65 cananian 1.1 /** 66 cananian 1.8 * Returns an array of <code>String</code> objects giving the declared 67 cananian 1.8 * names of the formal parameters of the method. The length of the 68 cananian 1.8 * returned array is equal to the number of formal parameters. 69 cananian 1.8 * If there is no <code>LocalVariableTable</code> attribute available 70 cananian 1.8 * for this method, then every element of the returned array will be 71 cananian 1.8 * <code>null</code>. 72 cananian 1.8 */ 73 cananian 1.30.2.12 public String[] getParameterNames(); 74 cananian 1.9 75 cananian 1.8 /** 76 cananian 1.1 * Returns an array of <code>HClass</code> objects that represent the 77 cananian 1.1 * types of the checked exceptions thrown by the underlying method 78 cananian 1.1 * represented by this <code>HMethod</code> object. Returns an array 79 cananian 1.1 * of length 0 if the method throws no checked exceptions. 80 cananian 1.1 */ 81 cananian 1.30.2.12 public HClass[] getExceptionTypes(); 82 cananian 1.6 83 cananian 1.6 /** 84 cananian 1.30.2.12 * Determines whether this <code>HMethod</code> is synthetic, 85 cananian 1.30.2.12 * in the sense of "associated with an inner-class; not programmer 86 cananian 1.30.2.12 * declared". 87 cananian 1.6 */ 88 cananian 1.30.2.12 public boolean isSynthetic(); 89 cananian 1.15 90 cananian 1.30.2.13 /** Determines whether this <code>HMethod</code> is an interface method. 91 cananian 1.30.2.13 * @return true if the declaring class is an interface, unless this 92 cananian 1.30.2.13 * method represents the static class initializer of the 93 cananian 1.30.2.13 * interface. 94 cananian 1.6 */ 95 cananian 1.30.2.12 public boolean isInterfaceMethod(); 96 cananian 1.15 97 cananian 1.17 /** Determines whether this is a static method. */ 98 cananian 1.30.2.12 public boolean isStatic(); 99 cananian 1.1 100 cananian 1.30.2.12 /** Returns a mutator for this <code>HMethod</code>, or <code>null</code> 101 cananian 1.30.2.12 * if the object is immutable. */ 102 cananian 1.30.2.12 public HMethodMutator getMutator(); 103 cananian 1.30.2.12 104 cananian 1.1 /** 105 cananian 1.1 * Compares this <code>HMethod</code> against the specified object. 106 cananian 1.1 * Returns <code>true</code> if the objects are the same. Two 107 cananian 1.1 * <code>HMethod</code>s are the same if they were declared by the same 108 cananian 1.1 * class and have the same name and formal parameter types. 109 cananian 1.30.2.12 */ 110 cananian 1.30.2.12 public boolean equals(Object obj); 111 cananian 1.9 112 cananian 1.1 /** 113 cananian 1.1 * Returns a string describing this <code>HMethod</code>. The string 114 cananian 1.1 * is formatted as the method access modifiers, if any, followed by 115 cananian 1.1 * the method return type, followed by a space, followed by the class 116 cananian 1.1 * declaring the method, followed by a period, followed by the method 117 cananian 1.1 * name, followed by a parenthesized, comma-separated list of the 118 cananian 1.1 * method's formal parameter types. If the method throws checked 119 cananian 1.1 * exceptions, the parameter list is followed by a space, followed 120 cananian 1.1 * by the word throws followed by a comma-separated list of the 121 cananian 1.1 * throws exception types. For example:<p> 122 cananian 1.1 * <DL> 123 cananian 1.1 * <DD><CODE>public boolean java.lang.Object.equals(java.lang.Object)</CODE> 124 cananian 1.1 * </DL><p> 125 cananian 1.1 * The access modifiers are placed in canonical order as specified by 126 cananian 1.1 * "The Java Language Specification." This is 127 cananian 1.1 * <code>public</code>, <code>protected</code>, or <code>private</code> 128 cananian 1.1 * first, and then other modifiers in the following order: 129 cananian 1.1 * <code>abstract</code>, <code>static</code>, <code>final</code>, 130 cananian 1.1 * <code>synchronized</code>, <code>native</code>. 131 cananian 1.1 */ 132 cananian 1.30.2.12 public String toString(); 133 cananian 1.33 134 cananian 1.33 /*****************************************************************/ 135 cananian 1.33 // JSR-14 extensions. 136 cananian 1.33 137 cananian 1.33 /** 138 cananian 1.33 * Returns an array of <code>HType</code> objects that represent the 139 cananian 1.33 * formal parameter types, in declaration order, of the method 140 cananian 1.33 * represented by this <code>HMethod</code> object. Returns an 141 cananian 1.33 * array of length 0 if the underlying method takes no parameters. 142 cananian 1.33 * <p> 143 cananian 1.33 * In particular, if the compile-time type of any formal parameter 144 cananian 1.33 * is a type variable or a parameterized type, than an object of the 145 cananian 1.33 * appropriate type (i.e., <code>HTypeVariable</code> or 146 cananian 1.33 * <code>HParameterizedType</code>) will be returned. 147 cananian 1.33 */ 148 cananian 1.33 public HType[] getGenericParameterTypes(); 149 cananian 1.33 /** 150 cananian 1.33 * Returns an <code>HType</code> object that represents the formal 151 cananian 1.33 * return type of the method represented by this 152 cananian 1.33 * <code>HMethod</code> object. In particular, if the compile-time 153 cananian 1.33 * return type a parameterized type, than an object of the 154 cananian 1.33 * appropriate type (i.e., <code>HTypeVariable</code> or 155 cananian 1.33 * <code>HParameterizedType</code> will be returned. 156 cananian 1.33 */ 157 cananian 1.33 public HType getGenericReturnType(); 158 cananian 1.33 /** 159 cananian 1.33 * Returns an array of <code>HMethodTypeVariable</code> objects that 160 cananian 1.33 * represent the type variables declared by the method represented 161 cananian 1.33 * by this <code>HMethod</code> object, in declaration order. 162 cananian 1.33 * Returns an array of length 0 if the underlying method declares no 163 cananian 1.33 * type variables. 164 cananian 1.33 */ 165 cananian 1.33 public HMethodTypeVariable[] getTypeParameters(); 166 cananian 1.1 167 cananian 1.30.2.1 /** Array factory: returns new <code>HMethod[]</code>. */ 168 cananian 1.31.2.1 public static final ArrayFactory<HMethod> arrayFactory = 169 cananian 1.30.2.12 Factories.hmethodArrayFactory; 170 cananian 1.1 } 171 cananian 1.13 172 cananian 1.13 // set emacs indentation style. 173 cananian 1.13 // Local Variables: 174 cananian 1.13 // c-basic-offset:2 175 cananian 1.13 // End: