soot.coffi
Class CONSTANT_Utf8_info

java.lang.Object
  extended by soot.coffi.CONSTANT_Utf8_info

public class CONSTANT_Utf8_info
extends Object

A constant pool entry of type CONSTANT_Utf8; note this is not multithread safe. It is, however, immutable.

Author:
Clark Verbrugge
See Also:
cp_info

Field Summary
static byte CONSTANT_Class
           
static byte CONSTANT_Double
           
static byte CONSTANT_Fieldref
           
static byte CONSTANT_Float
           
static byte CONSTANT_Integer
           
static byte CONSTANT_InterfaceMethodref
           
static byte CONSTANT_InvokeDynamic
           
static byte CONSTANT_Long
           
static byte CONSTANT_MethodHandle
           
static byte CONSTANT_Methodref
           
static byte CONSTANT_MethodType
           
static byte CONSTANT_NameAndType
           
static byte CONSTANT_String
           
static byte CONSTANT_Utf8
           
static byte REF_getField
           
static byte REF_getStatic
           
static byte REF_invokeInterface
           
static byte REF_invokeSpecial
           
static byte REF_invokeStatic
           
static byte REF_invokeVirtual
           
static byte REF_newInvokeSpecial
           
static byte REF_putField
           
static byte REF_putStatic
           
static byte[] REF_TO_CONSTANT
           
 byte tag
          One of the CONSTANT_* constants.
 
Constructor Summary
CONSTANT_Utf8_info(DataInputStream d)
          Constructor from a DataInputSream
 
Method Summary
 int compareTo(soot.coffi.cp_info cp)
          Compares this entry with another cp_info object; note that for Utf8 object it really doesn't matter whether they're in the same or a different constant pool, since they really do carry all their data.
 int compareTo(soot.coffi.cp_info[] constant_pool, soot.coffi.cp_info cp, soot.coffi.cp_info[] cp_constant_pool)
          Compares this entry with another cp_info object (which may reside in a different constant pool).
 String convert()
          Converts internal representation into an actual String.
static int countParams(soot.coffi.cp_info[] constant_pool, int m)
          Counts the number of parameters of the given method.
 Value createJimpleConstantValue(soot.coffi.cp_info[] constant_pool)
          Creates an appropriate jimple representation of this constant.
 boolean equals(CONSTANT_Utf8_info cu)
          Answers whether this utf8 string is the same as a given one.
static String fieldType(soot.coffi.cp_info[] constant_pool, int i)
          Returns the name of the field type of the given constant pool object.
 void fixConversion(String rep)
          Fixes the actual String used to represent the internal representation.
static String getClassname(soot.coffi.cp_info[] constant_pool, int i)
          Locates the name of the corresponding class, given the constant pool index of either a CONSTANT_Class, _Fieldref, Methodref or InterfaceMethodref.
static String getName(soot.coffi.cp_info[] constant_pool, int i)
          Returns the name of the given constant pool object, assuming it is of type CONSTANT_NameAndType, _FieldRef, _Methodref or _InterfaceMethodref.
static String getTypeDescr(soot.coffi.cp_info[] constant_pool, int i)
          Returns the type descriptor for the given constant pool object, which must be a CONSTANT_Utf8, CONSTANT_NameAndType, CONSTANT_Fieldref, CONSTANT_MethodRef, or CONSTANT_InterfaceMethodRef.
static long ints2long(long high, long low)
          Utility method, converts two integers into a single long.
 int length()
          Length in bytes of byte array.
static String printBits(int i)
          Utility method, returns a String binary representation of the given integer.
static String printBits(long i)
          Utility method, returns a String binary representation of the given long.
 int size()
          Returns the size of this cp_info object.
 String toString(soot.coffi.cp_info[] constant_pool)
          Returns a String representation of this entry.
static byte[] toUtf8(String s)
          Utility method; converts the given String into a utf8 encoded array of bytes.
 String typeName()
          Returns a String description of what kind of entry this is.
 void writeBytes(DataOutputStream dd)
          For writing out the byte stream for this utf8 properly (incl size).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTANT_Utf8

public static final byte CONSTANT_Utf8
See Also:
Constant Field Values

CONSTANT_Integer

