Package Summary Overview Summary

Module java.base
Package java.lang.runtime

# Class ExactConversionsSupport

java.lang.Object
java.lang.runtime.ExactConversionsSupport

public final class ExactConversionsSupport extends Object
A casting conversion is considered to be exact if, after applying the conversion to the value, no exception was raised or loss of information has occured; otherwise it is considered inexact. The methods in this class provide the run-time support for primitive conversions exactness checks. These methods may be used, for example, by Java compiler implementations to implement checks for `instanceof` and pattern matching runtime implementations. See JLS section 5.5.1 for more information on exact casting conversions.

Implementation Note:
  Methods that describe a conversion check among unconditionally exact types (they would return true) are ommited. Similarly, methods that describe a conversion check which can be redirected through one of the methods in this class are omitted too (i.e., byte to char can be redirected safely to `isIntToCharExact`, similarly `short` to `byte`, `short` to `char`, `char` to `byte` and `char` to `short`).
See Java Language Specification :
  5.5.1 Exact Casting Conversions
  15.20.2 The instanceof Operator
Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `isDoubleToByteExact (double n)`
  Exactness method from double to byte
  `static boolean`
  `isDoubleToCharExact (double n)`
  Exactness method from double to char
  `static boolean`
  `isDoubleToFloatExact (double n)`
  Exactness method from double to float
  `static boolean`
  `isDoubleToIntExact (double n)`
  Exactness method from double to int
  `static boolean`
  `isDoubleToLongExact (double n)`
  Exactness method from double to long
  `static boolean`
  `isDoubleToShortExact (double n)`
  Exactness method from double to short
  `static boolean`
  `isFloatToByteExact (float n)`
  Exactness method from float to byte
  `static boolean`
  `isFloatToCharExact (float n)`
  Exactness method from float to char
  `static boolean`
  `isFloatToIntExact (float n)`
  Exactness method from float to int
  `static boolean`
  `isFloatToLongExact (float n)`
  Exactness method from float to long
  `static boolean`
  `isFloatToShortExact (float n)`
  Exactness method from float to short
  `static boolean`
  `isIntToByteExact (int n)`
  Exactness method from int to byte
  `static boolean`
  `isIntToCharExact (int n)`
  Exactness method from int to char
  `static boolean`
  `isIntToFloatExact (int n)`
  Exactness method from int to float
  `static boolean`
  `isIntToShortExact (int n)`
  Exactness method from int to short
  `static boolean`
  `isLongToByteExact (long n)`
  Exactness method from long to byte
  `static boolean`
  `isLongToCharExact (long n)`
  Exactness method from long to char
  `static boolean`
  `isLongToDoubleExact (long n)`
  Exactness method from long to double
  `static boolean`
  `isLongToFloatExact (long n)`
  Exactness method from long to float
  `static boolean`
  `isLongToIntExact (long n)`
  Exactness method from long to int
  `static boolean`
  `isLongToShortExact (long n)`
  Exactness method from long to short

  ### Methods declared in class java.lang.Object

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

- ## Method Details

  - ### isIntToByteExact

    public static boolean isIntToByteExact (int n)
    Exactness method from int to byte
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isIntToShortExact

    public static boolean isIntToShortExact (int n)
    Exactness method from int to short
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isIntToCharExact

    public static boolean isIntToCharExact (int n)
    Exactness method from int to char
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isIntToFloatExact

    public static boolean isIntToFloatExact (int n)
    Exactness method from int to float
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isLongToByteExact

    public static boolean isLongToByteExact (long n)
    Exactness method from long to byte
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isLongToShortExact

    public static boolean isLongToShortExact (long n)
    Exactness method from long to short
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isLongToCharExact

    public static boolean isLongToCharExact (long n)
    Exactness method from long to char
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isLongToIntExact

    public static boolean isLongToIntExact (long n)
    Exactness method from long to int
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isLongToFloatExact

    public static boolean isLongToFloatExact (long n)
    Exactness method from long to float
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isLongToDoubleExact

    public static boolean isLongToDoubleExact (long n)
    Exactness method from long to double
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isFloatToByteExact

    public static boolean isFloatToByteExact (float n)
    Exactness method from float to byte
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isFloatToShortExact

    public static boolean isFloatToShortExact (float n)
    Exactness method from float to short
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isFloatToCharExact

    public static boolean isFloatToCharExact (float n)
    Exactness method from float to char
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isFloatToIntExact

    public static boolean isFloatToIntExact (float n)
    Exactness method from float to int
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isFloatToLongExact

    public static boolean isFloatToLongExact (float n)
    Exactness method from float to long
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isDoubleToByteExact

    public static boolean isDoubleToByteExact (double n)
    Exactness method from double to byte
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isDoubleToShortExact

    public static boolean isDoubleToShortExact (double n)
    Exactness method from double to short
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isDoubleToCharExact

    public static boolean isDoubleToCharExact (double n)
    Exactness method from double to char
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isDoubleToIntExact

    public static boolean isDoubleToIntExact (double n)
    Exactness method from double to int
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isDoubleToLongExact

    public static boolean isDoubleToLongExact (double n)
    Exactness method from double to long
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type

  - ### isDoubleToFloatExact

    public static boolean isDoubleToFloatExact (double n)
    Exactness method from double to float
    Implementation Requirements:
      relies on the notion of representation equivalence defined in the specification of the Double class.
    Parameters:
      `n` - value
    Returns:
      true if the passed value can be converted exactly to the target type