Top Description Fields Constructors Methods
org.codehaus.janino

public final Class Descriptor

extends Object
Class Inheritance
Imports
java.util.Collections, .HashMap, .Map, org.codehaus.commons.compiler.InternalCompilerException, org.codehaus.commons.nullanalysis.Nullable

Helper class that defines useful methods for handling "field descriptors" (JVMS 4.3.2) and "method descriptors" (JVMS 4.3.3).

Typical descriptors are:

Field Summary

Modifier and TypeField and Description
public static final String
BOOLEAN

The field descriptor for the primitive type BOOLEAN.

public static final String
BYTE

The field descriptor for the primitive type BYTE.

public static final String
CHAR

The field descriptor for the primitive type CHAR.

private static final Map<String, String>
private static final Map<String, String>
public static final String
DOUBLE

The field descriptor for the primitive type DOUBLE.

public static final String
FLOAT

The field descriptor for the primitive type FLOAT.

public static final String
INT

The field descriptor for the primitive type INT.

public static final String
JAVA_IO_SERIALIZABLE

The field descriptor for the interface java.io.Serializable.

public static final String
JAVA_LANG_ANNOTATION_RETENTION

The field descriptor for the annotation java.lang.annotation.Retention.

public static final String
JAVA_LANG_ASSERTIONERROR

The field descriptor for the class java.lang.AssertionError.

public static final String
JAVA_LANG_BOOLEAN

The field descriptor for the class java.lang.Boolean.

public static final String
JAVA_LANG_BYTE

The field descriptor for the class java.lang.Byte.

public static final String
JAVA_LANG_CHARACTER

The field descriptor for the class java.lang.Character.

public static final String
JAVA_LANG_CLASS

The field descriptor for the class java.lang.Class.

public static final String
JAVA_LANG_CLONEABLE

The field descriptor for the interface java.lang.Cloneable.

public static final String
JAVA_LANG_DOUBLE

The field descriptor for the class java.lang.Double.

public static final String
JAVA_LANG_ENUM

The field descriptor for the class java.lang.Enum.

public static final String
JAVA_LANG_ERROR

The field descriptor for the class java.lang.Error.

public static final String
JAVA_LANG_EXCEPTION

The field descriptor for the class java.lang.Exception.

public static final String
JAVA_LANG_FLOAT

The field descriptor for the class java.lang.Float.

public static final String
JAVA_LANG_INTEGER

The field descriptor for the class java.lang.Integer.

public static final String
JAVA_LANG_ITERABLE

The field descriptor for the interface java.lang.Iterable.

public static final String
JAVA_LANG_LONG

The field descriptor for the class java.lang.Long.

public static final String
JAVA_LANG_OBJECT

The field descriptor for the class java.lang.Object.

public static final String
JAVA_LANG_OVERRIDE

The field descriptor for the annotation java.lang.Override.

public static final String
JAVA_LANG_RUNTIMEEXCEPTION

The field descriptor for the class java.lang.RuntimeException.

public static final String
JAVA_LANG_SHORT

The field descriptor for the class java.lang.Short.

public static final String
JAVA_LANG_STRING

The field descriptor for the class java.lang.String.

public static final String
JAVA_LANG_STRINGBUILDER

The field descriptor for the class java.lang.StringBuilder.

public static final String
JAVA_LANG_SYSTEM

The field descriptor for the class java.lang.System.

public static final String
JAVA_LANG_THROWABLE

The field descriptor for the class java.lang.Throwable.

public static final String
JAVA_LANG_VOID

The field descriptor for the class java.lang.Void.

public static final String
JAVA_UTIL_ITERATOR

The field descriptor for the interface java.util.Iterator.

public static final String
LONG

The field descriptor for the primitive type LONG.

public static final String
SHORT

The field descriptor for the primitive type SHORT.

public static final String
VOID

The field descriptor for the type void.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean
areInSamePackage(String d1, String d2)

Checks whether two reference types are declared in the same package.

public static String
fromClassName(String className)

Converts a class name as defined by "Class.getName()" into a descriptor.

public static String
fromInternalForm(String internalForm)

Converts a class name in the "internal form" as described in JVMS 4.2 into a descriptor.

public static String

Returns:

The descriptor of the component of the array type d
getComponentDescriptor
(String d)

public static String
getPackageName(String d)

Returns the package name of a class or interface reference descriptor, or null iff the class or interface is declared in the default package.

public static boolean

Returns:

