Package org.codehaus.janino
Class Descriptor
- java.lang.Object
-
- org.codehaus.janino.Descriptor
-
public final class Descriptor extends Object
Helper class that defines useful methods for handling "field descriptors" (JVMS 4.3.2) and "method descriptors" (JVMS 4.3.3).Typical descriptors are:
IInteger[IArray of integerLpkg1/pkg2/Cls;ClassLpkg1/pkg2/Outer$Inner;Member class
-
-
Field Summary
Fields Modifier and Type Field Description static StringBOOLEANThe field descriptor for the primitive type BOOLEAN.static StringBYTEThe field descriptor for the primitive type BYTE.static StringCHARThe field descriptor for the primitive type CHAR.static StringDOUBLEThe field descriptor for the primitive type DOUBLE.static StringFLOATThe field descriptor for the primitive type FLOAT.static StringINTThe field descriptor for the primitive type INT.static StringJAVA_IO_SERIALIZABLEThe field descriptor for the interfaceSerializable.static StringJAVA_LANG_ASSERTIONERRORThe field descriptor for the classAssertionError.static StringJAVA_LANG_BOOLEANThe field descriptor for the classBoolean.static StringJAVA_LANG_BYTEThe field descriptor for the classByte.static StringJAVA_LANG_CHARACTERThe field descriptor for the classCharacter.static StringJAVA_LANG_CLASSThe field descriptor for the classClass.static StringJAVA_LANG_CLONEABLEThe field descriptor for the interfaceCloneable.static StringJAVA_LANG_DOUBLEThe field descriptor for the classDouble.static StringJAVA_LANG_ERRORThe field descriptor for the classError.static StringJAVA_LANG_EXCEPTIONThe field descriptor for the classException.static StringJAVA_LANG_FLOATThe field descriptor for the classFloat.static StringJAVA_LANG_INTEGERThe field descriptor for the classInteger.static StringJAVA_LANG_ITERABLEThe field descriptor for the interfaceIterable.static StringJAVA_LANG_LONGThe field descriptor for the classLong.static StringJAVA_LANG_OBJECTThe field descriptor for the classObject.static StringJAVA_LANG_OVERRIDEThe field descriptor for the annotationOverride.static StringJAVA_LANG_RUNTIMEEXCEPTIONThe field descriptor for the classRuntimeException.static StringJAVA_LANG_SHORTThe field descriptor for the classShort.static StringJAVA_LANG_STRINGThe field descriptor for the classString.static StringJAVA_LANG_STRINGBUILDERThe field descriptor for the classStringBuilder.static StringJAVA_LANG_THROWABLEThe field descriptor for the classThrowable.static StringJAVA_UTIL_ITERATORThe field descriptor for the interfaceIterator.static StringLONGThe field descriptor for the primitive type LONG.static StringSHORTThe field descriptor for the primitive type SHORT.static StringVOIDThe field descriptor for the type VOID.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanareInSamePackage(String d1, String d2)Checks whether two reference types are declared in the same package.static StringfromClassName(String className)Converts a class name as defined by "Class.getName()" into a descriptor.static StringfromInternalForm(String internalForm)Convert a class name in the "internal form" as described in JVMS 4.2 into a descriptor.static StringgetComponentDescriptor(String d)static StringgetPackageName(String d)Returns the package name of a class or interface reference descriptor, ornullif the class or interface is declared in the default package.static booleanhasSize1(String d)static booleanhasSize2(String d)static booleanisArrayReference(String d)static booleanisClassOrInterfaceReference(String d)static booleanisPrimitive(String d)static booleanisPrimitiveNumeric(String d)static booleanisReference(String d)static shortsize(String d)static StringtoClassName(String d)Converts a field descriptor into a class name as defined byClass.getName().static StringtoInternalForm(String d)Converts a descriptor into the "internal form" as defined by JVMS 4.2.static StringtoString(String d)Pretty-prints the given descriptor.
-
-
-
Field Detail
-
VOID
public static final String VOID
The field descriptor for the type VOID.- See Also:
- Constant Field Values
-
BYTE
public static final String BYTE
The field descriptor for the primitive type BYTE.- See Also:
- Constant Field Values
-
CHAR
public static final String CHAR
The field descriptor for the primitive type CHAR.- See Also:
- Constant Field Values
-
DOUBLE
public static final String DOUBLE
The field descriptor for the primitive type DOUBLE.- See Also:
- Constant Field Values
-
FLOAT
public static final String FLOAT
The field descriptor for the primitive type FLOAT.- See Also:
- Constant Field Values
-
INT
public static final String INT
The field descriptor for the primitive type INT.- See Also:
- Constant Field Values
-
LONG
public static final String LONG
The field descriptor for the primitive type LONG.- See Also:
- Constant Field Values
-
SHORT
public static final String SHORT
The field descriptor for the primitive type SHORT.- See Also:
- Constant Field Values
-
BOOLEAN
public static final String BOOLEAN
The field descriptor for the primitive type BOOLEAN.- See Also:
- Constant Field Values
-
JAVA_LANG_OVERRIDE
public static final String JAVA_LANG_OVERRIDE
The field descriptor for the annotationOverride.- See Also:
- Constant Field Values
-
JAVA_LANG_ASSERTIONERROR
public static final String JAVA_LANG_ASSERTIONERROR
The field descriptor for the classAssertionError.- See Also:
- Constant Field Values
-
JAVA_LANG_BOOLEAN
public static final String JAVA_LANG_BOOLEAN
The field descriptor for the classBoolean.- See Also:
- Constant Field Values
-
JAVA_LANG_BYTE
public static final String JAVA_LANG_BYTE
The field descriptor for the classByte.- See Also:
- Constant Field Values
-
JAVA_LANG_CHARACTER
public static final String JAVA_LANG_CHARACTER
The field descriptor for the classCharacter.- See Also:
- Constant Field Values
-
JAVA_LANG_CLASS
public static final String JAVA_LANG_CLASS
The field descriptor for the classClass.- See Also:
- Constant Field Values
-
JAVA_LANG_DOUBLE
public static final String JAVA_LANG_DOUBLE
The field descriptor for the classDouble.- See Also:
- Constant Field Values
-
JAVA_LANG_EXCEPTION
public static final String JAVA_LANG_EXCEPTION
The field descriptor for the classException.- See Also:
- Constant Field Values
-
JAVA_LANG_ERROR
public static final String JAVA_LANG_ERROR
The field descriptor for the classError.- See Also:
- Constant Field Values
-
JAVA_LANG_FLOAT
public static final String JAVA_LANG_FLOAT
The field descriptor for the classFloat.- See Also:
- Constant Field Values
-
JAVA_LANG_INTEGER
public static final String JAVA_LANG_INTEGER
The field descriptor for the classInteger.- See Also:
- Constant Field Values
-
JAVA_LANG_LONG
public static final String JAVA_LANG_LONG
The field descriptor for the classLong.- See Also:
- Constant Field Values
-
JAVA_LANG_OBJECT
public static final String JAVA_LANG_OBJECT
The field descriptor for the classObject.- See Also:
- Constant Field Values
-
JAVA_LANG_RUNTIMEEXCEPTION
public static final String JAVA_LANG_RUNTIMEEXCEPTION
The field descriptor for the classRuntimeException.- See Also:
- Constant Field Values
-
JAVA_LANG_SHORT
public static final String JAVA_LANG_SHORT
The field descriptor for the classShort.- See Also:
- Constant Field Values
-
JAVA_LANG_STRING
public static final String JAVA_LANG_STRING
The field descriptor for the classString.- See Also:
- Constant Field Values
-
JAVA_LANG_STRINGBUILDER
public static final String JAVA_LANG_STRINGBUILDER
The field descriptor for the classStringBuilder.- See Also:
- Constant Field Values
-
JAVA_LANG_THROWABLE
public static final String JAVA_LANG_THROWABLE
The field descriptor for the classThrowable.- See Also:
- Constant Field Values
-
JAVA_IO_SERIALIZABLE
public static final String JAVA_IO_SERIALIZABLE
The field descriptor for the interfaceSerializable.- See Also:
- Constant Field Values
-
JAVA_LANG_CLONEABLE
public static final String JAVA_LANG_CLONEABLE
The field descriptor for the interfaceCloneable.- See Also:
- Constant Field Values
-
JAVA_LANG_ITERABLE
public static final String JAVA_LANG_ITERABLE
The field descriptor for the interfaceIterable.- See Also:
- Constant Field Values
-
JAVA_UTIL_ITERATOR
public static final String JAVA_UTIL_ITERATOR
The field descriptor for the interfaceIterator.- See Also:
- Constant Field Values
-
-
Method Detail
-
isReference
public static boolean isReference(String d)
- Returns:
- Whether this
Descriptordescribes a reference (i.e. non-primitive) type
-
isClassOrInterfaceReference
public static boolean isClassOrInterfaceReference(String d)
- Returns:
- Whether this
Descriptordescribes a class or an interface (and not an array or a primitive type)
-
isArrayReference
public static boolean isArrayReference(String d)
- Returns:
- Whether this
Descriptordescribes an array type
-
getComponentDescriptor
public static String getComponentDescriptor(String d)
- Returns:
- The descriptor of the component of the array type
d - Throws:
JaninoRuntimeException-ddoes not describe an array type
-
size
public static short size(String d)
- Returns:
- The number of slots (1 or two) that a value of the type described by
doccupies on the operand stack or in the local variable array, or 0 iffddescribes the type VOID
-
hasSize1
public static boolean hasSize1(String d)
- Returns:
trueiffddescribes a primitive type except LONG and DOUBLE, or a reference type
-
hasSize2
public static boolean hasSize2(String d)
- Returns:
trueiffdLONG or DOUBLE
-
toString
public static String toString(String d)
Pretty-prints the given descriptor.- Parameters:
d- A valid field or method descriptor
-
fromClassName
public static String fromClassName(String className)
Converts a class name as defined by "Class.getName()" into a descriptor.
-
fromInternalForm
public static String fromInternalForm(String internalForm)
Convert a class name in the "internal form" as described in JVMS 4.2 into a descriptor.Also implement the encoding of array types as described in JVMS 4.4.1.
-
toClassName
public static String toClassName(String d)
Converts a field descriptor into a class name as defined byClass.getName().
-
toInternalForm
public static String toInternalForm(String d)
Converts a descriptor into the "internal form" as defined by JVMS 4.2.
-
isPrimitive
public static boolean isPrimitive(String d)
- Returns:
- Whether
ddescribes a primitive type or VOID
-
isPrimitiveNumeric
public static boolean isPrimitiveNumeric(String d)
- Returns:
- Whether
ddescribes a primitive type except BOOLEAN and VOID
-
getPackageName
public static String getPackageName(String d)
Returns the package name of a class or interface reference descriptor, ornullif the class or interface is declared in the default package.
-
-