edu.rit.classfile
Class ConstructorReference

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

public class ConstructorReference
extends SubroutineReference

Class ConstructorReference is used to create a reference to a constructor. To create a constructor reference:

  1. Construct a new instance of class ConstructorReference, specifying the class.

  2. Add the constructor's argument types in order, if any.

Or:

  1. Construct a new instance of class ConstructorReference, specifying the class.

  2. Specify the constructor's method descriptor, if the constructor has arguments. The method descriptor must indicate the return type is void.

Or:

  1. Construct a new instance of class ConstructorReference, specifying the class and the constructor's method descriptor, if the constructor has arguments. The method descriptor must indicate the return type is void.

Do not use the constructor reference for anything until you have completed the above steps. Once you have completed the above steps and have begun using the constructor reference, do not add further argument types or set the method descriptor.

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


Constructor Summary
ConstructorReference(ClassReference theClassReference)
          Construct a new constructor reference object.
ConstructorReference(ClassReference theClassReference, String theMethodDescriptor)
          Construct a new constructor reference object with the given method descriptor.
 
Method Summary
 void addArgumentType(TypeReference theArgumentType)
          Add an argument to the referenced constructor.
 void setMethodDescriptor(String theMethodDescriptor)
          Specify the referenced constructor's method descriptor.
 
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

ConstructorReference

public ConstructorReference(ClassReference theClassReference)
Construct a new constructor reference object. Initially, the referenced constructor has no arguments.

Parameters:
theClassReference - Class containing this constructor.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassReference is null.

ConstructorReference

public ConstructorReference(ClassReference theClassReference,
                            String theMethodDescriptor)
Construct a new constructor reference object with the given method descriptor. The method descriptor must indicate the return type is void.

Parameters:
theClassReference - Class containing this constructor.
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 theMethodDescriptor is null.
IllegalArgumentException - (unchecked exception) Thrown if theMethodDescriptor does not obey the syntax of a method descriptor. Thrown if theMethodDescriptor indicates that the return type is not void. Thrown if the number of arguments in theMethodDescriptor exceeds the limit (254).
Method Detail

addArgumentType

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

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 constructor reference is already in use.
ListFullException - Thrown if adding theArgumentType would cause the referenced constructor's argument word count to exceed the limit (254).

setMethodDescriptor

public void setMethodDescriptor(String theMethodDescriptor)
Specify the referenced constructor's method descriptor. The method descriptor must indicate the return type is void.

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 constructor reference is already in use.
IllegalArgumentException - (unchecked exception) Thrown if theMethodDescriptor does not obey the syntax of a method descriptor. Thrown if theMethodDescriptor indicates that the return type is not void. 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.