true iff d describes a primitive type except LONG and DOUBLE, or a reference type
hasSize1
(String d)

public static boolean

Returns:

true iff d LONG or DOUBLE
hasSize2
(String d)

public static boolean

Returns:

Whether this Descriptor describes an array type
isArrayReference
(String d)

public static boolean

Returns:

Whether this Descriptor describes a class or an interface (and not an array or a primitive type)
isClassOrInterfaceReference
(String d)

public static boolean

Returns:

Whether d describes a primitive type or VOID
isPrimitive
(String d)

public static boolean

Returns:

Whether d describes a primitive type except boolean and void
isPrimitiveNumeric
(String d)

public static boolean

Returns:

Whether this Descriptor describes a reference (i.e. non-primitive) type
isReference
(String d)

public static short

Returns:

The number of slots (1 or two) that a value of the type described by d occupies on the operand stack or in the local variable array, or 0 iff d describes the type VOID
size
(String d)

public static String
toClassName(String d)

Converts a field descriptor into a class name as defined by Class#getName().

public static String
toInternalForm(String d)

Converts a descriptor into the "internal form" as defined by JVMS 4.2.

public static String
toString(String
A valid field or method descriptor
d
)

Pretty-prints the given descriptor.

private static int
toString(String d, int idx, StringBuilder sb)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BOOLEANback to summary
public static final String BOOLEAN

The field descriptor for the primitive type BOOLEAN.

BYTEback to summary
public static final String BYTE

The field descriptor for the primitive type BYTE.

CHARback to summary
public static final String CHAR

The field descriptor for the primitive type CHAR.

CLASS_NAME_TO_DESCRIPTORback to summary
private static final Map<String, String> CLASS_NAME_TO_DESCRIPTOR
DESCRIPTOR_TO_CLASSNAMEback to summary
private static final Map<String, String> DESCRIPTOR_TO_CLASSNAME
DOUBLEback to summary
public static final String DOUBLE

The field descriptor for the primitive type DOUBLE.

FLOATback to summary
public static final String FLOAT

The field descriptor for the primitive type FLOAT.

INTback to summary
public static final String INT

The field descriptor for the primitive type INT.

JAVA_IO_SERIALIZABLEback to summary
public static final String JAVA_IO_SERIALIZABLE

The field descriptor for the interface java.io.Serializable.

JAVA_LANG_ANNOTATION_RETENTIONback to summary
public static final String JAVA_LANG_ANNOTATION_RETENTION

The field descriptor for the annotation java.lang.annotation.Retention.

JAVA_LANG_ASSERTIONERRORback to summary
public static final String JAVA_LANG_ASSERTIONERROR

The field descriptor for the class java.lang.AssertionError.

JAVA_LANG_BOOLEANback to summary
public static final String JAVA_LANG_BOOLEAN

The field descriptor for the class java.lang.Boolean.

JAVA_LANG_BYTEback to summary
public static final String JAVA_LANG_BYTE

The field descriptor for the class java.lang.Byte.

JAVA_LANG_CHARACTERback to summary
public static final String JAVA_LANG_CHARACTER

The field descriptor for the class java.lang.Character.

JAVA_LANG_CLASSback to summary
public static final String JAVA_LANG_CLASS

The field descriptor for the class java.lang.Class.

JAVA_LANG_CLONEABLEback to summary
public static final String JAVA_LANG_CLONEABLE

The field descriptor for the interface java.lang.Cloneable.

JAVA_LANG_DOUBLEback to summary
public static final String JAVA_LANG_DOUBLE

The field descriptor for the class java.lang.Double.

JAVA_LANG_ENUMback to summary
public static final String JAVA_LANG_ENUM

The field descriptor for the class java.lang.Enum.

JAVA_LANG_ERRORback to summary
public static final String JAVA_LANG_ERROR

The field descriptor for the class java.lang.Error.

JAVA_LANG_EXCEPTIONback to summary
public static final String JAVA_LANG_EXCEPTION

The field descriptor for the class java.lang.Exception.

JAVA_LANG_FLOATback to summary
public static final String JAVA_LANG_FLOAT

The field descriptor for the class java.lang.Float.

JAVA_LANG_INTEGERback to summary
public static final String JAVA_LANG_INTEGER

The field descriptor for the class java.lang.Integer.

JAVA_LANG_ITERABLEback to summary
public static final String JAVA_LANG_ITERABLE

The field descriptor for the interface java.lang.Iterable.

JAVA_LANG_LONGback to summary
public static final String JAVA_LANG_LONG

