Class ConstantValueWriter

java.lang.Object
com.ibm.wala.shrike.shrikeCT.ClassWriter.Element
com.ibm.wala.shrike.shrikeCT.ConstantValueWriter

public final class ConstantValueWriter extends ClassWriter.Element
This class builds serializable ConstantValue attributes. These attributes are associated with final fields.

After constructing a ConstantValueWriter, you must call setValueCPIndex.

  • Constructor Details

    • ConstantValueWriter

      public ConstantValueWriter(ClassWriter w)
      Build an empty writer.
      Throws:
      IllegalArgumentException - if w is null
    • ConstantValueWriter

      public ConstantValueWriter(ClassWriter w, long v)
      Build an writer for a 'long' constant value.
    • ConstantValueWriter

      public ConstantValueWriter(ClassWriter w, int v)
      Build an writer for an 'int' constant value.
    • ConstantValueWriter

      public ConstantValueWriter(ClassWriter w, float v)
      Build an writer for a 'float' constant value.
    • ConstantValueWriter

      public ConstantValueWriter(ClassWriter w, double v)
      Build an writer for a 'double' constant value.
    • ConstantValueWriter

      public ConstantValueWriter(ClassWriter w, String v)
      Build an writer for a 'String' constant value.
  • Method Details

    • getSize

      public int getSize()
      Specified by:
      getSize in class ClassWriter.Element
      Returns:
      the number of bytes that will be generated.
    • copyInto

      public int copyInto(byte[] buf, int offset) throws IllegalArgumentException
      Description copied from class: ClassWriter.Element
      Copy the bytes into 'buf' at offset 'offset'.
      Specified by:
      copyInto in class ClassWriter.Element
      Returns:
      the number of bytes copies, which must be equal to getSize()
      Throws:
      IllegalArgumentException
    • setLong

      public void setLong(long value)
      Set the constant value to a long.
    • setDouble

      public void setDouble(double value)
      Set the constant value to a double.
    • setInt

      public void setInt(int value)
      Set the constant value to an int.
    • setFloat

      public void setFloat(float value)
      Set the constant value to a float.
    • setString

      public void setString(String value)
      Set the constant value to a String.
    • setValueCPIndex

      public void setValueCPIndex(int index) throws IllegalArgumentException
      Set the index of the constant pool item holding the constant value.
      Throws:
      IllegalArgumentException