APIdia Launch Partner
Top Description Fields Constructors Methods
sun.reflect.generics.parser

public Class SignatureParser

extends Object
Class Inheritance
Imports
java.lang.reflect.GenericSignatureFormatError, java.util.*, sun.reflect.generics.tree.*

Parser for type signatures, as defined in the Java Virtual Machine Specification (JVMS) chapter 4. Converts the signatures into an abstract syntax tree (AST) representation. See the package sun.reflect.generics.tree for details of the AST.

Field Summary

Modifier and TypeField and Description
private static final boolean
private static final char
private int
private String
private int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
private char
private Error
error(String errorMsg)

private void
public static SignatureParser

Returns:

an instance of SignatureParser
make
()

Static factory method.

private void
mark()

private String
private ArrayTypeSignature
parseArrayTypeSignature()

ArrayTypeSignature: "[" TypeSignature

private BaseType
private FieldTypeSignature[]
parseBounds()

ClassBound: ":" FieldTypeSignature_opt InterfaceBound: ":" FieldTypeSignature

public ClassSignature

Returns:

An abstract syntax tree for a class signature corresponding to the input string
parseClassSig
(String
a string representing the input class signature
s
)

Parses a class signature (as defined in the JVMS, chapter 4) and produces an abstract syntax tree representing it.

private ClassSignature
parseClassSignature()

ClassSignature: FormalTypeParameters_opt SuperclassSignature SuperinterfaceSignature*

private ClassTypeSignature
parseClassTypeSignature()

ClassTypeSignature: "L" PackageSpecifier_opt SimpleClassTypeSignature ClassTypeSignatureSuffix* ";"

private void
parseClassTypeSignatureSuffix(List<SimpleClassTypeSignature> scts)

ClassTypeSignatureSuffix: "." SimpleClassTypeSignature

private FieldTypeSignature
parseFieldTypeSignature()

FieldTypeSignature: ClassTypeSignature ArrayTypeSignature TypeVariableSignature

private FieldTypeSignature
parseFieldTypeSignature(boolean allowArrays)

private TypeSignature[]
private FormalTypeParameter
parseFormalTypeParameter()

FormalTypeParameter: Identifier ClassBound InterfaceBound*

private FormalTypeParameter[]
parseFormalTypeParameters()

FormalTypeParameters: "<" FormalTypeParameter+ ">"

private String
public MethodTypeSignature

Returns:

An abstract syntax tree for a method signature corresponding to the input string
parseMethodSig
(String
a string representing the input method signature
s
)

Parses a method signature (as defined in the JVMS, chapter 4) and produces an abstract syntax tree representing it.

private MethodTypeSignature
parseMethodTypeSignature()

MethodTypeSignature: FormalTypeParameters_opt "(" TypeSignature* ")" ReturnType ThrowsSignature*

private SimpleClassTypeSignature
parsePackageNameAndSimpleClassTypeSignature()

PackageSpecifier: Identifier "/" PackageSpecifier*

private ReturnType
parseReturnType()

ReturnType: TypeSignature VoidDescriptor

private SimpleClassTypeSignature
parseSimpleClassTypeSignature(boolean dollar)

SimpleClassTypeSignature: Identifier TypeArguments_opt

private ClassTypeSignature[]
parseSuperInterfaces()

SuperclassSignature: ClassTypeSignature

private FieldTypeSignature
parseThrowsSignature()

ThrowsSignature: "^" ClassTypeSignature "^" TypeVariableSignature

private TypeArgument
parseTypeArgument()

TypeArgument: WildcardIndicator_opt FieldTypeSignature "*"

private TypeArgument[]
parseTypeArguments()

TypeArguments: "<" TypeArgument+ ">"

public TypeSignature

Returns:

An abstract syntax tree for a type signature corresponding to the input string
parseTypeSig
(String
a string representing the input type signature
s
)

Parses a type signature and produces an abstract syntax tree representing it.

private TypeSignature
parseTypeSignature()

TypeSignature: FieldTypeSignature BaseType

private TypeVariableSignature
parseTypeVariableSignature()

TypeVariableSignature: "T" Identifier ";"

private FormalTypeParameter[]
private FieldTypeSignature[]
private TypeSignature[]
private void
progress(int startingPosition)

Verify the parse has made forward progress; throw an exception if no progress.

private String
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
private static final boolean DEBUG
EOIback to summary
private static final char EOI
indexback to summary
private int index
inputback to summary
private String input
markback to summary
private int mark

Constructor Detail

SignatureParserback to summary
private SignatureParser()

Method Detail

advanceback to summary
private void advance()
currentback to summary
private char current()
errorback to summary
private Error error(String errorMsg)
initback to summary
private void init(String s)
makeback to summary
public static SignatureParser make()

Static factory method. Produces a parser instance.

Returns:SignatureParser

an instance of SignatureParser

markback to summary
private void mark()
markToCurrentback to summary
private String markToCurrent()
parseArrayTypeSignatureback to summary
private ArrayTypeSignature parseArrayTypeSignature()

ArrayTypeSignature: "[" TypeSignature

