Top Description Fields Constructors Methods
net.bytebuddy.jar.asm.signature

public Class SignatureWriter

extends SignatureVisitor
Class Inheritance
Imports
net.bytebuddy.jar.asm.Opcodes

A SignatureVisitor that generates signature literals, as defined in the Java Virtual Machine Specification (JVMS).
Authors
Thomas Hallgren, Eric Bruneton
See Also
JVMS 4.7.9.1

Field Summary

Modifier and TypeField and Description
private int
argumentStack

The stack used to keep track of class types that have arguments.

private boolean
hasFormals

Whether the visited signature contains formal type parameters.

private boolean
hasParameters

Whether the visited signature contains method parameter types.

private final StringBuilder
stringBuilder

The builder used to construct the visited signature.

Inherited from net.bytebuddy.jar.asm.signature.SignatureVisitor:
apiEXTENDSINSTANCEOFSUPER

Constructor Summary

AccessConstructor and Description
public
SignatureWriter()

Constructs a new SignatureWriter.

private
SignatureWriter(final StringBuilder stringBuilder)

Method Summary

Modifier and TypeMethod and Description
private void
endArguments()

Ends the type arguments of a class or inner class type.

private void
endFormals()

Ends the formal type parameters section of the signature.

public String

Returns:

the signature that was built by this signature writer.
toString
()

Overrides java.lang.Object.toString.

Returns the signature that was built by this signature writer.
public SignatureVisitor
visitArrayType()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitArrayType.

Visits a signature corresponding to an array type.
public void
visitBaseType(final char
the descriptor of the primitive type, or 'V' for void .
descriptor
)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitBaseType.

Visits a signature corresponding to a primitive type.
public SignatureVisitor
visitClassBound()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitClassBound.

