Skip to content

First cut grammar changes for Value Types (Value Classes and Objects)#5088

Open
mpalat wants to merge 5 commits into
eclipse-jdt:VALCO_PDOT_1from
mpalat:valtypes_grammar_on_VALCO
Open

First cut grammar changes for Value Types (Value Classes and Objects)#5088
mpalat wants to merge 5 commits into
eclipse-jdt:VALCO_PDOT_1from
mpalat:valtypes_grammar_on_VALCO

Conversation

@mpalat

@mpalat mpalat commented May 29, 2026

Copy link
Copy Markdown
Contributor

What it does

Grammar changes for issue #4479.

  • First cut changes with a couple of tests.
  • Need to add more tests
  • Further refinement maybe required.

How to test

Use the junit tests providided at ValueClassesAndObjectsTest

Author checklist

@mpalat mpalat self-assigned this May 29, 2026

@stephan-herrmann stephan-herrmann 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.

I couldn't hold my horses from browsing through these changes and dropping a few very superficial remarks here and there ...

@mpalat

mpalat commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

@stephan-herrmann - Thanks for the review comments - unfortunately I saw your comments after pushing another commit just now to the PR. I will address those review comments in a following commit soon.

@mpalat mpalat marked this pull request as draft June 2, 2026 06:09
@mpalat mpalat added this to the MilestoneNxt milestone Jun 2, 2026

@stephan-herrmann stephan-herrmann 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.

Some more comments :)

@stephan-herrmann

Copy link
Copy Markdown
Contributor

Despite my nitpicky comments, I'd like to get a somewhat broader picture:

  • Is this PR ready for removal of "Draft" and building on jenkins?
  • If it's really only about grammar, what further steps do you plan before merging?
  • Should we first update the target branch from master?

Background: I made a first walk through of specification changes, and would like to start implementing individual new rules soonish.

@mpalat mpalat force-pushed the valtypes_grammar_on_VALCO branch from ed0ada1 to 0a861c4 Compare June 18, 2026 04:28
@stephan-herrmann

Copy link
Copy Markdown
Contributor

No, intended to serve as common to many AbstractReTest. Yet to determine which all tests can derive from this.

So the purpose of this class remains unclear. Yet not a blocker for this PR.

@mpalat mpalat marked this pull request as ready for review June 18, 2026 17:05
@mpalat

mpalat commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Despite my nitpicky comments, I'd like to get a somewhat broader picture:

  • Is this PR ready for removal of "Draft" and building on jenkins?

Yes, I 've moved it to Ready for Review

  • If it's really only about grammar, what further steps do you plan before merging?

The primary purpose was only about grammar. Some essential changes in other areas (like AST etc) was done, but grammar changes are the essentials. So, from that perspective, no further changes for this PR is envisaged.

  • Should we first update the target branch from master?

Yes, did that - VALCO_PDOT_1 was merged from master now.

Background: I made a first walk through of specification changes, and would like to start implementing individual new rules soonish.

sure. Am also going through the specs in more detail - quite a lot of small number of changes, I believe

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces first-cut Java 26 (preview) grammar and DOM updates for “Value Classes and Objects”, primarily by treating value as a restricted identifier/modifier and plumbing it through the scanner/parser/DOM layers.

Changes:

  • Add value as a restricted identifier token (scanner, terminal symbols, parser tables/grammar).
  • Expose value as a DOM modifier (Modifier.VALUE / VALUE_KEYWORD) and wire it into DOM conversion/rewrite utilities.
  • Add initial regression tests and a small shared preview-test base class.

Reviewed changes

Copilot reviewed 28 out of 48 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java Map new value restricted-identifier token to public terminal symbols.
org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ITerminalSymbols.java Add TokenNameRestrictedIdentifiervalue constant.
org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/util/DOMASTUtil.java Gate DOM support for the new VALUE modifier based on JLS26+preview.
org.eclipse.jdt.core/dom/org/eclipse/jdt/internal/core/dom/rewrite/ASTRewriteAnalyzer.java Preserve/emit value modifier during AST rewrite.
org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java Include VALUE in computed/valid type modifiers.
org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java Add VALUE modifier bit + keyword + helpers.
org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java Convert parser token RestrictedIdentifiervalue into DOM Modifier.VALUE_KEYWORD.
org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java Create value modifiers via newModifiers(int flags).
org.eclipse.jdt.core/.settings/.api_filters Add API filter entry for the new VALUE_KEYWORD.
org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java Extend modifier-related DOM tests to cover VALUE.
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ValueClassesAndObjectsTest.java New regression tests for restricted identifier + basic parsing scenario.
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java Hook (currently commented) test into the Java 26 suite bucket.
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ScannerTest.java Extend restricted keyword token API test to include value.
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java Update commented test selector line (non-functional).
org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTestCommon.java New base class to force preview enablement and align javac options.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/util/Messages.java Add message key field for “value classes and objects”.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java Add restricted-identifier normalization for value.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/TerminalToken.java Add TokenNameRestrictedIdentifiervalue and mark it restricted.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java Recognize value and disambiguate via lookahead/feature gating.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java Update generated parser constants (terminals/states/rules/etc.).
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java Update generated parser switch + consumeToken handling for value.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java Treat value as a token candidate during qualified-name parsing.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/messages.properties Add “value_classes_and_objects” message text.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java Add VALUE_RESTRICTED_IDENTIFIER constant.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java Add default isValue() hook on compiler type bindings.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ExtraCompilerModifiers.java Add AccValue modifier bit.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java Add VALUE_CLASSES_AND_OBJECTS feature and restricted keyword metadata.
org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java Add AccIdentity constant alias.
org.eclipse.jdt.core.compiler.batch/grammar/java.g Add terminal and modifier production for RestrictedIdentifiervalue.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* <b>default</b>
* <b>sealed</b>
* <b>non-sealed</b>
* <b>value<b>
* Community Process (JCP) and is made available for testing and evaluation purposes
* only. The code is not compatible with any specification of the JCP.
*
* * Contributors:
Comment on lines +122 to +125
VALUE_CLASSES_AND_OBJECTS(ClassFileConstants.JDK26,
Messages.bind(Messages.primitives_in_patterns),
new char[][] {TypeConstants.VALUE_RESTRICTED_IDENTIFIER},
true),
Comment on lines 685 to 687
Modifier ::= Annotation
Modifier -> RestrictedIdentifiervalue
/.$putCase consumeAnnotationAsModifier(); $break ./
Comment on lines +6733 to 6734
case 209 : if (DEBUG) { System.out.println("Modifier -> RestrictedIdentifiervalue"); } //$NON-NLS-1$
consumeAnnotationAsModifier(); break;
Comment on lines +4 to +6
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
Comment on lines +4 to +6
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
PrimitiveInPatternsTest.class,
PrimitiveInPatternsTestSH.class,
Unicode17Test.class,
// ValueClassesAndObjectsTest.class,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants