com.claritysys.jvm.classfile
Class SigConverter

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

public class SigConverter
extends java.lang.Object

Manages the conversion between Java-friendly type signatures and VM format signatures.

Eg, the Java-friendly signature

   "@Class.forName(String)Class"
 
will be converted to the VM format:
   "java/lang/Class.forName (Ljava/lang/String;)Ljava/lang/Class;".
 

This is an optional feature of the JVM package which really simplifies generating classes, at a small performance cost.


Constructor Summary
SigConverter()
          Create a new SigConverter with only the primitive types initially.
SigConverter(SigConverter template)
          Create a SigConverter with all the mappings from the given one (eg, create a clone).
 
Method Summary
 java.lang.String addImport(java.lang.String cls)
          Import the given class, returning its short name.
 void dumpAliases()
          Dump imports to System.out.
 java.lang.String[] getArgTypes(java.lang.String sig)
          Parse the arg types of the method signature.
 java.lang.String getFullName(java.lang.String cls)
          Return the full name for the given short name.
 java.lang.String getReturnType(java.lang.String sig)
          Parse the return type of the method signature.
 java.lang.String getType(java.lang.String javaType)
          Return the VM type for the given Java-friendly type.
 java.lang.String toVmMethodSig(java.lang.String jlSig)
          Convert the given Java Language formed signature into a VM-style signature.
static java.lang.String toVmSig(java.lang.String rtype, java.lang.String[] ptypes)
          Convert type and param types to method signature in VM format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SigConverter

public SigConverter()
Create a new SigConverter with only the primitive types initially.


SigConverter

public SigConverter(SigConverter template)
Create a SigConverter with all the mappings from the given one (eg, create a clone).

Method Detail

addImport

public java.lang.String addImport(java.lang.String cls)
Import the given class, returning its short name.

Parameters:
cls - The fully qualified name of the class in either VM or JLS format (eg, "java/lang/String" or "java.lang.String").
Returns:
The "alias" or short name for the given class, such as String for java.lang.String.

getFullName

public java.lang.String getFullName(java.lang.String cls)
Return the full name for the given short name.


toVmMethodSig

public java.lang.String toVmMethodSig(java.lang.String jlSig)
Convert the given Java Language formed signature into a VM-style signature.

Eg, "(int[],boolean,String)boolean" --> "([IZLjava/lang/String;)Z"


toVmSig

public static java.lang.String toVmSig(java.lang.String rtype,
                                       java.lang.String[] ptypes)
Convert type and param types to method signature in VM format.


getType

public java.lang.String getType(java.lang.String javaType)
Return the VM type for the given Java-friendly type.

Parses random JL-formed declarations:

int, boolean, Object, com.foo.Bar, int[], etc.


getReturnType

public java.lang.String getReturnType(java.lang.String sig)
Parse the return type of the method signature. (int[], boolean, foobar.wassup,thingamajig)Object


getArgTypes

public java.lang.String[] getArgTypes(java.lang.String sig)
Parse the arg types of the method signature.


dumpAliases

public void dumpAliases()
Dump imports to System.out.



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