Visits the class bound of the last visited formal type parameter.
public void
visitClassType(final String
the internal name of the class or interface (see net.bytebuddy.jar.asm.Type#getInternalName()).
name
)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitClassType.

Starts the visit of a signature corresponding to a class or interface type.
public void
visitEnd()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitEnd.

Ends the visit of a signature corresponding to a class or interface type.
public SignatureVisitor
public void
visitFormalTypeParameter(final String
the name of the formal parameter.
name
)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitFormalTypeParameter.

Visits a formal type parameter.
public void
visitInnerClassType(final String
the local name of the inner class in its enclosing class.
name
)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitInnerClassType.

Visits an inner class.
public SignatureVisitor
visitInterface()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitInterface.

Visits the type of an interface implemented by the class.
public SignatureVisitor
visitInterfaceBound()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitInterfaceBound.

Visits an interface bound of the last visited formal type parameter.
public SignatureVisitor
public SignatureVisitor
public SignatureVisitor
public void
visitTypeArgument()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitTypeArgument.

Visits an unbounded type argument of the last visited class or inner class type.
public SignatureVisitor
visitTypeArgument(final char
'+', '-' or '='.
wildcard
)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitTypeArgument.

Visits a type argument of the last visited class or inner class type.
public void
visitTypeVariable(final String
the name of the type variable.
name
)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitTypeVariable.

Visits a signature corresponding to a type variable.

Field Detail

argumentStackback to summary
private int argumentStack

The stack used to keep track of class types that have arguments. Each element of this stack is a boolean encoded in one bit. The top of the stack is the least significant bit. The bottom of the stack is a sentinel element always equal to 1 (used to detect when the stack is full). Pushing false = <<= 1, pushing true = ( <<= 1) | 1, popping = >>>= 1.

Class type arguments must be surrounded with '<' and '>' and, because

  1. class types can be nested (because type arguments can themselves be class types),
  2. SignatureWriter always returns 'this' in each visit* method (to avoid allocating new SignatureWriter instances),

we need a stack to properly balance these angle brackets. A new element is pushed on this stack for each new visited type, and popped when the visit of this type ends (either in visitEnd, or because visitInnerClassType is called).

hasFormalsback to summary
private boolean hasFormals

Whether the visited signature contains formal type parameters.

hasParametersback to summary
private boolean hasParameters

Whether the visited signature contains method parameter types.

stringBuilderback to summary
private final StringBuilder stringBuilder

The builder used to construct the visited signature.

Constructor Detail

SignatureWriterback to summary
public SignatureWriter()

Constructs a new SignatureWriter.

SignatureWriterback to summary
private SignatureWriter(final StringBuilder stringBuilder)

Method Detail

endArgumentsback to summary
private void endArguments()

Ends the type arguments of a class or inner class type.

endFormalsback to summary
private void endFormals()

Ends the formal type parameters section of the signature.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the signature that was built by this signature writer.

Returns:String

the signature that was built by this signature writer.

Annotations
@Override
visitArrayTypeback to summary
public SignatureVisitor visitArrayType()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitArrayType.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitArrayType.

Visits a signature corresponding to an array type.

Returns:SignatureVisitor

a non null visitor to visit the signature of the array element type.

Annotations
@Override
visitBaseTypeback to summary
public void visitBaseType(final char descriptor)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitBaseType.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitBaseType.

Visits a signature corresponding to a primitive type.

Parameters
descriptor:char

the descriptor of the primitive type, or 'V' for void .

Annotations
@Override
visitClassBoundback to summary
public SignatureVisitor visitClassBound()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitClassBound.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitClassBound.

Visits the class bound of the last visited formal type parameter.

Returns:SignatureVisitor

a non null visitor to visit the signature of the class bound.

Annotations
@Override
visitClassTypeback to summary
public void visitClassType(final String name)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitClassType.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitClassType.

Starts the visit of a signature corresponding to a class or interface type.

Parameters
name:String

the internal name of the class or interface (see net.bytebuddy.jar.asm.Type#getInternalName()).

Annotations
@Override
visitEndback to summary
public void visitEnd()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitEnd.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitEnd.

Ends the visit of a signature corresponding to a class or interface type.

Annotations
@Override
visitExceptionTypeback to summary
public SignatureVisitor visitExceptionType()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitExceptionType.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitExceptionType.

Visits the type of a method exception.

Returns:SignatureVisitor

a non null visitor to visit the signature of the exception type.

Annotations
@Override
visitFormalTypeParameterback to summary
public void visitFormalTypeParameter(final String name)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitFormalTypeParameter.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitFormalTypeParameter.

Visits a formal type parameter.

Parameters
name:String

the name of the formal parameter.

Annotations
@Override
visitInnerClassTypeback to summary
public void visitInnerClassType(final String name)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitInnerClassType.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitInnerClassType.

Visits an inner class.

Parameters
name:String

the local name of the inner class in its enclosing class.

Annotations
@Override
visitInterfaceback to summary
public SignatureVisitor visitInterface()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitInterface.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitInterface.

Visits the type of an interface implemented by the class.

Returns:SignatureVisitor

a non null visitor to visit the signature of the interface type.

Annotations
@Override
visitInterfaceBoundback to summary
public SignatureVisitor visitInterfaceBound()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitInterfaceBound.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitInterfaceBound.

Visits an interface bound of the last visited formal type parameter.

Returns:SignatureVisitor

a non null visitor to visit the signature of the interface bound.

Annotations
@Override
visitParameterTypeback to summary
public SignatureVisitor visitParameterType()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitParameterType.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitParameterType.

Visits the type of a method parameter.

Returns:SignatureVisitor

a non null visitor to visit the signature of the parameter type.

Annotations
@Override
visitReturnTypeback to summary
public SignatureVisitor visitReturnType()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitReturnType.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitReturnType.

Visits the return type of the method.

Returns:SignatureVisitor

a non null visitor to visit the signature of the return type.

Annotations
@Override
visitSuperclassback to summary
public SignatureVisitor visitSuperclass()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitSuperclass.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitSuperclass.

Visits the type of the super class.

Returns:SignatureVisitor

a non null visitor to visit the signature of the super class type.

Annotations
@Override
visitTypeArgumentback to summary
public void visitTypeArgument()

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitTypeArgument.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitTypeArgument.

Visits an unbounded type argument of the last visited class or inner class type.

Annotations
@Override
visitTypeArgumentback to summary
public SignatureVisitor visitTypeArgument(final char wildcard)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitTypeArgument.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitTypeArgument.

Visits a type argument of the last visited class or inner class type.

Parameters
wildcard:char

'+', '-' or '='.

Returns:SignatureVisitor

a non null visitor to visit the signature of the type argument.

Annotations
@Override
visitTypeVariableback to summary
public void visitTypeVariable(final String name)

Overrides net.bytebuddy.jar.asm.signature.SignatureVisitor.visitTypeVariable.

Doc from net.bytebuddy.jar.asm.signature.SignatureVisitor.visitTypeVariable.

Visits a signature corresponding to a type variable.

Parameters
name:String

the name of the type variable.

Annotations
@Override