public static final byte CONSTANT_Integer
See Also:
Constant Field Values

CONSTANT_Float

public static final byte CONSTANT_Float
See Also:
Constant Field Values

CONSTANT_Long

public static final byte CONSTANT_Long
See Also:
Constant Field Values

CONSTANT_Double

public static final byte CONSTANT_Double
See Also:
Constant Field Values

CONSTANT_Class

public static final byte CONSTANT_Class
See Also:
Constant Field Values

CONSTANT_String

public static final byte CONSTANT_String
See Also:
Constant Field Values

CONSTANT_Fieldref

public static final byte CONSTANT_Fieldref
See Also:
Constant Field Values

CONSTANT_Methodref

public static final byte CONSTANT_Methodref
See Also:
Constant Field Values

CONSTANT_InterfaceMethodref

public static final byte CONSTANT_InterfaceMethodref
See Also:
Constant Field Values

CONSTANT_NameAndType

public static final byte CONSTANT_NameAndType
See Also:
Constant Field Values

CONSTANT_MethodHandle

public static final byte CONSTANT_MethodHandle
See Also:
Constant Field Values

CONSTANT_MethodType

public static final byte CONSTANT_MethodType
See Also:
Constant Field Values

CONSTANT_InvokeDynamic

public static final byte CONSTANT_InvokeDynamic
See Also:
Constant Field Values

REF_getField

public static final byte REF_getField
See Also:
Constant Field Values

REF_getStatic

public static final byte REF_getStatic
See Also:
Constant Field Values

REF_putField

public static final byte REF_putField
See Also:
Constant Field Values

REF_putStatic

public static final byte REF_putStatic
See Also:
Constant Field Values

REF_invokeVirtual

public static final byte REF_invokeVirtual
See Also:
Constant Field Values

REF_invokeStatic

public static final byte REF_invokeStatic
See Also:
Constant Field Values

REF_invokeSpecial

public static final byte REF_invokeSpecial
See Also:
Constant Field Values

REF_newInvokeSpecial

public static final byte REF_newInvokeSpecial
See Also:
Constant Field Values

REF_invokeInterface

public static final byte REF_invokeInterface
See Also:
Constant Field Values

REF_TO_CONSTANT

public static final byte[] REF_TO_CONSTANT

tag

public byte tag
One of the CONSTANT_* constants.

Constructor Detail

CONSTANT_Utf8_info

public CONSTANT_Utf8_info(DataInputStream d)
                   throws IOException
Constructor from a DataInputSream

Throws:
IOException
Method Detail

writeBytes

public void writeBytes(DataOutputStream dd)
                throws IOException
For writing out the byte stream for this utf8 properly (incl size).

Throws:
IOException

length

public int length()
Length in bytes of byte array.


size

public int size()
Returns the size of this cp_info object.

Returns:
number of bytes occupied by this object.
See Also:
cp_info.size()

convert

public String convert()
Converts internal representation into an actual String.

Returns:
String version of this utf8 object.

fixConversion

public void fixConversion(String rep)
Fixes the actual String used to represent the internal representation. We must have rep == convert(); we verify hashCodes() to spot-check this. No user-visible effects.


equals

public boolean equals(CONSTANT_Utf8_info cu)
Answers whether this utf8 string is the same as a given one.

Parameters:
cu - utf8 object with which to compare.
Returns:
true if they are equal, false if they are not.

compareTo

public int compareTo(soot.coffi.cp_info[] constant_pool,
                     soot.coffi.cp_info cp,
                     soot.coffi.cp_info[] cp_constant_pool)
Compares this entry with another cp_info object (which may reside in a different constant pool).

Parameters:
constant_pool - constant pool of ClassFile for this.
cp - constant pool entry to compare against.
cp_constant_pool - constant pool of ClassFile for cp.
Returns:
a value <0, 0, or >0 indicating whether this is smaller, the same or larger than cp.
See Also:
cp_info.compareTo(soot.coffi.cp_info[], soot.coffi.cp_info, soot.coffi.cp_info[]), compareTo(cp_info)

compareTo

public int compareTo(soot.coffi.cp_info cp)
Compares this entry with another cp_info object; note that for Utf8 object it really doesn't matter whether they're in the same or a different constant pool, since they really do carry all their data.

