edu.rit.classfile
Class SynthesizedClassInitializerDescription

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.SynthesizedClassInitializerDescription

public class SynthesizedClassInitializerDescription
extends SynthesizedSubroutineDescription

Class SynthesizedClassInitializerDescription is used to synthesize a subroutine description for some actual class initializer. To synthesize a class initializer:

  1. Create an instance of class SynthesizedClassInitializerDescription, specifying the class or interface.

  2. Modify the class initializer's strict floating point mode if necessary.

  3. Add the class initializer's bytecode instructions in order.

  4. Add the class initializer's exception handlers in order if necessary.

  5. Set the class initializer's max_stack and max_locals values.

In the documentation below, the term "described class initializer" means "the synthesized class initializer described by this synthesized class initializer description object."


Constructor Summary
SynthesizedClassInitializerDescription(SynthesizedClassOrInterfaceDescription theClassDescription)
          Construct a new synthesized class initializer description object.
 
Method Summary
 void addExceptionHandler(Location theStartLocation, Location theEndLocation, Location theHandlerLocation, ClassReference theCatchType)
          Add an exception handler to the described class initializer's list of exception handlers.
 void addInstruction(Instruction theInstruction)
          Adds the given instruction to the described class initializer's list of bytecode instructions.
 void increaseMaxLocals(int theMaxLocals)
          Increase the described class initializer's max_locals item if necessary.
 void increaseMaxStack(int theMaxStack)
          Increase the described class initializer's max_stack item if necessary.
 void setMaxLocals(int theMaxLocals)
          Specify the described class initializer's max_locals item.
 void setMaxStack(int theMaxStack)
          Specify the described class initializer's max_stack item.
 void setStrictfp(boolean isStrictfp)
          Specify whether the described class initializer uses strict floating point mode.
 
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

SynthesizedClassInitializerDescription

public SynthesizedClassInitializerDescription(SynthesizedClassOrInterfaceDescription theClassDescription)
                                       throws ListFullException
Construct a new synthesized class initializer description object. Initially, the described class initializer does not use strict floating point mode, has no instructions, has max_stack = 0, and has max_locals = 0. As a side effect, the new synthesized class initializer description object is added to the given synthesized class or interface description object.

Parameters:
theClassDescription - Class or interface containing this class initializer.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null.
ListFullException - Thrown if theClassDescription's subroutine list is full (i.e., contains 65535 subroutines).
Method Detail

setStrictfp

public void setStrictfp(boolean isStrictfp)
Specify whether the described class initializer uses strict floating point mode.

Parameters:
isStrictfp - True to use strict floating point mode, false not to use strict floating point mode.

addInstruction

public void addInstruction(Instruction theInstruction)
                    throws ListFullException
Adds the given instruction to the described class initializer's list of bytecode instructions.

Parameters:
theInstruction - Instruction to add.
Throws:
NullPointerException - (unchecked exception) Thrown if theInstruction is null.
ListFullException - Thrown if the requisite constant pool entries could not be added because the described class initializer's constant pool is full. Also thrown if adding theInstruction would cause the described class initializer's code length to exceed the maximum allowed value (65534 bytes).

addExceptionHandler

public void addExceptionHandler(Location theStartLocation,
                                Location theEndLocation,
                                Location theHandlerLocation,
                                ClassReference theCatchType)
                         throws ListFullException
Add an exception handler to the described class initializer's list of exception handlers.

Parameters:
theStartLocation - Start location. This is the location of the first instruction in the class initializer's bytecode sequence covered by the exception handler. (The start location is inclusive.)
theEndLocation - End location. This is the location of the next instruction after the last instruction in the class initializer's bytecode sequence covered by the exception handler. (The end location is exclusive.)
theHandlerLocation - Handler location. This is the location of the first instruction in the exception handler itself.
theCatchType - Catch type. This is a class reference to the exception class caught by the exception handler. Null means the exception handler catches all exceptions.
Throws:
NullPointerException - (unchecked exception) Thrown if theStartLocation is null, theEndLocation is null, or theHandlerLocation is null.
IllegalArgumentException - (unchecked exception) Thrown if any of the following is true:
  • theStartLocation, theEndLocation, and theHandlerLocation have not all been added to the described class initializer.
  • theStartLocation is at the same place as or comes after theEndLocation.
ListFullException - Thrown if the requisite constant pool entries could not be added because the described class initializer's class's constant pool was full. Also thrown if the described class initializer's exception handler list is full (i.e., contains 65535 exception handlers).

setMaxStack

public void setMaxStack(int theMaxStack)
                 throws OutOfRangeException
Specify the described class initializer's max_stack item. The max_stack item's value gives the maximum depth of the described class initializer's operand stack at any point during execution of the class initializer.

Parameters:
theMaxStack - max_stack value.
Throws:
OutOfRangeException - Thrown if theMaxStack is not in the range 0 .. 65535.

increaseMaxStack

public void increaseMaxStack(int theMaxStack)
                      throws OutOfRangeException
Increase the described class initializer's max_stack item if necessary. The max_stack item's value gives the maximum depth of the described class initializer's operand stack at any point during execution of the class initializer. If the described class initializer's current max_stack value is less than theMaxStack, the max_stack value is set to theMaxStack, otherwise the max_stack value is unchanged.

Parameters:
theMaxStack - max_stack value.
Throws:
OutOfRangeException - Thrown if theMaxStack is not in the range 0 .. 65535.

setMaxLocals

public void setMaxLocals(int theMaxLocals)
                  throws OutOfRangeException
Specify the described class initializer's max_locals item. The max_locals item's value gives the number of local variables in the local variable array allocated upon invocation of the described class initializer.

Parameters:
theMaxLocals - max_locals value.
Throws:
OutOfRangeException - Thrown if theMaxLocals is not in the range 0 .. 65535.

increaseMaxLocals

public void increaseMaxLocals(int theMaxLocals)
                       throws OutOfRangeException
Increase the described class initializer's max_locals item if necessary. The max_locals item's value gives the number of local variables in the local variable array allocated upon invocation of the described class initializer. If the described class initializer's current max_locals value is less than theMaxLocals, the max_locals value is set to theMaxLocals, otherwise the max_locals value is unchanged.

Parameters:
theMaxLocals - max_locals value.
Throws:
OutOfRangeException - Thrown if theMaxLocals is not in the range 0 .. 65535.


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