parseBaseTypeback to summary
private BaseType parseBaseType()
parseBoundsback to summary
private FieldTypeSignature[] parseBounds()

ClassBound: ":" FieldTypeSignature_opt InterfaceBound: ":" FieldTypeSignature

parseClassSigback to summary
public ClassSignature parseClassSig(String s)

Parses a class signature (as defined in the JVMS, chapter 4) and produces an abstract syntax tree representing it.

Parameters
s:String

a string representing the input class signature

Returns:ClassSignature

An abstract syntax tree for a class signature corresponding to the input string

Exceptions
GenericSignatureFormatError:
if the input is not a valid class signature
parseClassSignatureback to summary
private ClassSignature parseClassSignature()

ClassSignature: FormalTypeParameters_opt SuperclassSignature SuperinterfaceSignature*

parseClassTypeSignatureback to summary
private ClassTypeSignature parseClassTypeSignature()

ClassTypeSignature: "L" PackageSpecifier_opt SimpleClassTypeSignature ClassTypeSignatureSuffix* ";"

parseClassTypeSignatureSuffixback to summary
private void parseClassTypeSignatureSuffix(List<SimpleClassTypeSignature> scts)

ClassTypeSignatureSuffix: "." SimpleClassTypeSignature

parseFieldTypeSignatureback to summary
private FieldTypeSignature parseFieldTypeSignature()

FieldTypeSignature: ClassTypeSignature ArrayTypeSignature TypeVariableSignature

parseFieldTypeSignatureback to summary
private FieldTypeSignature parseFieldTypeSignature(boolean allowArrays)
parseFormalParametersback to summary
private TypeSignature[] parseFormalParameters()
parseFormalTypeParameterback to summary
private FormalTypeParameter parseFormalTypeParameter()

FormalTypeParameter: Identifier ClassBound InterfaceBound*

parseFormalTypeParametersback to summary
private FormalTypeParameter[] parseFormalTypeParameters()

FormalTypeParameters: "<" FormalTypeParameter+ ">"

parseIdentifierback to summary
private String parseIdentifier()
parseMethodSigback to summary
public MethodTypeSignature parseMethodSig(String s)

Parses a method signature (as defined in the JVMS, chapter 4) and produces an abstract syntax tree representing it.

Parameters
s:String

a string representing the input method signature

Returns:MethodTypeSignature

An abstract syntax tree for a method signature corresponding to the input string

Exceptions
GenericSignatureFormatError:
if the input is not a valid method signature
parseMethodTypeSignatureback to summary
private MethodTypeSignature parseMethodTypeSignature()

MethodTypeSignature: FormalTypeParameters_opt "(" TypeSignature* ")" ReturnType ThrowsSignature*

parsePackageNameAndSimpleClassTypeSignatureback to summary
private SimpleClassTypeSignature parsePackageNameAndSimpleClassTypeSignature()

PackageSpecifier: Identifier "/" PackageSpecifier*

parseReturnTypeback to summary
private ReturnType parseReturnType()

ReturnType: TypeSignature VoidDescriptor

parseSimpleClassTypeSignatureback to summary
private SimpleClassTypeSignature parseSimpleClassTypeSignature(boolean dollar)

SimpleClassTypeSignature: Identifier TypeArguments_opt

parseSuperInterfacesback to summary
private ClassTypeSignature[] parseSuperInterfaces()

SuperclassSignature: ClassTypeSignature

parseThrowsSignatureback to summary
private FieldTypeSignature parseThrowsSignature()

ThrowsSignature: "^" ClassTypeSignature "^" TypeVariableSignature

parseTypeArgumentback to summary
private TypeArgument parseTypeArgument()

TypeArgument: WildcardIndicator_opt FieldTypeSignature "*"

parseTypeArgumentsback to summary
private TypeArgument[] parseTypeArguments()

TypeArguments: "<" TypeArgument+ ">"

parseTypeSigback to summary
public TypeSignature parseTypeSig(String s)

Parses a type signature and produces an abstract syntax tree representing it.

Parameters
s:String

a string representing the input type signature

Returns:TypeSignature

An abstract syntax tree for a type signature corresponding to the input string

Exceptions
GenericSignatureFormatError:
if the input is not a valid type signature
parseTypeSignatureback to summary
private TypeSignature parseTypeSignature()

TypeSignature: FieldTypeSignature BaseType

parseTypeVariableSignatureback to summary
private TypeVariableSignature parseTypeVariableSignature()

TypeVariableSignature: "T" Identifier ";"

parseZeroOrMoreFormalTypeParametersback to summary
private FormalTypeParameter[] parseZeroOrMoreFormalTypeParameters()
parseZeroOrMoreThrowsSignaturesback to summary
private FieldTypeSignature[] parseZeroOrMoreThrowsSignatures()
parseZeroOrMoreTypeSignaturesback to summary
private TypeSignature[] parseZeroOrMoreTypeSignatures()
progressback to summary
private void progress(int startingPosition)

Verify the parse has made forward progress; throw an exception if no progress.

remainderback to summary
private String remainder()
skipIdentifierback to summary
private void skipIdentifier()