Skip to content

8387875: [lworld] Provide value-class-preview.md file#2633

Open
liach wants to merge 12 commits into
openjdk:lworldfrom
liach:doc/lw-value-migration
Open

8387875: [lworld] Provide value-class-preview.md file#2633
liach wants to merge 12 commits into
openjdk:lworldfrom
liach:doc/lw-value-migration

Conversation

@liach

@liach liach commented Jul 8, 2026

Copy link
Copy Markdown
Member

This is some extremely basic overview about value class migrations.

  1. Build: I intentionally skipped the streamlined build system installed by David Beaumont. Instead, I stressed the custom handling used by Value Objects JEP. (The "Preview Classes in Interim javac" section might go to general documentation later.)

  2. Testing: I started from the motivations/goals and describe how those goals are accomplished.

  3. Wrapper class caches: Some simple overview.

There are definitely more topics to cover; feel free to raise.

Paging @jddarcy and @viktorklang-ora for proofreading.



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Issue

  • JDK-8387875: [lworld] Provide value-class-preview.md file (Enhancement - P2)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2633

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2633.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Jul 8, 2026

Copy link
Copy Markdown

👋 Welcome back liach! A progress list of the required criteria for merging this PR into lworld 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 commented Jul 8, 2026

Copy link
Copy Markdown

❗ 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 8387875 8387875: [lworld] Provide value-class-preview.md file Jul 8, 2026
Comment thread doc/value-class-preview.md Outdated
`/*value*/ record` in the hardcoded list of source files, and generate preview
source files where these occurrences are replaced by `value class` and
`value record`, respectively.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, with the current system, consequently, any needed testing of "is preview enabled" must be done at runtime rather than via a compile-time macro?
(The other little code gen systems used in the JDK have a more expressive set of primitives. In my estimation, the simple system here is good for the purpose it is being used for, but it is helpful to document it here.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I don't understand how a compile-time macro can work - we have one runtime that must support both preview-on and preview-off runs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the space of generate-different-source-code-from-a-template solutions, it would be possible to have code conditionally emitted for one case but not the other. The solution used for JEP 401 currently just uncomments the value modifier.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tried to use annotation processors and discovered that it just introduced unnecessary hassles and complexities beyond what is required for JEP 401. I have described the JEP 401 process here; we can tweak this document if we do tweak this pipeline in the future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand some of the history for the transitory use of annotation processors, but the readers of this document might have not that history (and might not care about it either ;-) ).

Given that the general shape of the solution is "we have generating preview-specific versions of source files which get compiled into preview-specific class files," the current mechanism we are choosing to do the generation has very limited functionality, which is sufficient for the purposes at hand. However, that mechanism is less capable than several analagous mechanisms elsewhere in the JDK build.

@jddarcy

jddarcy commented Jul 9, 2026

Copy link
Copy Markdown
Member

And once the text of the note if finalized, links to it in // comments should be added to the wrapper classes and the java.time classes.

Comment thread doc/value-class-preview.md Outdated
Comment thread doc/value-class-preview.md Outdated
@viktorklang-ora

Copy link
Copy Markdown
Contributor

Thanks for taking this on, @liach!

@liach

liach commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

Updated. Please help proofread the latest version, thanks!

Comment thread doc/value-class-preview.md Outdated
Comment thread doc/value-class-preview.md Outdated
@viktorklang-ora

Copy link
Copy Markdown
Contributor

After commentsI had some minor comments, and after addressing those I think this is ready from my point-of-view. I'll let @jddarcy decide if anything more is necessary.

@liach liach marked this pull request as ready for review July 10, 2026 16:02
@openjdk openjdk Bot added the rfr Pull request is ready for review label Jul 10, 2026
@mlbridge

mlbridge Bot commented Jul 10, 2026

Copy link
Copy Markdown

Webrevs

Comment thread doc/value-class-preview.md Outdated
Comment thread doc/value-class-preview.md Outdated
Comment thread doc/value-class-preview.md
Comment thread doc/value-class-preview.md Outdated
Comment thread doc/value-class-preview.md Outdated
Comment thread doc/value-class-preview.md Outdated
Comment thread doc/value-class-preview.md Outdated

@viktorklang-ora viktorklang-ora left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is LGTM after considering my latest comments.

Comment thread doc/value-class-preview.md Outdated
to value classes. This means that when preview features are enabled, different
class files are used for the migrated classes in the Java class library.

To accomplish this, the JDK uses *preview-specific* files in `META-INF/preview`,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify,
"To accomplish this, a built JDK uses..."

That is, this section is discussing the artifact people run, not the source structure, etc.

@jddarcy

jddarcy commented Jul 16, 2026

Copy link
Copy Markdown
Member

Other than the small edit to the text, I think the only remaining task is to add cross references in non-javadoc comments in the affected files, the wrapper classes, etc. to this information.

@liach

liach commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

@dansmithcode Do you think a one liner in each of the migrated class like:

// See doc/value-class-preview.md for how value classes are declared in the Java Platform APIs.

would be the best way forward? Feel free to suggest exact wording too.

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

Labels

rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

4 participants