Package javassist.bytecode

# Class SignatureAttribute

java.lang.Object
javassist.bytecode.AttributeInfo
javassist.bytecode.SignatureAttribute

public class SignatureAttribute extends AttributeInfo
`Signature_attribute`.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`SignatureAttribute.ArrayType`
Array types.
`static class`
`SignatureAttribute.BaseType`
Primitive types.
`static class`
`SignatureAttribute.ClassSignature`
Class signature.
`static class`
`SignatureAttribute.ClassType`
Class types.
`static class`
`SignatureAttribute.MethodSignature`
Method type signature.
`static class`
`SignatureAttribute.NestedClassType`
Nested class types.
`static class`
`SignatureAttribute.ObjectType`
Class types, array types, and type variables.
`static class`
`SignatureAttribute.Type`
Primitive types and object types.
`static class`
`SignatureAttribute.TypeArgument`
Type argument.
`static class`
`SignatureAttribute.TypeParameter`
Formal type parameters.
`static class`
`SignatureAttribute.TypeVariable`
Type variables.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`tag`
The name of this attribute `"Signature"`.

## Constructor Summary

Constructors
Constructor
Description
`SignatureAttribute(ConstPool cp, String signature)`
Constructs a `Signature` attribute.

## Method Summary

Modifier and Type
Method
Description
`AttributeInfo`
`copy(ConstPool newCp, Map<String,String> classnames)`
Makes a copy.
`String`
`getSignature()`
Returns the generic signature indicated by `signature_index`.
`void`
`setSignature(String sig)`
Sets `signature_index` to the index of the given generic signature, which is added to a constant pool.
`static SignatureAttribute.ClassSignature`
`toClassSignature(String sig)`
Parses the given signature string as a class signature.
`static SignatureAttribute.ObjectType`
`toFieldSignature(String sig)`
Parses the given signature string as a field type signature.
`static SignatureAttribute.MethodSignature`
`toMethodSignature(String sig)`
Parses the given signature string as a method type signature.
`static SignatureAttribute.Type`
`toTypeSignature(String sig)`
Parses the given signature string as a type signature.

### Methods inherited from class javassist.bytecode.AttributeInfo

`get, getConstPool, getName, length, set`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### tag

public static final String tag
The name of this attribute `"Signature"`.

See Also:
  - Constant Field Values

## Constructor Details

### SignatureAttribute

public SignatureAttribute(ConstPool cp, String signature)
Constructs a `Signature` attribute.

Parameters:
  `cp` - a constant pool table.
  `signature` - the signature represented by this attribute.

## Method Details

### getSignature

public String getSignature()
Returns the generic signature indicated by `signature_index`.

See Also:
  - `toClassSignature(String)`
  - `toMethodSignature(String)`
  - `toFieldSignature(String)`

### setSignature

public void setSignature(String sig)
Sets `signature_index` to the index of the given generic signature, which is added to a constant pool.

Parameters:
  `sig` - new signature.
Since:
  3.11

### copy

public AttributeInfo copy(ConstPool newCp, Map<String,String> classnames)
Makes a copy. Class names are replaced according to the given `Map` object.

Overrides:
  `copy` in class `AttributeInfo`
Parameters:
  `newCp` - the constant pool table used by the new copy.
  `classnames` - pairs of replaced and substituted class names.

### toClassSignature

public static SignatureAttribute.ClassSignature toClassSignature(String sig) throws BadBytecode
Parses the given signature string as a class signature.

Parameters:
  `sig` - the signature obtained from the `SignatureAttribute` of a `ClassFile`.
Returns:
  a tree-like data structure representing a class signature. It provides convenient accessor methods.
Throws:
  `BadBytecode` - thrown when a syntactical error is found.
Since:
  3.5
See Also:
  - `getSignature()`

### toMethodSignature

public static SignatureAttribute.MethodSignature toMethodSignature(String sig) throws BadBytecode
Parses the given signature string as a method type signature.

Parameters:
  `sig` - the signature obtained from the `SignatureAttribute` of a `MethodInfo`.
Returns:
  @return a tree-like data structure representing a method signature. It provides convenient accessor methods.
Throws:
  `BadBytecode` - thrown when a syntactical error is found.
Since:
  3.5
See Also:
  - `getSignature()`

### toFieldSignature

public static SignatureAttribute.ObjectType toFieldSignature(String sig) throws BadBytecode
Parses the given signature string as a field type signature.

Parameters:
  `sig` - the signature string obtained from the `SignatureAttribute` of a `FieldInfo`.
Returns:
  the field type signature.
Throws:
  `BadBytecode` - thrown when a syntactical error is found.
Since:
  3.5
See Also:
  - `getSignature()`

### toTypeSignature

public static SignatureAttribute.Type toTypeSignature(String sig) throws BadBytecode
Parses the given signature string as a type signature. The type signature is either the field type signature or a base type descriptor including `void` type.

Throws:
  `BadBytecode` - thrown when a syntactical error is found.
Since:
  3.18