Skip to content

Conversation

@liach
Copy link
Member

@liach liach commented Dec 5, 2025

The 3 methods to determine conversions and subtyping on java.lang.Class, which are isInstance, cast, and isAssignableFrom, have their documentation from the earliest days of the Java Platform. During the language evolution, a lot of terms have become inaccurate, such as "assignment-compatible", which does not apply for primitive types, and the out-of-date instanceof analogy with the upcoming patterns, in isInstance; isAssignableFrom is not very clear about arrays; cast would also benefit from more detailed explanations.

In my facelift, I moved the subtyping description to isAssignableFrom, and left the conversion stuff in isInstance and cast. I intentionally avoided linking to too many JLS chapters to reduce confusions. I believe in this shape, we have a good amount of easily comprehensible yet accurate specification for all 3 methods, and users are welcome to read the linked JLS chapters for more details and context.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8373192 to be approved

Issues

  • JDK-8371795: Improve documentation of Class.isInstance (Bug - P4)
  • JDK-8373192: Improve documentation of Class.isInstance (CSR)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28684/head:pull/28684
$ git checkout pull/28684

Update a local copy of the PR:
$ git checkout pull/28684
$ git pull https://git.openjdk.org/jdk.git pull/28684/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28684

View PR using the GUI difftool:
$ git pr show -t 28684

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28684.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 5, 2025

👋 Welcome back liach! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Dec 5, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title 8371795 8371795: Improve documentation of Class.isInstance Dec 5, 2025
@openjdk openjdk bot added csr Pull request needs approved CSR before integration core-libs core-libs-dev@openjdk.org labels Dec 5, 2025
@openjdk
Copy link

openjdk bot commented Dec 5, 2025

@liach The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@liach liach marked this pull request as ready for review December 5, 2025 23:08
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 5, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 5, 2025

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org csr Pull request needs approved CSR before integration rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

1 participant