The field descriptor for the class java.lang.Long.

JAVA_LANG_OBJECTback to summary
public static final String JAVA_LANG_OBJECT

The field descriptor for the class java.lang.Object.

JAVA_LANG_OVERRIDEback to summary
public static final String JAVA_LANG_OVERRIDE

The field descriptor for the annotation java.lang.Override.

JAVA_LANG_RUNTIMEEXCEPTIONback to summary
public static final String JAVA_LANG_RUNTIMEEXCEPTION

The field descriptor for the class java.lang.RuntimeException.

JAVA_LANG_SHORTback to summary
public static final String JAVA_LANG_SHORT

The field descriptor for the class java.lang.Short.

JAVA_LANG_STRINGback to summary
public static final String JAVA_LANG_STRING

The field descriptor for the class java.lang.String.

JAVA_LANG_STRINGBUILDERback to summary
public static final String JAVA_LANG_STRINGBUILDER

The field descriptor for the class java.lang.StringBuilder.

JAVA_LANG_SYSTEMback to summary
public static final String JAVA_LANG_SYSTEM

The field descriptor for the class java.lang.System.

JAVA_LANG_THROWABLEback to summary
public static final String JAVA_LANG_THROWABLE

The field descriptor for the class java.lang.Throwable.

JAVA_LANG_VOIDback to summary
public static final String JAVA_LANG_VOID

The field descriptor for the class java.lang.Void.

JAVA_UTIL_ITERATORback to summary
public static final String JAVA_UTIL_ITERATOR

The field descriptor for the interface java.util.Iterator.

LONGback to summary
public static final String LONG

The field descriptor for the primitive type LONG.

SHORTback to summary
public static final String SHORT

The field descriptor for the primitive type SHORT.

VOIDback to summary
public static final String VOID

The field descriptor for the type void.

Constructor Detail

Descriptorback to summary
private Descriptor()

Method Detail

areInSamePackageback to summary
public static boolean areInSamePackage(String d1, String d2)

Checks whether two reference types are declared in the same package.

fromClassNameback to summary
public static String fromClassName(String className)

Converts a class name as defined by "Class.getName()" into a descriptor.

fromInternalFormback to summary
public static String fromInternalForm(String internalForm)

Converts a class name in the "internal form" as described in JVMS 4.2 into a descriptor.

Also implements the encoding of array types as described in JVMS 4.4.1.

getComponentDescriptorback to summary
public static String getComponentDescriptor(String d)
Returns:String

The descriptor of the component of the array type d

Exceptions
InternalCompilerException:
d does not describe an array type
getPackageNameback to summary
public static String getPackageName(String d)

Returns the package name of a class or interface reference descriptor, or null iff the class or interface is declared in the default package.

Annotations
@Nullable
hasSize1back to summary
public static boolean hasSize1(String d)
Returns:boolean

true iff d describes a primitive type except LONG and DOUBLE, or a reference type

hasSize2back to summary
public static boolean hasSize2(String d)
Returns:boolean

true iff d LONG or DOUBLE

isArrayReferenceback to summary
public static boolean isArrayReference(String d)
Returns:boolean

Whether this Descriptor describes an array type

isClassOrInterfaceReferenceback to summary
public static boolean isClassOrInterfaceReference(String d)
Returns:boolean

Whether this Descriptor describes a class or an interface (and not an array or a primitive type)

isPrimitiveback to summary
public static boolean isPrimitive(String d)
Returns:boolean

Whether d describes a primitive type or VOID

isPrimitiveNumericback to summary
public static boolean isPrimitiveNumeric(String d)
Returns:boolean

Whether d describes a primitive type except boolean and void

isReferenceback to summary
public static boolean isReference(String d)
Returns:boolean

Whether this Descriptor describes a reference (i.e. non-primitive) type

sizeback to summary
public static short size(String d)
Returns:short

The number of slots (1 or two) that a value of the type described by d occupies on the operand stack or in the local variable array, or 0 iff d describes the type VOID

toClassNameback to summary
public static String toClassName(String d)

Converts a field descriptor into a class name as defined by Class#getName().

toInternalFormback to summary
public static String toInternalForm(String d)

Converts a descriptor into the "internal form" as defined by JVMS 4.2.

toStringback to summary
public static String toString(String d)

Pretty-prints the given descriptor.

Parameters
d:String

A valid field or method descriptor

toStringback to summary
private static int toString(String d, int idx, StringBuilder sb)