edu.rit.classfile
Class SynthesizedClassConstantFieldDescription

java.lang.Object
  extended by edu.rit.classfile.FieldReference
      extended by edu.rit.classfile.FieldDescription
          extended by edu.rit.classfile.SynthesizedFieldDescription
              extended by edu.rit.classfile.SynthesizedClassConstantFieldDescription

public class SynthesizedClassConstantFieldDescription
extends SynthesizedFieldDescription

Class SynthesizedClassConstantFieldDescription is used to synthesize a field description for some actual field that is part of a class and that has an initial constant value. A class constant field is always static. A class constant field may or may not be final. (When a field has a constant value, it only means the field is initialized automatically with a constant value. It doesn't mean the field has to keep that value forever.) To synthesize a class constant field:

  1. Create an instance of class SynthesizedClassConstantFieldDescription, specifying the class, the field's name, and the field's constant value. In this case the JVM will automatically initialize the field to the given constant value.

  2. Specify the field's access mode, final mode, volatile mode, and transient mode if necessary.

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

To synthesize a class field that is not constant, see class SynthesizedClassFieldDescription. To synthesize an interface field, see class SynthesizedInterfaceFieldDescription.


Constructor Summary
SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription, String theFieldName, boolean theValue)
          Construct a new synthesized class constant field description object with the given class, field name, and boolean constant value.
SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription, String theFieldName, byte theValue)
          Construct a new synthesized class constant field description object with the given class, field name, and byte constant value.
SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription, String theFieldName, char theValue)
          Construct a new synthesized class constant field description object with the given class, field name, and character constant value.
SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription, String theFieldName, double theValue)
          Construct a new synthesized class constant field description object with the given class, field name, and double constant value.
SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription, String theFieldName, float theValue)
          Construct a new synthesized class constant field description object with the given class, field name, and float constant value.
SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription, String theFieldName, int theValue)
          Construct a new synthesized class constant field description object with the given class, field name, and integer constant value.
SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription, String theFieldName, long theValue)
          Construct a new synthesized class constant field description object with the given class, field name, and long constant value.
SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription, String theFieldName, short theValue)
          Construct a new synthesized class constant field description object with the given class, field name, and short constant value.
SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription, String theFieldName, String theValue)
          Construct a new synthesized class constant field description object with the given class, field name, and string constant value.
 
Method Summary
 void setFinal()
          Specify that the described field is final and is not volatile, that is, may not be changed after initialization and can be cached.
 void setNonFinalNonVolatile()
          Specify that the described field is not final and is not volatile, that is, may be changed after initialization and can be cached.
 void setPackageScoped()
          Specify that the described field 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 setPrivate()
          Specify that the described field is private, that is, may be accessed only from inside its defining class.
 void setProtected()
          Specify that the described field 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 field is public, that is, may be accessed from inside and outside its defining package.
 void setTransient(boolean isTransient)
          Specify whether the described field is transient, that is, not written or read by a persistent object manager.
 void setVolatile()
          Specify that the described field is not final and is volatile, that is, may be changed after initialization and cannot be cached.
 
Methods inherited from class edu.rit.classfile.FieldDescription
getConstantValue, isFinal, isPackageScoped, isPrivate, isProtected, isPublic, isStatic, isTransient, isVolatile
 
Methods inherited from class edu.rit.classfile.FieldReference
equals, getClassReference, getFieldDescriptor, getFieldName, getFieldType, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SynthesizedClassConstantFieldDescription

public SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription,
                                                String theFieldName,
                                                String theValue)
                                         throws ListFullException
Construct a new synthesized class constant field description object with the given class, field name, and string constant value. The described field is initially public, static, non-final, non-volatile, and non-transient, and its type is java.lang.String. As a side effect, the described field is added to the given class.

Parameters:
theClassDescription - Class containing this field.
theFieldName - Field name.
theValue - String constant value.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null, theFieldName is null, or theValue is null.
IllegalArgumentException - (unchecked exception) Thrown if theFieldName is zero length.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if theClassDescription's field list is full (i.e., contains 65535 fields).

SynthesizedClassConstantFieldDescription

public SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription,
                                                String theFieldName,
                                                int theValue)
                                         throws ListFullException
Construct a new synthesized class constant field description object with the given class, field name, and integer constant value. The described field is initially public, static, non-final, non-volatile, and non-transient, and its type is int. As a side effect, the described field is added to the given class.

Parameters:
theClassDescription - Class containing this field.
theFieldName - Field name.
theValue - Integer constant value.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null or theFieldName is null.
IllegalArgumentException - (unchecked exception) Thrown if theFieldName is zero length.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if theClassDescription's field list is full (i.e., contains 65535 fields).

SynthesizedClassConstantFieldDescription

public SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription,
                                                String theFieldName,
                                                short theValue)
                                         throws ListFullException
Construct a new synthesized class constant field description object with the given class, field name, and short constant value. The described field is initially public, static, non-final, non-volatile, and non-transient, and its type is short. As a side effect, the described field is added to the given class.

