Class SignatureParser
- java.lang.Object
-
- org.codehaus.janino.util.signature.SignatureParser
-
public class SignatureParser extends java.lang.Object
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 haveObject.toString()
methods that convert them into nice, human-readable strings. This conversion can be customized usingSignatureParser(Options)
and passing a customSignatureParser.Options
object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SignatureParser.ArrayTypeSignature
Representation of the "ArrayTypeSignature" clause.static class
SignatureParser.ClassSignature
Representation of the "ClassSignature" clause.static class
SignatureParser.ClassTypeSignature
Representation of the "ClassTypeSignature" clause, e.gstatic interface
SignatureParser.FieldTypeSignature
Representation of the "FieldTypeSignature" clause.static interface
SignatureParser.FieldTypeSignatureVisitor<T,EX extends java.lang.Throwable>
static class
SignatureParser.FormalTypeParameter
Representation of the "FormalTypeParameter" clause, e.gstatic class
SignatureParser.MethodTypeSignature
Representation of the "MethodTypeSignature" clause.static interface
SignatureParser.Options
static class
SignatureParser.PrimitiveTypeSignature
Representation of the "PrimitiveTypeSignature" clause, i.estatic class
SignatureParser.SignatureException
Signalizes am malformed signature.static class
SignatureParser.SimpleClassTypeSignature
Representation of the "SimpleClassTypeSignature" clause, e.gstatic interface
SignatureParser.ThrowsSignature
Representation of the "ThrowsSignature" clause.static class
SignatureParser.TypeArgument
Representation of the "TypeArgument" clause.static interface
SignatureParser.TypeSignature
Representation of the "TypeSignature" clause.static class
SignatureParser.TypeVariableSignature
Representation of the "TypeVariableSignature" clause, e.g
-
Field Summary
Fields Modifier and Type Field Description static SignatureParser.PrimitiveTypeSignature
BOOLEAN
The primitive 'boolean
' type.static SignatureParser.PrimitiveTypeSignature
BYTE
The primitive 'byte
' type.static SignatureParser.PrimitiveTypeSignature
CHAR
The primitive 'char
' type.static SignatureParser.Options
DEFAULT_OPTIONS
A trivial implementation ofSignatureParser.Options
.static SignatureParser.PrimitiveTypeSignature
DOUBLE
The primitive 'double
' type.static SignatureParser.PrimitiveTypeSignature
FLOAT
The primitive 'float
' type.static SignatureParser.PrimitiveTypeSignature
INT
The primitive 'int
' type.static SignatureParser.PrimitiveTypeSignature
LONG
The primitive 'long
' type.SignatureParser.ClassTypeSignature
object
The class type signature of theObject
class.static SignatureParser.PrimitiveTypeSignature
SHORT
The primitive 'short
' type.static SignatureParser.TypeSignature
VOID
Representation of the 'void' type.
-
Constructor Summary
Constructors Constructor Description SignatureParser()
SignatureParser(SignatureParser.Options options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SignatureParser.TypeSignature
decodeClassNameOrFieldDescriptor(java.lang.String s)
Decodes a "class-name-or-field-descriptor" as defined in JLS8 4.4.1 ("name_index").SignatureParser.ClassSignature
decodeClassSignature(java.lang.String s)
Decodes a 'class signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.SignatureParser.TypeSignature
decodeFieldDescriptor(java.lang.String s)
Decodes a 'field descriptor' as defined in JLS7 4.3.2.SignatureParser.FieldTypeSignature
decodeFieldTypeSignature(java.lang.String s)
Decodes a 'field type signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.SignatureParser.MethodTypeSignature
decodeMethodDescriptor(java.lang.String s)
Decodes a 'method descriptor' as defined in JVMS[78] 4.3.3.SignatureParser.MethodTypeSignature
decodeMethodTypeSignature(java.lang.String s)
Decodes a 'method type signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.SignatureParser.TypeSignature
decodeReturnType(java.lang.String s)
Decodes a 'return type' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.SignatureParser.TypeSignature
decodeTypeSignature(java.lang.String s)
Decodes a 'type signature' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.
-
-
-
Field Detail
-
DEFAULT_OPTIONS
public static final SignatureParser.Options DEFAULT_OPTIONS
A trivial implementation ofSignatureParser.Options
.
-
object
public final SignatureParser.ClassTypeSignature object
The class type signature of theObject
class.
-
BYTE
public static final SignatureParser.PrimitiveTypeSignature BYTE
The primitive 'byte
' type.
-
CHAR
public static final SignatureParser.PrimitiveTypeSignature CHAR
The primitive 'char
' type.
-
DOUBLE
public static final SignatureParser.PrimitiveTypeSignature DOUBLE
The primitive 'double
' type.
-
FLOAT
public static final SignatureParser.PrimitiveTypeSignature FLOAT
The primitive 'float
' type.
-
INT
public static final SignatureParser.PrimitiveTypeSignature INT
The primitive 'int
' type.
-
LONG
public static final SignatureParser.PrimitiveTypeSignature LONG
The primitive 'long
' type.
-
SHORT
public static final SignatureParser.PrimitiveTypeSignature SHORT
The primitive 'short
' type.
-
BOOLEAN
public static final SignatureParser.PrimitiveTypeSignature BOOLEAN
The primitive 'boolean
' type.
-
VOID
public static final SignatureParser.TypeSignature VOID
Representation of the 'void' type.
-
-
Constructor Detail
-
SignatureParser
public SignatureParser()
-
SignatureParser
public SignatureParser(SignatureParser.Options options)
-
-
Method Detail
-
decodeClassSignature
public SignatureParser.ClassSignature decodeClassSignature(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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
-
decodeFieldDescriptor
public SignatureParser.TypeSignature decodeFieldDescriptor(java.lang.String s) throws SignatureParser.SignatureException
Decodes a 'field descriptor' as defined in JLS7 4.3.2.
-
decodeClassNameOrFieldDescriptor
public SignatureParser.TypeSignature decodeClassNameOrFieldDescriptor(java.lang.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(java.lang.String s) throws SignatureParser.SignatureException
Decodes a 'return type' as defined in JVMS7 4.3.4 / JVMS8 4.7.9.1.
-
-