Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8285939: javadoc java.lang.Record should not have "Direct Known Subclasses:" section #8523


Copy link

@jonathan-gibbons jonathan-gibbons commented May 3, 2022

As described in the JBS issue, the observed problem is a side-effect of a related but different issue, which is that record classes are not treated the same was as enum classes when it comes to generating the class hierarchy in ClassTree. Because record classes are not treated specially/differently, they are treated as ordinary/plain classes, with the side-effect that the page for java.lang.Record shows Direct Known Subclasses.

The underlying fix is therefore to clone the enum support in ClassTree and related classes, to provide support for record classes. It is possible to do an extreme minimal clone, but that just clones some of the messy evolution already there. Instead, the code in ClassTree and its clients is refactored and modernized.

Previously there were four explicit pairs of member fields, containing data for different groups (hierarchies) of classes, namely: plain classes, enum classes, interfaces and annotation interfaces. These fields are most of the code to support them are moved into some new abstractions to encapsulate related functionality.

  1. The main new abstraction in ClassTree is Hierarchy which provides the support for the different hierarchies displayed in the generated pages.
  2. A new enum HierarchyKind identifies the four existing hierarchies (listed above) and now a new one, for record classes. The hierarchies correspond to the different kinds of declared type.
  3. A small new class SubtypeMap which is a multi-map for mapping a type element to its subtypes. This is used in Hierarchy and to record the classes that implement an interfaces.

Generally, the naming should be clearer and more obvious. The most confusing name in the old code was enumSubtypes which was weird because enum classes don't have subtypes. It meant "subtypes of supertypes of enum classes". This was a prime motivator to switch to the hierarchy terminology. The variant spellings of intfacs have all been replaced by interfaces, and classtree becomes classTree.

Testing: a new test case has been added to the test, which verifies the new record hierarchy is displayed on a a package tree page. It is not simple to directly test the observed/reported behavior, because it is specific to the JDK API documentation, and because it is about the content of the java.lang.Record API page. However, manual inspection and diff comparison between JDK API documentation generated before and after this change reveals only expected differences. These differences are on the java.lang.R4cord page (where the offending section is no longer displayed) and on the pages related to the two existing records in JDK ... which are now listed in Record Class Hierarchy sections in the appropriate package-tree.html files.


  • 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


  • JDK-8285939: javadoc java.lang.Record should not have "Direct Known Subclasses:" section



Using git

Checkout this PR locally:
$ git fetch pull/8523/head:pull/8523
$ git checkout pull/8523

Update a local copy of the PR:
$ git checkout pull/8523
$ git pull pull/8523/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8523

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

Using diff file

Download this PR as a diff file:

Copy link

@bridgekeeper bridgekeeper bot commented May 3, 2022

👋 Welcome back jjg! 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 openjdk bot added the rfr label May 3, 2022
Copy link

@openjdk openjdk bot commented May 3, 2022

@jonathan-gibbons The following label will be automatically applied to this pull request:

  • javadoc

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.

@openjdk openjdk bot added the javadoc label May 3, 2022
Copy link

@mlbridge mlbridge bot commented May 3, 2022


Copy link

@pavelrappo pavelrappo left a comment

Although I haven't looked into code in detail, I can confirm that the following JDK API pages have been updated and look good:

  1. java.base/java/lang/Record.html
  2. java.base/java/lang/class-use/Object.html
  3. java.base/java/lang/class-use/Record.html
  4. java.base/java/lang/package-use.html
  5. jdk.jshell/jdk/jshell/package-tree.html
  7. overview-tree.html

WRT documentation, a hierarchy of records now behave similarly to that of enums.

Copy link

@pavelrappo pavelrappo left a comment

Please merge this branch with the master (they are now in conflict) and I will review the change.

hns approved these changes May 25, 2022
Copy link

@hns hns left a comment

This is a nice cleanup! My only objection is that some refactored/moved methods have lost their doc comment.

Copy link

@openjdk openjdk bot commented May 25, 2022

@jonathan-gibbons This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file for details.

After integration, the commit message for the final commit will be:

8285939: javadoc java.lang.Record should not have "Direct Known Subclasses:" section

Reviewed-by: prappo, hannesw

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 60 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label May 25, 2022
Copy link
Contributor Author

@jonathan-gibbons jonathan-gibbons commented May 31, 2022


Copy link

@openjdk openjdk bot commented May 31, 2022

Going to push as commit 8fc201e.
Since your change was applied there have been 60 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated label May 31, 2022
@openjdk openjdk bot closed this May 31, 2022
@openjdk openjdk bot removed ready rfr labels May 31, 2022
Copy link

@openjdk openjdk bot commented May 31, 2022

@jonathan-gibbons Pushed as commit 8fc201e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@jonathan-gibbons jonathan-gibbons deleted the 8285939.record-subtypes branch May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
integrated javadoc
3 participants