Class dec.trek.MethodThe Method object allows you to manipulate the methods of a class. Also a method can be passed as an argument when the called methods corresponding parameter is of class Member. This is because Member is the superclass of Field and Method. The Method class does not have a public constructor. To reach a classfiles methods, you must use firstMethod() or lastMethod() in the ClassFile class, or override atStartOf(Method) or atEndOf(Method) in the Trek class. A method consists of statements and local variables. However statements are not explicitly part of a classfile, and local variables may not be. Thus the method needs to be analyzed before you can access its content. This occurs when you first access a statement or local variable with firstStatement, firstLocal, and so on. This analysis is rather involved. In particular, determining the data type of a local variable can require using getClassFile to access other classfiles. But if a classfile is not accessible, the analyzer catches the exception and uses heuristics to make up for the unavailable info. Method Summary
Fieldspublic Object userDefined Field that can be used by an application developer to store arbitrary data about this object during the trek. MethodsReturns the Local object of this methods first local variable. If this method has no locals, null is returned instead. If the method is not static, the first local is always the this variable. public Statement firstStatement() Returns the Statement object of this methods first statement. If this method has no code, null is returned instead. Returns the number of arguments defined for this method public ClassFile getClassFile() Returns the ClassFile object of the class that this method is part of public ExceptionHandler[] getExceptionHandlers() Returns this methods exception handlers. If this method has no exception handlers, null is returned instead. To access the attributes of an exception handler, see the ExceptionHandler class. public boolean hasModifier(int flags) Returns true if this method was declared with any of the specified flags. Parameters: flags one or more of the ACC constants defined in the Trek class. public boolean isConstructor() Returns true if this method is a constructor. Returns the Local object of this methods last local. If this method has no locals, null is returned instead. public Statement lastStatement() Returns the Statement object of this methods last statement. If this method has no code, null is returned instead. Returns the Method of the alphabetically next method in this methods classfile. Returns null if there are no more methods. Returns the Method of the alphabetically previous method in this methods classfile. Returns null if there are no more methods. Returns the source code that defined this methods argument list. Returns the unqualified name of this method. Returns a persistent value that identifies this method. A reference to this method can be acquired by calling getObject on a trek that this method is within. A method is defined by its argument list as well as its name (because overloading is allowed in Java). Thus an object Id for a method becomes obsolete if either its name or its argument list is changed. Returns the source statement that defined this method. public String[] toThrowsTypes() Returns an array containing the fully qualified name of each exception specified in this method's throws clause. If this method has no throws clause, the returned array's size is 0. Returns this methods return type, such as void or int or java.lang.Object.
|