First cut grammar changes for Value Types (Value Classes and Objects)#5088
First cut grammar changes for Value Types (Value Classes and Objects)#5088mpalat wants to merge 5 commits into
Conversation
stephan-herrmann
left a comment
There was a problem hiding this comment.
I couldn't hold my horses from browsing through these changes and dropping a few very superficial remarks here and there ...
|
@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. |
stephan-herrmann
left a comment
There was a problem hiding this comment.
Some more comments :)
|
Despite my nitpicky comments, I'd like to get a somewhat broader picture:
Background: I made a first walk through of specification changes, and would like to start implementing individual new rules soonish. |
ed0ada1 to
0a861c4
Compare
So the purpose of this class remains unclear. Yet not a blocker for this PR. |
Yes, I 've moved it to Ready for Review
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.
Yes, did that - VALCO_PDOT_1 was merged from master now.
sure. Am also going through the specs in more detail - quite a lot of small number of changes, I believe |
There was a problem hiding this comment.
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
valueas a restricted identifier token (scanner, terminal symbols, parser tables/grammar). - Expose
valueas 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: |
| VALUE_CLASSES_AND_OBJECTS(ClassFileConstants.JDK26, | ||
| Messages.bind(Messages.primitives_in_patterns), | ||
| new char[][] {TypeConstants.VALUE_RESTRICTED_IDENTIFIER}, | ||
| true), |
| Modifier ::= Annotation | ||
| Modifier -> RestrictedIdentifiervalue | ||
| /.$putCase consumeAnnotationAsModifier(); $break ./ |
| case 209 : if (DEBUG) { System.out.println("Modifier -> RestrictedIdentifiervalue"); } //$NON-NLS-1$ | ||
| consumeAnnotationAsModifier(); break; |
| * 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/ |
| * 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, |
What it does
Grammar changes for issue #4479.
How to test
Use the junit tests providided at ValueClassesAndObjectsTest
Author checklist