Package org.codehaus.janino
Class Descriptor
java.lang.Object
org.codehaus.janino.Descriptor
Helper class that defines useful methods for handling "field descriptors"
(JVMS 4.3.2) and "method descriptors" (JVMS 4.3.3).
Typical descriptors are:
I
Integer[I
Array of integerLpkg1/pkg2/Cls;
ClassLpkg1/pkg2/Outer$Inner;
Member class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The field descriptor for the primitive type BOOLEAN.static final String
The field descriptor for the primitive type BYTE.static final String
The field descriptor for the primitive type CHAR.static final String
The field descriptor for the primitive type DOUBLE.static final String
The field descriptor for the primitive type FLOAT.static final String
The field descriptor for the primitive type INT.static final String
The field descriptor for the interfaceSerializable
.static final String
The field descriptor for the wrapper classAssertionError
.static final String
The field descriptor for the wrapper classBoolean
.static final String
The field descriptor for the wrapper classByte
.static final String
The field descriptor for the wrapper classCharacter
.static final String
The field descriptor for the classClass
.static final String
The field descriptor for the interfaceCloneable
.static final String
The field descriptor for the wrapper classDouble
.static final String
The field descriptor for the classError
.static final String
The field descriptor for the wrapper classFloat
.static final String
The field descriptor for the wrapper classInteger
.static final String
The field descriptor for the wrapper classLong
.static final String
The field descriptor for the classObject
.static final String
The field descriptor for the annotationOverride
.static final String
The field descriptor for the classRuntimeException
.static final String
The field descriptor for the wrapper classShort
.static final String
The field descriptor for the classString
.static final String
The field descriptor for the classStringBuilder
.static final String
The field descriptor for the classThrowable
.static final String
The field descriptor for the primitive type LONG.static final String
The field descriptor for the primitive type SHORT.static final String
The field descriptor for the type VOID. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
areInSamePackage
(String d1, String d2) Check whether two reference types are declared in the same package.static String
fromClassName
(String className) Convert a class name as defined by "Class.getName()" into a descriptor.static String
fromInternalForm
(String internalForm) Convert a class name in the "internal form" as described in JVMS 4.2 into a descriptor.static String
static String
Returns the package name of a class or interface reference descriptor, ornull
if the class or interface is declared in the default package.static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
static short
static String
Convert a field descriptor into a class name as defined byClass.getName()
.static String
Convert a descriptor into the "internal form" as defined by JVMS 4.2.static String
Pretty-prints the given descriptor.
-
Field Details
-
VOID
The field descriptor for the type VOID.- See Also:
-
BYTE
The field descriptor for the primitive type BYTE.- See Also:
-
CHAR
The field descriptor for the primitive type CHAR.- See Also:
-
DOUBLE
The field descriptor for the primitive type DOUBLE.- See Also:
-
FLOAT
The field descriptor for the primitive type FLOAT.- See Also:
-
INT
The field descriptor for the primitive type INT.- See Also:
-
LONG
The field descriptor for the primitive type LONG.- See Also:
-
SHORT
The field descriptor for the primitive type SHORT.- See Also:
-
BOOLEAN
The field descriptor for the primitive type BOOLEAN.- See Also:
-
JAVA_LANG_OBJECT
The field descriptor for the classObject
.- See Also:
-
JAVA_LANG_STRING
The field descriptor for the classString
.- See Also:
-
JAVA_LANG_STRINGBUILDER
The field descriptor for the classStringBuilder
.- See Also:
-
JAVA_LANG_CLASS
The field descriptor for the classClass
.- See Also:
-
JAVA_LANG_THROWABLE
The field descriptor for the classThrowable
.- See Also:
-
JAVA_LANG_RUNTIMEEXCEPTION
The field descriptor for the classRuntimeException
.- See Also:
-
JAVA_LANG_ERROR
The field descriptor for the classError
.- See Also:
-
JAVA_LANG_CLONEABLE
The field descriptor for the interfaceCloneable
.- See Also:
-
JAVA_LANG_OVERRIDE
The field descriptor for the annotationOverride
.- See Also:
-
JAVA_IO_SERIALIZABLE
The field descriptor for the interfaceSerializable
.- See Also:
-
JAVA_LANG_ASSERTIONERROR
The field descriptor for the wrapper classAssertionError
.- See Also:
-
JAVA_LANG_BOOLEAN
The field descriptor for the wrapper classBoolean
.- See Also:
-
JAVA_LANG_BYTE
The field descriptor for the wrapper classByte
.- See Also:
-
JAVA_LANG_CHARACTER
The field descriptor for the wrapper classCharacter
.- See Also:
-
JAVA_LANG_SHORT
The field descriptor for the wrapper classShort
.- See Also:
-
JAVA_LANG_INTEGER
The field descriptor for the wrapper classInteger
.- See Also:
-
JAVA_LANG_LONG
The field descriptor for the wrapper classLong
.- See Also:
-
JAVA_LANG_FLOAT
The field descriptor for the wrapper classFloat
.- See Also:
-
JAVA_LANG_DOUBLE
The field descriptor for the wrapper classDouble
.- See Also:
-
-
Method Details
-
isReference
- Returns:
- Whether this
Descriptor
describes a reference (i.e. non-primitive) type
-
isClassOrInterfaceReference
- Returns:
- Whether this
Descriptor
describes a class or an interface (and not an array or a primitive type)
-
isArrayReference
- Returns:
- Whether this
Descriptor
describes an array type
-
getComponentDescriptor
- Returns:
- The descriptor of the component of the array type
d
- Throws:
JaninoRuntimeException
-d
does not describe an array type
-
size
- 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 iffd
describes the type VOID
-
hasSize1
- Returns:
true
iffd
describes a primitive type except LONG and DOUBLE, or a reference type
-
hasSize2
- Returns:
true
iffd
LONG or DOUBLE
-
toString
Pretty-prints the given descriptor.- Parameters:
d
- A valid field or method descriptor
-
fromClassName
Convert a class name as defined by "Class.getName()" into a descriptor. -
fromInternalForm
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
Convert a field descriptor into a class name as defined byClass.getName()
. -
toInternalForm
Convert a descriptor into the "internal form" as defined by JVMS 4.2. -
isPrimitive
- Returns:
- Whether
d
describes a primitive type or VOID
-
isPrimitiveNumeric
- Returns:
- Whether
d
describes a primitive type except BOOLEAN and VOID
-
getPackageName
Returns the package name of a class or interface reference descriptor, ornull
if the class or interface is declared in the default package. -
areInSamePackage
Check whether two reference types are declared in the same package.
-