Type (Java SE 22 & JDK 22)
Description: declaration: module: jdk.jdi, package: com.sun.jdi, interface: Type
Keywords: com.sun.jdi.Type interface

Module jdk.jdi
Package com.sun.jdi

# Interface Type

All Superinterfaces:
  `Mirror`

All Known Subinterfaces:
  `ArrayType`, `BooleanType`, `ByteType`, `CharType`, `ClassType`, `DoubleType`, `FloatType`, `IntegerType`, `InterfaceType`, `LongType`, `PrimitiveType`, `ReferenceType`, `ShortType`, `VoidType`

public interface Type extends Mirror
The mirror for a type in the target VM. This interface is the root of a type hierarchy encompassing primitive types and reference types.

A Type may be used to represent a run-time type:

> `Value`.type()

or a compile-time type:

> `Field.type()`
> `Method.returnType()`
> `Method.argumentTypes()`
> `LocalVariable.type()`
> `ArrayType.componentType()`

The following tables illustrate which subinterfaces of Type are used to mirror types in the target VM --

Subinterfaces of `PrimitiveType`
Type declared in target as | Is mirrored as an instance of
--- | ---
`boolean` | `BooleanType`
`byte` | `ByteType`
`char` | `CharType`
`double` | `DoubleType`
`float` | `FloatType`
`int` | `IntegerType`
`long` | `LongType`
`short` | `ShortType`
`void` | `VoidType`

Subinterfaces of `ReferenceType`
Type declared in target as | For example | Is mirrored as an instance of
--- | --- | ---
a class | `Date` | `ClassType`
an interface | `Runnable` | `InterfaceType`
an array | (any) | `ArrayType`
`int[]` | `ArrayType` whose `componentType()` is `IntegerType`
`Date[]` | `ArrayType` whose `componentType()` is `ClassType`
`Runnable[]` | `ArrayType` whose `componentType()` is `InterfaceType`

Since:
  1.3
See Also:
  - Subinterface PrimitiveType
  - Subinterface ReferenceType
  - Value - for relationship between Type and Value
  - Field.type() - for usage examples

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `name()`
  Returns the name of this type.
  `String`
  `signature()`
  Returns the type signature for this type.

  ### Methods declared in interface com.sun.jdi.Mirror

  `toString, virtualMachine`

- ## Method Details

  - ### signature

    String signature()
    Returns the type signature for this type. The result is of the same form as the string returned by `Class.descriptorString()`. The returned string is a type descriptor conforming to JVMS 4.3.2 if this type can be described nominally. Otherwise, the returned string is not a type descriptor.
    Returns:
      the type signature

  - ### name

    String name()
    Returns the name of this type. The result is of the same form as the name returned by `Class.getName()`. The returned name may not be a binary name.
    Returns:
      the name of this type