edu.rit.classfile
Class SynthesizedAbstractMethodDescription

java.lang.Object
  extended by edu.rit.classfile.SubroutineReference
      extended by edu.rit.classfile.SubroutineDescription
          extended by edu.rit.classfile.SynthesizedSubroutineDescription
              extended by edu.rit.classfile.SynthesizedAbstractMethodDescription

public class SynthesizedAbstractMethodDescription
extends SynthesizedSubroutineDescription

Class SynthesizedAbstractMethodDescription is used to synthesize a subroutine description for some actual abstract method. To synthesize an abstract method:

  1. Create an instance of class SynthesizedAbstractMethodDescription, specifying the class and the method name.

  2. Modify the method's access mode if necessary.

  3. Specify the method's return type, if any.

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

  5. Add the method's thrown exceptions in order, if any.

Or:

  1. Create an instance of class SynthesizedAbstractMethodDescription, specifying the class and the method name.

  2. Modify the method's access mode if necessary.

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

  4. Add the method's thrown exceptions in order, if any.

Or:

  1. Create an instance of class SynthesizedAbstractMethodDescription, specifying the class, the method name, and the method descriptor, if the method does not return void or if the method has arguments.

  2. Modify the method's access mode if necessary.

  3. Add the method's thrown exceptions in order, if any.

In the documentation below, the term "described method" means "the synthesized abstract method described by this synthesized abstract method description object."

To synthesize a non-abstract method, see class SynthesizedMethodDescription.


Constructor Summary
SynthesizedAbstractMethodDescription(SynthesizedClassDescription theClassDescription, String theMethodName)
          Construct a new synthesized abstract method description object with the given name.
SynthesizedAbstractMethodDescription(SynthesizedClassDescription theClassDescription, String theMethodName, String theMethodDescriptor)
          Construct a new synthesized abstract method description object with the given name and method descriptor.
 
Method Summary
 void addArgumentType(TypeReference theArgumentType)
          Add an argument to the described method.
 void addThrownException(ClassReference theExceptionClass)
          Add a thrown exception to the described method.
 void setMethodDescriptor(String theMethodDescriptor)
          Specify the described method's method descriptor.
 void setPackageScoped()
          Specify that the described method has default access (also known as package scoped), that is, may be accessed only from inside its defining package or inside its defining class.
 void setProtected()
          Specify that the described method is protected, that is, may be accessed only from inside its defining package, inside its defining class, or inside subclasses of its defining class.
 void setPublic()
          Specify that the described method is public, that is, may be accessed from inside and outside its defining package.
 void setReturnType(TypeReference theReturnType)
          Specify the described method's return type.
 
Methods inherited from class edu.rit.classfile.SubroutineDescription
getCodeLength, getExceptionHandlers, getInstructions, getMaxLocals, getMaxStack, getThrownExceptions, isAbstract, isFinal, isNative, isPackageScoped, isPrivate, isProtected, isPublic, isStatic, isStrictfp, isSynchronized
 
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

SynthesizedAbstractMethodDescription

public SynthesizedAbstractMethodDescription(SynthesizedClassDescription theClassDescription,
                                            String theMethodName)
                                     throws ListFullException
Construct a new synthesized abstract method description object with the given name. Initially, the described method is public, is abstract, has a return type of void, has no arguments, and throws no exceptions. As a side effect, the new synthesized abstract method description object is added to the given synthesized class description object.

Parameters:
theClassDescription - Class containing this method.
theMethodName - Method name.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null or theMethodName is null.
IllegalArgumentException - (unchecked exception) Thrown if theMethodName is zero length.
ListFullException - Thrown if theClassDescription's subroutine list is full (i.e., contains 65535 subroutines).

SynthesizedAbstractMethodDescription

public SynthesizedAbstractMethodDescription(SynthesizedClassDescription theClassDescription,
                                            String theMethodName,
                                            String theMethodDescriptor)
                                     throws ListFullException
Construct a new synthesized abstract method description object with the given name and method descriptor. Initially, the described method is public, is abstract, has a return type and arguments as specified by theMethodDescriptor, and throws no exceptions. As a side effect, the new synthesized abstract method description object is added to the given synthesized class description object.

Parameters:
theClassDescription - 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 theClassDescription 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).
ListFullException - Thrown if theClassDescription's subroutine list is full (i.e., contains 65535 subroutines).
Method Detail

setPublic

public void setPublic()
Specify that the described method is public, that is, may be accessed from inside and outside its defining package.


setProtected

public void setProtected()
Specify that the described method is protected, that is, may be accessed only from inside its defining package, inside its defining class, or inside subclasses of its defining class.


setPackageScoped

public void setPackageScoped()
Specify that the described method has default access (also known as package scoped), that is, may be accessed only from inside its defining package or inside its defining class.


setReturnType

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

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

addArgumentType

public void addArgumentType(TypeReference theArgumentType)
                     throws ListFullException
Add an argument to the described 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 description is already in use.
ListFullException - Thrown if adding theArgumentType would cause the described method's argument word count to exceed the limit (254).

setMethodDescriptor

public void setMethodDescriptor(String theMethodDescriptor)
Specify the described 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 description 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).

addThrownException

public void addThrownException(ClassReference theExceptionClass)
                        throws ListFullException
Add a thrown exception to the described method.

Parameters:
theExceptionClass - Exception's class reference.
Throws:
NullPointerException - (unchecked exception) Thrown if theExceptionClass is null.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if the described method's thrown exception list is full (i.e., contains 65535 thrown exceptions).


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