com.claritysys.jvm.classfile
Class Utils

java.lang.Object
  extended by com.claritysys.jvm.classfile.Utils

public final class Utils
extends java.lang.Object


Constructor Summary
Utils()
           
 
Method Summary
static int getMethodReturnType(java.lang.String vmSignature)
          Determine the return type of the method, given its VM signature.
static int getMethodStackWords(java.lang.String vmMethodSig)
          Count the number of stack words needed to hold the parameters for the given method signature.
static int getParameterCount(java.lang.String vmMethodSig)
          Count how many parameters there are in the given method signature.
static java.lang.String[] getParameters(java.lang.String vmMethodSig)
          Return an array of strings representing the individual parameters of the given VM-formatted method signature.
static int getStackWords(int type)
           
static int getStackWords(java.lang.String fieldType)
           
static int parseType(char ch)
           
static int parseType(java.lang.String vmSignature)
          Return one of the JVM.T_XXX constants for the given VM signature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

parseType

public static int parseType(java.lang.String vmSignature)
Return one of the JVM.T_XXX constants for the given VM signature.

For example, if given "I", return JVM.T_INT. If given "Ljava/lang/Object;" return JVM.T_OBJECT.


getStackWords

public static int getStackWords(java.lang.String fieldType)

getStackWords

public static int getStackWords(int type)

parseType

public static int parseType(char ch)

getMethodReturnType

public static int getMethodReturnType(java.lang.String vmSignature)
Determine the return type of the method, given its VM signature.

A VM signature looks like this (some samples):

   (IIZ)V // a method taking (int, int, boolean) and returning void
   ()I    // a method taking no params and return an int
   ()[I   // a method taking no params and returning array of int.
 

Returns:
One of the JVM.T_XXX constants, such as JVM.T_INT.

getMethodStackWords

public static int getMethodStackWords(java.lang.String vmMethodSig)
Count the number of stack words needed to hold the parameters for the given method signature. For each argument, long or double take 2, everything else takes 1.

Because it doesn't know if the method is static, it cannot include the "this", which is always local zero for non-static methods, so be sure to account for that.


getParameters

public static java.lang.String[] getParameters(java.lang.String vmMethodSig)
Return an array of strings representing the individual parameters of the given VM-formatted method signature.

Eg, given a signature "(II)Ljava/lang/String;" return an array with 2 string elements "I" and "I". The return type is discarded.

Parameters:
vmMethodSig - Method signature in VM format (see doc description).
Returns:
Array of String, possible zero length but not null.

getParameterCount

public static int getParameterCount(java.lang.String vmMethodSig)
Count how many parameters there are in the given method signature.

Parameters:
vmMethodSig -
Returns:


Copyright ? 2000-2003 Clarity Systems Group, LLC. All Rights Reserved.