Parameters:
cp - constant pool entry to compare against.
Returns:
a value <0, 0, or >0 indicating whether this is smaller, the same or larger than cp.
See Also:
cp_info.compareTo(soot.coffi.cp_info[], soot.coffi.cp_info, soot.coffi.cp_info[]), compareTo(cp_info[],cp_info,cp_info[])

toUtf8

public static byte[] toUtf8(String s)
Utility method; converts the given String into a utf8 encoded array of bytes.

Parameters:
s - String to encode.
Returns:
array of bytes, utf8 encoded version of s.

toString

public String toString(soot.coffi.cp_info[] constant_pool)
Returns a String representation of this entry.

Parameters:
constant_pool - constant pool of ClassFile.
Returns:
String representation of this entry.
See Also:
cp_info.toString(soot.coffi.cp_info[])

typeName

public String typeName()
Returns a String description of what kind of entry this is.

Returns:
the String "utf8".
See Also:
cp_info.typeName()

createJimpleConstantValue

public Value createJimpleConstantValue(soot.coffi.cp_info[] constant_pool)
Creates an appropriate jimple representation of this constant. Field and method constants are assumed to point to static fields/methods.


ints2long

public static long ints2long(long high,
                             long low)
Utility method, converts two integers into a single long.

Parameters:
high - upper 32 bits of the long.
low - lower 32 bits of the long.
Returns:
a long value composed from the two ints.

printBits

public static String printBits(int i)
Utility method, returns a String binary representation of the given integer.

Parameters:
i - the integer in question.
Returns:
a String of 0's and 1's.
See Also:
cp_info.printBits(long)

printBits

public static String printBits(long i)
Utility method, returns a String binary representation of the given long.

Parameters:
i - the long in question.
Returns:
a String of 0's and 1's.
See Also:
cp_info.printBits(int)

getClassname

public static String getClassname(soot.coffi.cp_info[] constant_pool,
                                  int i)
Locates the name of the corresponding class, given the constant pool index of either a CONSTANT_Class, _Fieldref, Methodref or InterfaceMethodref.

Parameters:
constant_pool - constant pool of ClassFile.
i - index of cp_info entry in question.
Returns:
name of the associated class.

getName

public static String getName(soot.coffi.cp_info[] constant_pool,
                             int i)
Returns the name of the given constant pool object, assuming it is of type CONSTANT_NameAndType, _FieldRef, _Methodref or _InterfaceMethodref.

Parameters:
constant_pool - constant pool of ClassFile.
i - index of cp_info entry in question.
Returns:
name of the associated object.
See Also:
CONSTANT_Utf8_info

countParams

public static int countParams(soot.coffi.cp_info[] constant_pool,
                              int m)
Counts the number of parameters of the given method.

Parameters:
constant_pool - constant pool of ClassFile.
m - a constant pool index as accepted by getTypeDescr.
Returns:
the number of parameters.
See Also:
cp_info.getTypeDescr(soot.coffi.cp_info[], int)

getTypeDescr

public static String getTypeDescr(soot.coffi.cp_info[] constant_pool,
                                  int i)
Returns the type descriptor for the given constant pool object, which must be a CONSTANT_Utf8, CONSTANT_NameAndType, CONSTANT_Fieldref, CONSTANT_MethodRef, or CONSTANT_InterfaceMethodRef.

Parameters:
constant_pool - constant pool of ClassFile.
i - a constant pool index for an entry of type CONSTANT_Utf8, CONSTANT_NameAndType, CONSTANT_MethodRef, or CONSTANT_InterfaceMethodRef.
Returns:
the type descriptor.
See Also:
CONSTANT_Utf8_info

fieldType

public static String fieldType(soot.coffi.cp_info[] constant_pool,
                               int i)
Returns the name of the field type of the given constant pool object.

Parameters:
constant_pool - constant pool of ClassFile.
i - a constant pool index for an entry of type CONSTANT_Utf8, CONSTANT_NameAndType, or CONSTANT_FieldRef.
Returns:
the type of the field.
See Also:
CONSTANT_Utf8_info, cp_info.getTypeDescr(soot.coffi.cp_info[], int)