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
-
BYTE
-
CHAR
-
DOUBLE
-
FLOAT
-
INT
-
LONG
-
SHORT
-
BOOLEAN
-
JAVA_LANG_ANNOTATION_RETENTION
-
JAVA_LANG_OVERRIDE
-
JAVA_LANG_ASSERTIONERROR
The field descriptor for the classAssertionError.- See Also:
-
JAVA_LANG_BOOLEAN
-
JAVA_LANG_BYTE
-
JAVA_LANG_CHARACTER
-
JAVA_LANG_CLASS
-
JAVA_LANG_DOUBLE
-
JAVA_LANG_ENUM
-
JAVA_LANG_ERROR
-
JAVA_LANG_EXCEPTION
-
JAVA_LANG_FLOAT
-
JAVA_LANG_INTEGER
-
JAVA_LANG_LONG
-
JAVA_LANG_OBJECT
-
JAVA_LANG_RUNTIMEEXCEPTION
The field descriptor for the classRuntimeException.- See Also:
-
JAVA_LANG_SHORT
-
JAVA_LANG_STRING
-
JAVA_LANG_STRINGBUILDER
The field descriptor for the classStringBuilder.- See Also:
-
JAVA_LANG_SYSTEM
-
JAVA_LANG_THROWABLE
-
JAVA_LANG_VOID
-
JAVA_IO_SERIALIZABLE
The field descriptor for the interfaceSerializable.- See Also:
-
JAVA_LANG_CLONEABLE
-
JAVA_LANG_ITERABLE
-
JAVA_UTIL_ITERATOR
-
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
-
toString
-
fromClassName
-
fromInternalForm
-
toClassName
Converts a field descriptor into a class name as defined byClass.getName(). -
toInternalForm
-
isPrimitive
- Returns:
- Whether d describes a primitive type or VOID
-
isPrimitiveNumeric
- Returns:
- Whether d describes a primitive type except
booleanandvoid
-
getPackageName
-
areInSamePackage
-