Parameters:
theClassDescription - Class containing this field.
theFieldName - Field name.
theValue - Short constant value.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null or theFieldName is null.
IllegalArgumentException - (unchecked exception) Thrown if theFieldName is zero length.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if theClassDescription's field list is full (i.e., contains 65535 fields).

SynthesizedClassConstantFieldDescription

public SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription,
                                                String theFieldName,
                                                char theValue)
                                         throws ListFullException
Construct a new synthesized class constant field description object with the given class, field name, and character constant value. The described field is initially public, static, non-final, non-volatile, and non-transient, and its type is char. As a side effect, the described field is added to the given class.

Parameters:
theClassDescription - Class containing this field.
theFieldName - Field name.
theValue - Character constant value.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null or theFieldName is null.
IllegalArgumentException - (unchecked exception) Thrown if theFieldName is zero length.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if theClassDescription's field list is full (i.e., contains 65535 fields).

SynthesizedClassConstantFieldDescription

public SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription,
                                                String theFieldName,
                                                byte theValue)
                                         throws ListFullException
Construct a new synthesized class constant field description object with the given class, field name, and byte constant value. The described field is initially public, static, non-final, non-volatile, and non-transient, and its type is byte. As a side effect, the described field is added to the given class.

Parameters:
theClassDescription - Class containing this field.
theFieldName - Field name.
theValue - Byte constant value.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null or theFieldName is null.
IllegalArgumentException - (unchecked exception) Thrown if theFieldName is zero length.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if theClassDescription's field list is full (i.e., contains 65535 fields).

SynthesizedClassConstantFieldDescription

public SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription,
                                                String theFieldName,
                                                boolean theValue)
                                         throws ListFullException
Construct a new synthesized class constant field description object with the given class, field name, and boolean constant value. The described field is initially public, static, non-final, non-volatile, and non-transient, and its type is boolean. As a side effect, the described field is added to the given class.

Parameters:
theClassDescription - Class containing this field.
theFieldName - Field name.
theValue - Boolean constant value.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null or theFieldName is null.
IllegalArgumentException - (unchecked exception) Thrown if theFieldName is zero length.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if theClassDescription's field list is full (i.e., contains 65535 fields).

SynthesizedClassConstantFieldDescription

public SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription,
                                                String theFieldName,
                                                float theValue)
                                         throws ListFullException
Construct a new synthesized class constant field description object with the given class, field name, and float constant value. The described field is initially public, static, non-final, non-volatile, and non-transient, and its type is float. As a side effect, the described field is added to the given class.

Parameters:
theClassDescription - Class containing this field.
theFieldName - Field name.
theValue - Float constant value.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null or theFieldName is null.
IllegalArgumentException - (unchecked exception) Thrown if theFieldName is zero length.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if theClassDescription's field list is full (i.e., contains 65535 fields).

SynthesizedClassConstantFieldDescription

public SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription,
                                                String theFieldName,
                                                long theValue)
                                         throws ListFullException
Construct a new synthesized class constant field description object with the given class, field name, and long constant value. The described field is initially public, static, non-final, non-volatile, and non-transient, and its type is long. As a side effect, the described field is added to the given class.

Parameters:
theClassDescription - Class containing this field.
theFieldName - Field name.
theValue - Long constant value.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null or theFieldName is null.
IllegalArgumentException - (unchecked exception) Thrown if theFieldName is zero length.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if theClassDescription's field list is full (i.e., contains 65535 fields).

SynthesizedClassConstantFieldDescription

public SynthesizedClassConstantFieldDescription(SynthesizedClassDescription theClassDescription,
                                                String theFieldName,
                                                double theValue)
                                         throws ListFullException
Construct a new synthesized class constant field description object with the given class, field name, and double constant value. The described field is initially public, static, non-final, non-volatile, and non-transient, and its type is double. As a side effect, the described field is added to the given class.

Parameters:
theClassDescription - Class containing this field.
theFieldName - Field name.
theValue - Double constant value.
Throws:
NullPointerException - (unchecked exception) Thrown if theClassDescription is null or theFieldName is null.
IllegalArgumentException - (unchecked exception) Thrown if theFieldName is zero length.
ListFullException - Thrown if the requisite constant pool entries could not be added because the constant pool is full. Also thrown if theClassDescription's field list is full (i.e., contains 65535 fields).
Method Detail

setPublic

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


setPrivate

public void setPrivate()
Specify that the described field is private, that is, may be accessed only from inside its defining class.


setProtected

public void setProtected()
Specify that the described field 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 field has default access (also known as package scoped), that is, may be accessed only from inside its defining package or inside its defining class.


setNonFinalNonVolatile

public void setNonFinalNonVolatile()
Specify that the described field is not final and is not volatile, that is, may be changed after initialization and can be cached.


setFinal

public void setFinal()
Specify that the described field is final and is not volatile, that is, may not be changed after initialization and can be cached.


setVolatile

public void setVolatile()
Specify that the described field is not final and is volatile, that is, may be changed after initialization and cannot be cached.


setTransient

public void setTransient(boolean isTransient)
Specify whether the described field is transient, that is, not written or read by a persistent object manager.

Parameters:
isTransient - True if the described field is transient, false otherwise.


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