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/Clazz;
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 annotationRetention
.static final String
The field descriptor for the classAssertionError
.static final String
The field descriptor for the classBoolean
.static final String
The field descriptor for the classByte
.static final String
The field descriptor for the 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 classDouble
.static final String
The field descriptor for the classEnum
.static final String
The field descriptor for the classError
.static final String
The field descriptor for the classException
.static final String
The field descriptor for the classFloat
.static final String
The field descriptor for the classInteger
.static final String
The field descriptor for the interfaceIterable
.static final String
The field descriptor for the 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 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 classSystem
.static final String
The field descriptor for the classThrowable
.static final String
The field descriptor for the classVoid
.static final String
The field descriptor for the interfaceIterator
.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 typevoid
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
areInSamePackage
(String d1, String d2) Checks whether two reference types are declared in the same package.static String
fromClassName
(String className) Converts a class name as defined by "Class.getName()" into a descriptor.static String
fromInternalForm
(String internalForm) Converts 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
iff 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
Converts a field descriptor into a class name as defined byClass.getName()
.static String
Converts a descriptor into the "internal form" as defined by JVMS 4.2.static String
Pretty-prints the given descriptor.private static int
toString
(String d, int idx, StringBuilder sb)
-
Field Details
-
VOID
The field descriptor for the typevoid
.- 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_ANNOTATION_RETENTION
The field descriptor for the annotationRetention
.- See Also:
-
JAVA_LANG_OVERRIDE
The field descriptor for the annotationOverride
.- See Also:
-
JAVA_LANG_ASSERTIONERROR
The field descriptor for the classAssertionError
.- See Also:
-
JAVA_LANG_BOOLEAN
The field descriptor for the classBoolean
.- See Also:
-
JAVA_LANG_BYTE
The field descriptor for the classByte
.- See Also:
-
JAVA_LANG_CHARACTER
The field descriptor for the classCharacter
.- See Also:
-
JAVA_LANG_CLASS
The field descriptor for the classClass
.- See Also:
-
JAVA_LANG_DOUBLE
The field descriptor for the classDouble
.- See Also:
-
JAVA_LANG_ENUM
The field descriptor for the classEnum
.- See Also:
-
JAVA_LANG_ERROR
The field descriptor for the classError
.- See Also:
-
JAVA_LANG_EXCEPTION
The field descriptor for the classException
.- See Also:
-
JAVA_LANG_FLOAT
The field descriptor for the classFloat
.- See Also:
-
JAVA_LANG_INTEGER
The field descriptor for the classInteger
.- See Also:
-
JAVA_LANG_LONG
The field descriptor for the classLong
.- See Also:
-
JAVA_LANG_OBJECT
The field descriptor for the classObject
.- See Also:
-
JAVA_LANG_RUNTIMEEXCEPTION
The field descriptor for the classRuntimeException
.- See Also:
-
JAVA_LANG_SHORT
The field descriptor for the classShort
.- 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_SYSTEM
The field descriptor for the classSystem
.- See Also:
-
JAVA_LANG_THROWABLE
The field descriptor for the classThrowable
.- See Also:
-
JAVA_LANG_VOID
The field descriptor for the classVoid
.- See Also:
-
JAVA_IO_SERIALIZABLE
The field descriptor for the interfaceSerializable
.- See Also:
-
JAVA_LANG_CLONEABLE
The field descriptor for the interfaceCloneable
.- See Also:
-
JAVA_LANG_ITERABLE
The field descriptor for the interfaceIterable
.- See Also:
-
JAVA_UTIL_ITERATOR
The field descriptor for the interfaceIterator
.- See Also:
-
DESCRIPTOR_TO_CLASSNAME
-
CLASS_NAME_TO_DESCRIPTOR
-
-
Constructor Details
-
Descriptor
private Descriptor()
-
-
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:
InternalCompilerException
- 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 iff d describes the type VOID
-
hasSize1
- Returns:
true
iff d describes a primitive type except LONG and DOUBLE, or a reference type
-
hasSize2
- Returns:
true
iff d LONG or DOUBLE
-
toString
Pretty-prints the given descriptor.- Parameters:
d
- A valid field or method descriptor
-
toString
-
fromClassName
Converts a class name as defined by "Class.getName()" into a descriptor. -
fromInternalForm
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.
-
toClassName
Converts a field descriptor into a class name as defined byClass.getName()
. -
toInternalForm
Converts 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
andvoid
-
getPackageName
Returns the package name of a class or interface reference descriptor, ornull
iff the class or interface is declared in the default package. -
areInSamePackage
Checks whether two reference types are declared in the same package.
-