joeq.Util
Class DescriptorUtil

java.lang.Object
  extended by joeq.Util.DescriptorUtil

public class DescriptorUtil
extends Object

The signature of a method that is available from the BCEL library uses descriptors as defined in Section 4.3 of the Java Virtual Machine specificaiton. Javadoc and Java do not use signatures in this same format. This class converts the Javadoc/Java signature format to that used by the JVM spec. To summarize the descriptors A method descriptor represents the parameters that the method takes and the value that it returns:

MethodDescriptor: ( ParameterDescriptor* ) ReturnDescriptor

A parameter descriptor represents a parameter passed to a method:

ParameterDescriptor: FieldType

A return descriptor represents the type of the value returned from a method. It is a series of characters generated by the grammar:

ReturnDescriptor: FieldType V

The character V indicates that the method returns no value (its return type is void).

A field descriptor represents the type of a class, instance, or local variable. It is a series of characters generated by the grammar:

FieldDescriptor: FieldType

ComponentType: FieldType

FieldType: BaseType ObjectType ArrayType

BaseType: B C D F I J S Z

ObjectType: L ;

ArrayType: [ ComponentType

The characters of BaseType, the L and ; of ObjectType, and the [ of ArrayType are all ASCII characters. The represents a fully qualified class or interface name. For historical reasons it is encoded in internal form (4.2). The interpretation of the field types is as shown in Table 4.2.

BaseType Character Type Interpretation ---------------------------------------------- B byte signed byte C char Unicode character D double double-precision floating-point value F float single-precision floating-point value I int integer J long long integer L; reference an instance of class S short signed short Z boolean true or false [ reference one array dimension

Author:
Mark Pollack

Constructor Summary
DescriptorUtil()
           
 
Method Summary
static String convert(String javadocSig, String javadocReturnType)
          Converts from the Java/Javadoc method signature the JVM spec format.
static String[] getParameters(String jvmSignature)
          Convert a JVM signature as defined in the JVM spec to that used in the Java.
static int jvmFormatToJavaFormat(String jvmFormat, int i, StringBuffer stringbuffer)
          The utility method that does the real work of parsing through the JVM formatted string and adding an converted method parameter description to the StringBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DescriptorUtil

public DescriptorUtil()
Method Detail

convert

public static String convert(String javadocSig,
                             String javadocReturnType)
Converts from the Java/Javadoc method signature the JVM spec format.

Parameters:
javadocSig - method signature as returned via Javadoc API.
javadocReturnType - return type as returned via Javadoc API.
Returns:
mtehod signature as defined in the JVM spec.

getParameters

public static String[] getParameters(String jvmSignature)
Convert a JVM signature as defined in the JVM spec to that used in the Java.

Parameters:
jvmSignature - The JVM format signature.
Returns:
a String[] containing the method parameter as elements of the array.

jvmFormatToJavaFormat

public static int jvmFormatToJavaFormat(String jvmFormat,
                                        int i,
                                        StringBuffer stringbuffer)
The utility method that does the real work of parsing through the JVM formatted string and adding an converted method parameter description to the StringBuffer.

Parameters:
jvmFormat - The JVM formatted string that is being parsed.
i - The offset into the string being parsed.
stringbuffer - The storage for building the converted method signature.
Returns:
new offset location for parsing.


Copyright © 2001-2008 John Whaley. All Rights Reserved.