edu.rit.classfile
Class MethodReference

java.lang.Object
  extended by edu.rit.classfile.SubroutineReference
      extended by edu.rit.classfile.MethodReference

public class MethodReference
extends SubroutineReference

Class MethodReference is used to create a reference to a method. To create a method reference:

  1. Construct a new instance of class MethodReference, specifying the class and method name.

  2. Specify the method's return type if it does not return void.

  3. Add the method's argument types in order, if any.

Or:

  1. Construct a new instance of class MethodReference, specifying the class and method name.

  2. Specify the method descriptor, if the method does not return void or if the method has arguments.

Or:

  1. Construct a new instance of class MethodReference, specifying the class, the method name, and the method descriptor, if the method does not return void or if the method has arguments.

Do not use the method reference for anything until you have completed the above steps. Once you have completed the above steps and have begun using the method reference, do not alter the method reference's return type or add further argument types or alter the method descriptor.

In the documentation below, the term "referenced method" means "the method referred to by this method reference object."


Constructor Summary
MethodReference(ClassReference theClassReference, String theMethodName)
          Construct a new method reference object with the given method name.
MethodReference(ClassReference theClassReference, String theMethodName, String theMethodDescriptor)
          Construct a new method reference object with the given method name and method descriptor.
 
Method Summary
 void addArgumentType(TypeReference theArgumentType)
          Add an argument to the referenced method.
 void setMethodDescriptor(String theMethodDescriptor)
          Specify the referenced method's method descriptor.
 void setReturnType(TypeReference theReturnType)
          Specify the referenced method's return type.
 
Methods inherited from class edu.rit.classfile.SubroutineReference
equals, getArgumentTypes, getArgumentWordCount, getClassReference, getMethodDescriptor, getMethodName, getReturnType, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MethodReference

public MethodReference(ClassReference theClassReference,
                       String theMethodName)
Construct a new method reference object with the given method name. Initially, the referenced method has no arguments and returns void.

Parameters:
theClassReference - Class containing this method.
theMethodName - Method name.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassReference is null or theMethodName is null.
IllegalArgumentException - (unchecked exception) Thrown if theMethodName is zero length.

MethodReference

public MethodReference(ClassReference theClassReference,
                       String theMethodName,
                       String theMethodDescriptor)
Construct a new method reference object with the given method name and method descriptor.

Parameters:
theClassReference - Class containing this method.
theMethodName - Method name.
theMethodDescriptor - Method descriptor in the format specified by Section 4.3.3 of the Java Virtual Machine Specification, Second Edition.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassReference is null or theMethodName is null or theMethodDescriptor is null.
IllegalArgumentException - (unchecked exception) Thrown if theMethodName is zero length. Thrown if theMethodDescriptor does not obey the syntax of a method descriptor. Thrown if the number of arguments in theMethodDescriptor exceeds the limit (254).
Method Detail

setReturnType

public void setReturnType(TypeReference theReturnType)
Specify the referenced method's return type.

Parameters:
theReturnType - Type reference for the return type, or null if the referenced method returns void.
Throws:
IllegalStateException - (unchecked exception) Thrown if the return type cannot be altered because this method reference is already in use.

addArgumentType

public void addArgumentType(TypeReference theArgumentType)
                     throws ListFullException
Add an argument to the referenced method.

Parameters:
theArgumentType - Argument's type reference.
Throws:
NullPointerException - (unchecked exception) Thrown if theArgumentType is null.
IllegalStateException - (unchecked exception) Thrown if further argument types cannot be added because this method reference is already in use.
ListFullException - Thrown if adding theArgumentType would cause the referenced method's argument word count to exceed the limit (254).

setMethodDescriptor

public void setMethodDescriptor(String theMethodDescriptor)
Specify the referenced method's method descriptor.

Parameters:
theMethodDescriptor - Method descriptor in the format specified by Section 4.3.3 of the Java Virtual Machine Specification, Second Edition.
Throws:
NullPointerException - (unchecked exception) Thrown if theMethodDescriptor is null.
IllegalStateException - (unchecked exception) Thrown if the method descriptor cannot be set because this method reference is already in use.
IllegalArgumentException - (unchecked exception) Thrown if theMethodDescriptor does not obey the syntax of a method descriptor. Thrown if the number of arguments in theMethodDescriptor exceeds the limit (254).


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.