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/Clazz;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 annotationRetention.static final StringThe field descriptor for the classAssertionError.static final StringThe field descriptor for the classBoolean.static final StringThe field descriptor for the classByte.static final StringThe field descriptor for the classCharacter.static final StringThe field descriptor for the classClass.static final StringThe field descriptor for the interfaceCloneable.static final StringThe field descriptor for the classDouble.static final StringThe field descriptor for the classEnum.static final StringThe field descriptor for the classError.static final StringThe field descriptor for the classException.static final StringThe field descriptor for the classFloat.static final StringThe field descriptor for the classInteger.static final StringThe field descriptor for the interfaceIterable.static final StringThe field descriptor for the 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 classShort.static final StringThe field descriptor for the classString.static final StringThe field descriptor for the classStringBuilder.static final StringThe field descriptor for the classSystem.static final StringThe field descriptor for the classThrowable.static final StringThe field descriptor for the classVoid.static final StringThe field descriptor for the interfaceIterator.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 typevoid. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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) Converts 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, ornulliff the class or interface is declared in the default package.static booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic shortstatic StringConverts a field descriptor into a class name as defined byClass.getName().static StringConverts a descriptor into the "internal form" as defined by JVMS 4.2.static StringPretty-prints the given descriptor.private static inttoString(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
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:
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:
trueiff d describes a primitive type except LONG and DOUBLE, or a reference type
-
hasSize2
- Returns:
trueiff 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
booleanandvoid
-
getPackageName
Returns the package name of a class or interface reference descriptor, ornulliff the class or interface is declared in the default package. -
areInSamePackage
Checks whether two reference types are declared in the same package.
-