Class ConstantValueWriter
java.lang.Object
com.ibm.wala.shrike.shrikeCT.ClassWriter.Element
com.ibm.wala.shrike.shrikeCT.ConstantValueWriter
This class builds serializable ConstantValue attributes. These attributes are associated with
final fields.
After constructing a ConstantValueWriter, you must call setValueCPIndex.
-
Constructor Summary
ConstructorDescriptionBuild an empty writer.ConstantValueWriter
(ClassWriter w, double v) Build an writer for a 'double' constant value.ConstantValueWriter
(ClassWriter w, float v) Build an writer for a 'float' constant value.ConstantValueWriter
(ClassWriter w, int v) Build an writer for an 'int' constant value.ConstantValueWriter
(ClassWriter w, long v) Build an writer for a 'long' constant value.Build an writer for a 'String' constant value. -
Method Summary
Modifier and TypeMethodDescriptionint
copyInto
(byte[] buf, int offset) Copy the bytes into 'buf' at offset 'offset'.int
getSize()
void
setDouble
(double value) Set the constant value to a double.void
setFloat
(float value) Set the constant value to a float.void
setInt
(int value) Set the constant value to an int.void
setLong
(long value) Set the constant value to a long.void
Set the constant value to a String.void
setValueCPIndex
(int index) Set the index of the constant pool item holding the constant value.
-
Constructor Details
-
ConstantValueWriter
Build an empty writer.- Throws:
IllegalArgumentException
- if w is null
-
ConstantValueWriter
Build an writer for a 'long' constant value. -
ConstantValueWriter
Build an writer for an 'int' constant value. -
ConstantValueWriter
Build an writer for a 'float' constant value. -
ConstantValueWriter
Build an writer for a 'double' constant value. -
ConstantValueWriter
Build an writer for a 'String' constant value.
-
-
Method Details
-
getSize
public int getSize()- Specified by:
getSize
in classClassWriter.Element
- Returns:
- the number of bytes that will be generated.
-
copyInto
Description copied from class:ClassWriter.Element
Copy the bytes into 'buf' at offset 'offset'.- Specified by:
copyInto
in classClassWriter.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
Set the constant value to a String. -
setValueCPIndex
Set the index of the constant pool item holding the constant value.- Throws:
IllegalArgumentException
-