APIdia Launch Partner
Top Description Inners
com.sun.tools.javac.code

public sealed Interface TypeMetadata

permits Annotations, ConstantValue
Known Direct Implementers
com.sun.tools.javac.code.TypeMetadata.Annotations, com.sun.tools.javac.code.TypeMetadata.ConstantValue
Imports
com.sun.tools.javac.util.List, .ListBuffer

A type metadata is an object that can be stapled on a type. This is typically done using Type#addMetadata(TypeMetadata). Metadata associated to a type can also be removed, typically using Type#dropMetadata(Class). To drop all metadata from a given type, the Type#baseType() method can also be used. This can be useful when comparing two using reference equality (see also Type#equalsIgnoreMetadata(Type)).

There are no constraints on how a type metadata should be defined. Typically, a type metadata will be defined as a small record, storing additional information (see ConstantValue). In other cases, type metadata can be mutable and support complex state transitions (see Annotations).

The only invariant the implementation requires is that there must be one metadata of a given kind attached to a type, as this makes accessing and dropping metadata simpler. If clients wish to store multiple metadata values that are logically related, they should define a metadata type that collects such values in e.g. a list.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static record
TypeMetadata.Annotations

A type metadata object holding type annotations.

public static record
TypeMetadata.ConstantValue

A type metadata holding a constant value.

com.sun.tools.javac.code back to summary

public final Record TypeMetadata.Annotations

extends Record
implements TypeMetadata
Class Inheritance
All Implemented Interfaces
com.sun.tools.javac.code.TypeMetadata
Record Components
annotationBuffer:ListBuffer<Attribute.TypeCompound> 

A type metadata object holding type annotations. This metadata needs to be mutable, because type annotations are sometimes set in two steps. That is, a type can be created with an empty set of annotations (e.g. during member enter). At some point later, the type is then updated to contain the correct annotations. At this point we need to augment the existing type (rather than creating a new one), as the type might already have been saved inside other symbols.

Field Summary

Modifier and TypeField and Description
private final ListBuffer<Attribute.TypeCompound>
annotationBuffer

Record Component accessed by annotationBuffer().

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
public

Method Summary

Modifier and TypeMethod and Description
public ListBuffer<Attribute.TypeCompound>
annotationBuffer()

Record Component getter of annotationBuffer.

pack-priv List<Attribute.TypeCompound>
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

annotationBufferback to summary
private final ListBuffer<Attribute.TypeCompound> annotationBuffer

Record Component accessed by annotationBuffer().

Constructor Detail

Annotationsback to summary
pack-priv Annotations()
Annotationsback to summary
pack-priv Annotations(List<Attribute.TypeCompound> annotations)
Annotationsback to summary
public Annotations(ListBuffer<Attribute.TypeCompound> annotationBuffer)

Method Detail

annotationBufferback to summary
public ListBuffer<Attribute.TypeCompound> annotationBuffer()

Record Component getter of annotationBuffer.

annotationsback to summary
pack-priv List<Attribute.TypeCompound> annotations()
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

com.sun.tools.javac.code back to summary

public final Record TypeMetadata.ConstantValue

extends Record
implements TypeMetadata
Class Inheritance
All Implemented Interfaces
com.sun.tools.javac.code.TypeMetadata
Record Components
value:Object 

A type metadata holding a constant value. This can be used to describe constant types, such as the type of a string literal, or that of a numeric constant.

Field Summary

Modifier and TypeField and Description
private final Object
value

Record Component accessed by value().

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public Object
value()

Record Component getter of value.

Field Detail

valueback to summary
private final Object value

Record Component accessed by value().

Constructor Detail

ConstantValueback to summary
public ConstantValue(Object value)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

valueback to summary
public Object value()

Record Component getter of value.