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:
IInteger[IArray of integerLpkg1/pkg2/Cls;ClassLpkg1/pkg2/Outer$Inner;Member class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe field descriptor for the primitive type BOOLEAN.static final StringThe field descriptor for the primitive type BYTE.static final StringThe field descriptor for the primitive type CHAR.static final StringThe field descriptor for the primitive type DOUBLE.static final StringThe field descriptor for the primitive type FLOAT.static final StringThe field descriptor for the primitive type INT.static final StringThe field descriptor for the interfaceSerializable.static final StringThe field descriptor for the wrapper classAssertionError.static final StringThe field descriptor for the wrapper classBoolean.static final StringThe field descriptor for the wrapper classByte.static final StringThe field descriptor for the wrapper classCharacter.static final StringThe field descriptor for the classClass.static final StringThe field descriptor for the interfaceCloneable.static final StringThe field descriptor for the wrapper classDouble.static final StringThe field descriptor for the classError.static final StringThe field descriptor for the wrapper classFloat.static final StringThe field descriptor for the wrapper classInteger.static final StringThe field descriptor for the wrapper classLong.static final StringThe field descriptor for the classObject.static final StringThe field descriptor for the annotationOverride.static final StringThe field descriptor for the classRuntimeException.static final StringThe field descriptor for the wrapper classShort.static final StringThe field descriptor for the classString.static final StringThe field descriptor for the classStringBuilder.static final StringThe field descriptor for the classThrowable.static final StringThe field descriptor for the primitive type LONG.static final StringThe field descriptor for the primitive type SHORT.static final StringThe field descriptor for the type VOID. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareInSamePackage(String d1, String d2) Check whether two reference types are declared in the same package.static StringfromClassName(String className) Convert 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 Stringstatic StringReturns the package name of a class or interface reference descriptor, ornullif the class or interface is declared in the default package.static booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic shortstatic StringConvert a field descriptor into a class name as defined byClass.getName().static StringConvert a descriptor into the "internal form" as defined by JVMS 4.2.static StringPretty-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
Descriptordescribes a reference (i.e. non-primitive) type
-
isClassOrInterfaceReference
- Returns:
- Whether this
Descriptordescribes a class or an interface (and not an array or a primitive type)
-
isArrayReference
- Returns:
- Whether this
Descriptordescribes an array type
-
getComponentDescriptor
- Returns:
- The descriptor of the component of the array type
d - Throws:
JaninoRuntimeException-ddoes not describe an array type
-
size
- 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
- Returns:
trueiffddescribes a primitive type except LONG and DOUBLE, or a reference type
-
hasSize2
- Returns:
trueiffdLONG 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
ddescribes a primitive type or VOID
-
isPrimitiveNumeric
- Returns:
- Whether
ddescribes a primitive type except BOOLEAN and VOID
-
getPackageName
Returns the package name of a class or interface reference descriptor, ornullif the class or interface is declared in the default package. -
areInSamePackage
Check whether two reference types are declared in the same package.
-