jist.swans.misc
Class Sizeof

java.lang.Object
  extended by jist.swans.misc.Sizeof

public class Sizeof
extends java.lang.Object

Compute the static or dynamic size of a type or object.

Since:
SWANS1.0
Version:
$Id: Sizeof.java,v 1.4 2004/04/06 16:07:49 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Field Summary
private static int SIZE_REFERENCE
          Size of a pointer.
 
Constructor Summary
Sizeof()
           
 
Method Summary
private static int array(java.lang.Object obj)
          Return (dynamic) size of an array.
static int inst(boolean b)
          Return (dynamic) size of primitive.
static int inst(byte b)
          Return (dynamic) size of primitive.
static int inst(char c)
          Return (dynamic) size of primitive.
static int inst(double d)
          Return (dynamic) size of primitive.
static int inst(float f)
          Return (dynamic) size of primitive.
static int inst(int i)
          Return (dynamic) size of primitive.
static int inst(long l)
          Return (dynamic) size of primitive.
static int inst(java.lang.Object obj)
          Return (dynamic) size of object instance.
static int inst(short s)
          Return (dynamic) size of primitive.
private static int primitive(java.lang.Class type)
          Return static size of primitive type.
static int type(java.lang.Class type)
          Return static size of non-primitive type (a class/structure).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE_REFERENCE

private static final int SIZE_REFERENCE
Size of a pointer.

See Also:
Constant Field Values
Constructor Detail

Sizeof

public Sizeof()
Method Detail

inst

public static int inst(boolean b)
Return (dynamic) size of primitive.

Parameters:
b - boolean
Returns:
sizeof(boolean)

inst

public static int inst(byte b)
Return (dynamic) size of primitive.

Parameters:
b - byte
Returns:
sizeof(byte)

inst

public static int inst(char c)
Return (dynamic) size of primitive.

Parameters:
c - char
Returns:
sizeof(char)

inst

public static int inst(short s)
Return (dynamic) size of primitive.

Parameters:
s - short
Returns:
sizeof(short)

inst

public static int inst(int i)
Return (dynamic) size of primitive.

Parameters:
i - int
Returns:
sizeof(int)

inst

public static int inst(long l)
Return (dynamic) size of primitive.

Parameters:
l - long
Returns:
sizeof(long)

inst

public static int inst(float f)
Return (dynamic) size of primitive.

Parameters:
f - float
Returns:
sizeof(float)

inst

public static int inst(double d)
Return (dynamic) size of primitive.

Parameters:
d - double
Returns:
sizeof(double)

inst

public static int inst(java.lang.Object obj)
Return (dynamic) size of object instance.

Parameters:
obj - object to size
Returns:
size of object

array

private static int array(java.lang.Object obj)
Return (dynamic) size of an array.

Parameters:
obj - array to compute size
Returns:
size of an array

type

public static int type(java.lang.Class type)
Return static size of non-primitive type (a class/structure).

Parameters:
type - class or structure to compute size
Returns:
size of class or structure

primitive

private static int primitive(java.lang.Class type)
Return static size of primitive type.

Parameters:
type - class of primitive type
Returns:
size of primitive type