---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 22 Edition"
java_version: 22
chapter: "Chapter 18. Type Inference"
section: "18.2.3"
heading: "18.2.3. Subtyping Constraints"
parent: "18.2. Reduction"
source: https://docs.oracle.com/javase/specs/jls/se22/html/jls-18.html#jls-18.2.3
id: "18.2.3"
url: https://jvm.obfuscated.software/jls/se22/18.2.3.html
raw: https://jvm.obfuscated.software/jls/se22/18.2.3.md
---

# 18.2.3. Subtyping Constraints

A constraint formula of the form ‹S `<:` T› is reduced as follows:

- If S and T are proper types, the constraint reduces to *true* if S is a subtype of T ([§4.10](4.10.md)), and *false* otherwise.

- Otherwise, if S is the null type, the constraint reduces to *true*.

- Otherwise, if T is the null type, the constraint reduces to *false*.

- Otherwise, if S is an inference variable, α, the constraint reduces to the bound α `<:` T.

- Otherwise, if T is an inference variable, α, the constraint reduces to the bound S `<:` α.

- Otherwise, the constraint is reduced according to the form of T:

  - If T is a parameterized class or interface type, or an inner class type of a parameterized class or interface type (directly or indirectly), let A_1, ..., A_n be the type arguments of T. Among the supertypes of S, a corresponding class or interface type is identified, with type arguments B_1, ..., B_n. If no such type exists, the constraint reduces to *false*. Otherwise, the constraint reduces to the following new constraints: for all *i* (1 ≤ *i* ≤ *n*), ‹B_i `<=` A_i›.

  - If T is any other class or interface type, then the constraint reduces to *true* if T is among the supertypes of S, and *false* otherwise.

  - If T is an array type, T'`[]`, then among the supertypes of S that are array types, a most specific type is identified, S'`[]` (this may be S itself). If no such array type exists, the constraint reduces to *false*. Otherwise:

    - If neither S' nor T' is a primitive type, the constraint reduces to ‹S' `<:` T'›.
    - Otherwise, the constraint reduces to *true* if S' and T' are the same primitive type, and *false* otherwise.

  - If T is a type variable, there are three cases:

    - If S is an intersection type of which T is an element, the constraint reduces to *true*.
    - Otherwise, if T has a lower bound, B, the constraint reduces to ‹S `<:` B›.
    - Otherwise, the constraint reduces to *false*.

  - If T is an intersection type, I_1 `&` ... `&` I_n, the constraint reduces to the following new constraints: for all *i* (1 ≤ *i* ≤ *n*), ‹S `<:` I_i›.

A constraint formula of the form ‹S `<=` T›, where S and T are type arguments ([§4.5.1](4.5.1.md)), is reduced as follows:

- If T is a type:

  - If S is a type, the constraint reduces to ‹S = T›.
  - If S is a wildcard, the constraint reduces to *false*.

- If T is a wildcard of the form `?`, the constraint reduces to *true*.

- If T is a wildcard of the form `?` `extends` T':

  - If S is a type, the constraint reduces to ‹S `<:` T'›.
  - If S is a wildcard of the form `?`, the constraint reduces to ‹`Object` `<:` T'›.
  - If S is a wildcard of the form `?` `extends` S', the constraint reduces to ‹S' `<:` T'›.
  - If S is a wildcard of the form `?` `super` S', the constraint reduces to ‹`Object` = T'›.

- If T is a wildcard of the form `?` `super` T':

  - If S is a type, the constraint reduces to ‹T' `<:` S›.
  - If S is a wildcard of the form `?` `super` S', the constraint reduces to ‹T' `<:` S'›.
  - Otherwise, the constraint reduces to *false*.
