org.dellroad.jc.cgen
Class Util

java.lang.Object
  extended byorg.dellroad.jc.cgen.Util

public class Util
extends Object

Various utility stuff used when analyzing class files and generating code.


Nested Class Summary
static class Util.OrderTypeSwitch
          Utility class that computes ordering preference in a C structure of the various types.
static class Util.PrimTypeSwitch
          Utility class that passes the appropriate string ("byte", "char", etc.) to the prim() method depending on the primitive type.
 
Field Summary
static int ACC_SUPER
           
static Comparator classComparator
          Sorts classes by their names' UTF-8 encoding.
static Comparator fieldComparator
          Sorts fields by staticness, basic type, name, then signature.
static Comparator localComparator
          Sorts local variables by name.
static Comparator methodComparator
          Sorts methods by name, then by signature.
static Comparator utf8Comparator
          Sorts Strings in the same way that strcmp() does on their UTF-8 encodings.
 
Method Summary
static String _JC_TYPE(Type t)
          Return the _JC_TYPE_* macro appropriate for the given type.
static void addSupertypes(SootClass cls, Set set)
           
static long classHash(SootClass sc)
           
static String fieldDescriptor(Type t)
           
static SootMethod findMethod(SootClass c, String subSig)
          Find a method declared by a SootClass or any of its superclasses.
static String fullSignature(SootMethod m)
           
static Set getAllInterfaces(SootClass c)
           
static Set getAllSupertypes(SootClass c)
           
static long hash(String s)
           
static boolean hasSubtypes(SootClass c)
           
static boolean hasSubtypes(SootField f)
           
static boolean hasSubtypes(SootMethod m)
           
static boolean hasSubtypes(Type t)
           
static int imethodHash(SootMethod m)
          Get the interface method hash table hash.
static int instanceofHash(SootClass sc)
          Get the instanceof hash table hash.
static boolean isClassInit(SootMethod m)
           
static boolean isConstructor(SootMethod m)
           
static boolean isFinal(SootClass c)
           
static boolean isFinal(SootField f)
           
static boolean isFinal(SootMethod m)
           
static boolean isNonvirtual(SpecialInvokeExpr v, SootMethod callingMethod)
          Determine if an INVOKESPECIAL can be implemented like the old INVOKENONVIRTUAL.
static boolean isPrimitive(Type type)
           
static boolean isPrimitiveArray(Type type)
           
static boolean isReference(SootClass c)
           
static boolean isReference(SootField f)
           
static boolean isReference(SootMethod m)
           
static boolean isReference(Type t)
          Return whether type t is a reference type or not.
static boolean isVirtual(SootMethod m)
           
static void panic(String msg)
           
static String paramTypes(SootMethod m)
           
static void require(boolean value)
           
static void require(boolean value, String msg)
          Poor man's assert().
static long sigHash(SootMethod m)
           
static String sigHashString(SootMethod m)
           
static String signature(SootField f)
           
static String signature(SootMethod m)
           
static char typeLetter(Type t)
           
static String typeWord(Type t)
           
static byte[] utf8Encode(String s)
          This method is required to work around a stupid bug in Sun's JDK String.getBytes("UTF-8") (bug #4628881).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACC_SUPER

public static final int ACC_SUPER
See Also:
Constant Field Values

utf8Comparator

public static final Comparator utf8Comparator
Sorts Strings in the same way that strcmp() does on their UTF-8 encodings.


methodComparator

public static final Comparator methodComparator
Sorts methods by name, then by signature.


localComparator

public static final Comparator localComparator
Sorts local variables by name.


fieldComparator

public static final Comparator fieldComparator
Sorts fields by staticness, basic type, name, then signature.


classComparator

public static final Comparator classComparator
Sorts classes by their names' UTF-8 encoding.

Method Detail

_JC_TYPE

public static String _JC_TYPE(Type t)
Return the _JC_TYPE_* macro appropriate for the given type.


isReference

public static boolean isReference(SootClass c)

isReference

public static boolean isReference(SootField f)

isReference

public static boolean isReference(SootMethod m)

isPrimitive

public static boolean isPrimitive(Type type)

isPrimitiveArray

public static boolean isPrimitiveArray(Type type)

isFinal

public static boolean isFinal(SootClass c)

isFinal

public static boolean isFinal(SootField f)

isFinal

public static boolean isFinal(SootMethod m)

isVirtual

public static boolean isVirtual(SootMethod m)

isConstructor

public static boolean isConstructor(SootMethod m)

isClassInit

public static boolean isClassInit(SootMethod m)

hasSubtypes

public static boolean hasSubtypes(SootClass c)

hasSubtypes

public static boolean hasSubtypes(SootField f)

hasSubtypes

public static boolean hasSubtypes(SootMethod m)

hasSubtypes

public static boolean hasSubtypes(Type t)

isReference

public static boolean isReference(Type t)
Return whether type t is a reference type or not. t must be a normal Java type, i.e., a type that can be the type of a variable.


typeLetter

public static char typeLetter(Type t)

fieldDescriptor

public static String fieldDescriptor(Type t)

typeWord

public static String typeWord(Type t)

signature

public static String signature(SootField f)

signature

public static String signature(SootMethod m)

fullSignature

public static String fullSignature(SootMethod m)

paramTypes

public static String paramTypes(SootMethod m)

hash

public static long hash(String s)

sigHash

public static long sigHash(SootMethod m)

classHash

public static long classHash(SootClass sc)

isNonvirtual

public static boolean isNonvirtual(SpecialInvokeExpr v,
                                   SootMethod callingMethod)
Determine if an INVOKESPECIAL can be implemented like the old INVOKENONVIRTUAL.


instanceofHash

public static int instanceofHash(SootClass sc)
Get the instanceof hash table hash.


imethodHash

public static int imethodHash(SootMethod m)
Get the interface method hash table hash.


sigHashString

public static String sigHashString(SootMethod m)

findMethod

public static SootMethod findMethod(SootClass c,
                                    String subSig)
Find a method declared by a SootClass or any of its superclasses.


getAllInterfaces

public static Set getAllInterfaces(SootClass c)

getAllSupertypes

public static Set getAllSupertypes(SootClass c)

addSupertypes

public static void addSupertypes(SootClass cls,
                                 Set set)

require

public static void require(boolean value)

require

public static void require(boolean value,
                           String msg)
Poor man's assert().


utf8Encode

public static byte[] utf8Encode(String s)
This method is required to work around a stupid bug in Sun's JDK String.getBytes("UTF-8") (bug #4628881).


panic

public static void panic(String msg)