Class SignatureParser
java.lang.Object
org.codehaus.janino.util.signature.SignatureParser
Helper class for parsing signatures and descriptors. See
Java 5 class file format,
section 4.4.4, "Signatures".
The various structures that the parser returns (e.g. SignatureParser.ClassTypeSignature
) all have Object.toString()
methods that convert them into nice, human-readable strings. This conversion can be customized
using SignatureParser(Options)
and passing a custom SignatureParser.Options
object.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Representation of the "ArrayTypeSignature" clause.static class
Representation of the "ClassSignature" clause.static class
Representation of the "ClassTypeSignature" clause, e.g.static interface
Representation of the "FieldTypeSignature" clause.static interface
static class
Representation of the "FormalTypeParameter" clause, e.g.static class
Representation of the "MethodTypeSignature" clause.static interface
static class
Representation of the "PrimitiveTypeSignature" clause, i.e.static class
Signalizes am malformed signature.static class
Representation of the "SimpleClassTypeSignature" clause, e.g.static interface
Representation of the "ThrowsSignature" clause.static class
Representation of the "TypeArgument" clause.static interface
Representation of the "TypeSignature" clause.static class
Representation of the "TypeVariableSignature" clause, e.g. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SignatureParser.PrimitiveTypeSignature
The primitive 'boolean
' type.static final SignatureParser.PrimitiveTypeSignature
The primitive 'byte
' type.static final SignatureParser.PrimitiveTypeSignature
The primitive 'char
' type.static final SignatureParser.Options
A trivial implementation ofSignatureParser.Options
.static final SignatureParser.PrimitiveTypeSignature
The primitive 'double
' type.static final SignatureParser.PrimitiveTypeSignature
The primitive 'float
' type.static final SignatureParser.PrimitiveTypeSignature
The primitive 'int
' type.static final SignatureParser.PrimitiveTypeSignature
The primitive 'long
' type.The class type signature of theObject
class.private SignatureParser.Options
private static final SignatureParser.PrimitiveTypeSignature[]
static final SignatureParser.PrimitiveTypeSignature
The primitive 'short
' type.static final SignatureParser.TypeSignature
Representation of the 'void' type. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate SignatureParser.TypeSignature
decodeClassName
(String internalName) Decodes a "class-name-or-field-descriptor" as defined in JLS8 4.4.1 ("name_index").Decodes a 'class signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.Decodes a 'field descriptor' as defined in JLS7 4.3.2.Decodes a 'field type signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.Decodes a 'method descriptor' as defined in JVMS[78] 4.3.3.Decodes a 'method type signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.Decodes a 'return type' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.Decodes a 'type signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.private SignatureParser.ClassSignature
private SignatureParser.TypeSignature
private static String
private static String
private SignatureParser.TypeSignature
private SignatureParser.ThrowsSignature
private SignatureParser.TypeArgument
private SignatureParser.TypeSignature
private static SignatureParser.TypeVariableSignature
-
Field Details
-
DEFAULT_OPTIONS
A trivial implementation ofSignatureParser.Options
. -
options
-
object
The class type signature of theObject
class. -
BYTE
The primitive 'byte
' type. -
CHAR
The primitive 'char
' type. -
DOUBLE
The primitive 'double
' type. -
FLOAT
The primitive 'float
' type. -
INT
The primitive 'int
' type. -
LONG
The primitive 'long
' type. -
SHORT
The primitive 'short
' type. -
BOOLEAN
The primitive 'boolean
' type. -
VOID
Representation of the 'void' type. -
PRIMITIVE_TYPES
-
-
Constructor Details
-
SignatureParser
public SignatureParser() -
SignatureParser
-
-
Method Details
-
decodeClassSignature
public SignatureParser.ClassSignature decodeClassSignature(String s) throws SignatureParser.SignatureException Decodes a 'class signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1. -
decodeMethodTypeSignature
public SignatureParser.MethodTypeSignature decodeMethodTypeSignature(String s) throws SignatureParser.SignatureException Decodes a 'method type signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1. -
decodeTypeSignature
public SignatureParser.TypeSignature decodeTypeSignature(String s) throws SignatureParser.SignatureException Decodes a 'type signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1. -
decodeFieldTypeSignature
public SignatureParser.FieldTypeSignature decodeFieldTypeSignature(String s) throws SignatureParser.SignatureException Decodes a 'field type signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1. -
decodeMethodDescriptor
public SignatureParser.MethodTypeSignature decodeMethodDescriptor(String s) throws SignatureParser.SignatureException Decodes a 'method descriptor' as defined in JVMS[78] 4.3.3.- Returns:
- E.g.
"(Object[]) => java.util.stream.Stream"
or"join()"
(void method) - Throws:
SignatureParser.SignatureException
-
decodeClassName
-
decodeFieldDescriptor
public SignatureParser.TypeSignature decodeFieldDescriptor(String s) throws SignatureParser.SignatureException Decodes a 'field descriptor' as defined in JLS7 4.3.2. -
decodeClassNameOrFieldDescriptor
public SignatureParser.TypeSignature decodeClassNameOrFieldDescriptor(String s) throws SignatureParser.SignatureException Decodes a "class-name-or-field-descriptor" as defined in JLS8 4.4.1 ("name_index"). -
decodeReturnType
public SignatureParser.TypeSignature decodeReturnType(String s) throws SignatureParser.SignatureException Decodes a 'return type' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1. -
parseFieldDescriptor
private SignatureParser.TypeSignature parseFieldDescriptor(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseMethodDescriptor
private SignatureParser.MethodTypeSignature parseMethodDescriptor(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseClassSignature
private SignatureParser.ClassSignature parseClassSignature(StringCharStream scs) throws EOFException, SignatureParser.SignatureException, UnexpectedCharacterException -
parseMethodTypeSignature
private SignatureParser.MethodTypeSignature parseMethodTypeSignature(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseReturnType
private SignatureParser.TypeSignature parseReturnType(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseThrowsSignature
private SignatureParser.ThrowsSignature parseThrowsSignature(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseClassTypeSignature
private SignatureParser.ClassTypeSignature parseClassTypeSignature(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseIdentifier
private static String parseIdentifier(StringCharStream scs) throws EOFException, SignatureParser.SignatureException -
parseIdentifierRest
private static String parseIdentifierRest(StringCharStream scs) throws EOFException, SignatureParser.SignatureException -
parseTypeVariableSignature
private static SignatureParser.TypeVariableSignature parseTypeVariableSignature(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseFormalTypeParameter
private SignatureParser.FormalTypeParameter parseFormalTypeParameter(StringCharStream scs) throws EOFException, SignatureParser.SignatureException, UnexpectedCharacterException -
parseTypeSignature
private SignatureParser.TypeSignature parseTypeSignature(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseFieldTypeSignature
private SignatureParser.FieldTypeSignature parseFieldTypeSignature(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseArrayTypeSignature
private SignatureParser.FieldTypeSignature parseArrayTypeSignature(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException -
parseTypeArgument
private SignatureParser.TypeArgument parseTypeArgument(StringCharStream scs) throws EOFException, UnexpectedCharacterException, SignatureParser.SignatureException
-