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

Merge BETA_JAVA23 into master #2979

Merged
merged 71 commits into from
Sep 18, 2024
Merged

Merge BETA_JAVA23 into master #2979

merged 71 commits into from
Sep 18, 2024

Conversation

jarthana
Copy link
Member

@jarthana jarthana commented Sep 18, 2024

What it does

How to test

Author checklist

jarthana and others added 30 commits April 5, 2024 13:28
# Conflicts:
#	org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/impl/JavaFeature.java
#	org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Parser.java
#	org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java
#	org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/parser20.rsc
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_3.java
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_5.java
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SealedTypesTests.java
#	org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
#	org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/StringTemplateComponent.java
#	org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/StringTemplateExpression.java
#	org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
# Conflicts:
#	org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTStructuralPropertyTest.java
#	org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTTest.java
#	org.eclipse.jdt.core/.settings/.api_filters
#	org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
#	org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java

Change-Id: I4c62b1c99d15864bee1b82d4a2ac56c9be5c1ad0
…Patterns, instanceof, and Switch patterns (eclipse-jdt#2499)

* Issue eclipse-jdt#2298 - EP 455: Primitive Types in Patterns, instanceof, and
switch (Preview)

* Widening primitive conversion part

* Narrowing Primitive conversion

* Fixing the Testall and the NPE issue

* Fixing the test case issues due to features becoming standard or another
one becoming extinct

* widening and narrowing primitive conversion

- Rest of it will be addressed in subsequent pull requests
+ grammar & scanner
  - distinguish "import module.foo;" vs. "import module foo;"
    - even within module-info.java
+ resolving
+ errors reporting
+ implement reads() as reflexive property

general test work:
+ pull up reusable methods to new AbstractModuleCompilationTest
+ for tests using writeFilesCollecting
  + ensure testFileNames!=null implies shouldFlush*=false
+ run.javac improved for runConformModuleTest()
+ adjust ModuleCompilationTests.testReleaseOption15: new javac warn
specific tests regarding:
+ shadowing
+ ambiguity
+ accessibility
+ packages from requires transitive
+ redundant imports (flag as unused)
+ module import in CU in unnamed module
+ ambiguity from just one module import

fixes eclipse-jdt#2383

squashed version of
eclipse-jdt#2496
# Conflicts:
#	org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF
#	org.eclipse.jdt.core.compiler.batch/pom.xml
#	org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
#	org.eclipse.jdt.core.tests.compiler/pom.xml
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchPatternTest21.java
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UnnamedPatternsAndVariablesTest.java
#	org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/UseOfUnderscoreJava22Test.java
#	org.eclipse.jdt.core.tests.model/JCL/build.xml
#	org.eclipse.jdt.core.tests.model/META-INF/MANIFEST.MF
#	org.eclipse.jdt.core.tests.model/pom.xml
#	org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java
#	org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests21.java
#	org.eclipse.jdt.core/.settings/.api_filters
#	org.eclipse.jdt.core/META-INF/MANIFEST.MF
#	org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/StringTemplateComponent.java
#	org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/StringTemplateExpression.java
#	org.eclipse.jdt.core/pom.xml
API filter and problem constant need version bump after merging with master.
…dt#2685)

Preparation
+ renamed the feature from "Statements before Super" to 
  "Flexible Constructor Bodies"
+ move the main flag, let ClassScope manage early construction contexts

Implement updates for JEP 482:
+ change wording towards "early construction context"
+ determine early-ctor-ctx based on target class
+ fine tuning:
  - where should enclosing types be considered?
  - search for enclosings first
    but also consider their supers in a second round
+ reduce # mechanisms for detecting early construction context
+ allow assignment to fields of uninitialized instance
+ differentiate new errors:
  - FieldReadInEarlyConstructionContext
  - ThisInEarlyConstructionContext
  - AllocationInEarlyConstructionContext
  - MessageSendInEarlyConstructionContext
  - DuplicateExplicitConstructorCall
  - ConstructorCallNotAllowedHere
  - SuperFieldAssignInEarlyConstructionContext
  - AssignFieldWithInitializerInEarlyConstructionContext
+ generation of synth args and fields for enclosing instances
  - such synthetics allow to skip over unavailable enclosing instances 
    towards outer instances that are available

Documentation of key strategies as javadoc / code comments:
+ enablement: JavaFeature.FLEXIBLE_CONSTRUCTOR_BODIES
  2-step strategy
  - does compliance generally allow the use of this feature?
    already at this level we may suggest to enable the feature
  - is the preview feature enabled?
+ detection / analysis: ClassScope.insideEarlyConstructionContext
  - describes the combination of structural and temporary contexts
+ explicit vs implicit constructor calls: CD.resolveStatements()
  - code comment describing updated contract of CD.constructorCall
+ code gen: TypeDeclaration.manageEnclosingInstanceAccessIfNecessary()
  - code comment describing the strategy to generate synth args & fields
    for various outer classes, which orchestrates code generation

Fixes eclipse-jdt#2472
…nts (eclipse-jdt#2731)

The changes especially include the scanner changes to recognize the
markdown format and resolve, validate and report tags and references
inside the markdown comments.

* Fix failing formatter tests by changing tests. Tests are failing due to markdown being
converted to Javadoc without a distinction from regular Javadoc. This
needs to be addressed in DOM.
eclipse-jdt#2743 (eclipse-jdt#2750)

Make sure that compliance level is set regardless of the AST level. Also, this being a standard feature, preview flag is not required.
… (eclipse-jdt#2772)

Basic changes to CompletionScanner to recognize markdown comment blocks and associated tests
+ do expect ExplicitConstructorCall even in regular method

Fixes eclipse-jdt#2782
jarthana and others added 27 commits September 3, 2024 11:19
Preparation: + expose isMarkdown in DOM Javadoc

related to eclipse-jdt#2851
Restore ability to format Java in file with markdown comments:
+ avoid AssertionError in TokenManager.firstIndexIn
  visit(Javadoc) need to look for TokenNameCOMMENT_MARKDOWN specifically
+ fix infinite loop in tokenizeMultilineComment()
  - detect markdown comment
  - search for '/' not '*'
  - token should not include the final '\n'

Leave markdown comments unchanged by formatting for now

related to eclipse-jdt#2851
…eview) (eclipse-jdt#2866)

+ implement code generation for switch on primitive/boxed
+ new error for illegal constant type in switch on newly allowed type
+ systematic test combinatorics of primitives in instanceof / switch

See eclipse-jdt#2866 for details.
…#2878)

+ true + false = exhaustive over boolean :)
+ leverage PrimitiveConversionRoute for Pattern.coversType()
+ fine-tune combinations of primitive and boxing types
+ fix one omission in BaseTypeBinding.isExactWidening()
+ code gen to respect exhaustiveness of switch over primitives
+ fix code gen for bootstrap in the case of boxing+widening conversion
+ simplify condition for generating a throwing default
+ UNBOXING_CONVERSION is exhaustive (trivial case from 14.11.1.1)
+ implement WIDENING_REFERENCE_AND_UNBOXING_COVERSION and
  ..._AND_WIDENING_PRIMITIVE_CONVERSION
  - detect in Pattern.findPrimitiveConversionRoute()
  - adjust SwitchStatement.typeSwitchSignature()
  - generate in TypePattern.generateTestingConversion()
clarify code gen for BOXING_CONVERSION_AND_WIDENING_REFERENCE_CONVERSION
implement NARROWING_AND_UNBOXING_CONVERSION
+ InstanceOfExpression.generateTypeCheck()
+ TypePattern.generateTestingConversion()
+ Fixes for WIDENING_AND_NARROWING_PRIMITIVE_CONVERSION
  - must be checked before individual narrowing or widening
  - pattern doesn't cover its type
+ Implement remaining routes in InstanceOfExpression.generateTypeCheck()
  + those are unconditionally exact

Additional clean-up:
* clarify terminology for pairs of types
+ prefer 'provided' / 'expected' where possible
+ disentangle Pattern.outerExpressionType out ofExpression.expectedType
+ also connect to terms runtimeType vs. compileTimeType
* + tiny clean-up removing dead code

specific correct error message for incompatible case constant
+ fix bogus expectation in existing tests

fixes eclipse-jdt#2869
+ SuperAfterStatementsTest: new excuse JavacBug8207032
+ MarkdownCommentsTest
  - pass suitable arguments to javac and java
  - initialize reporting options only in one place (setUp())
  - remove unrelated errors for better comparison
  - fine tune problem severities for better comparison with javac
+ ModuleCompilationTests
  - adjust to current error messages from javac
+ RecordPatternTest: 1 EclipseWarningConfiguredAsError
 (eclipse-jdt#2894)

code gen for matching with primitive type pattern nested in record patt.
+ more locations to handle 1 or 2 byte pops, dups ... (generically)
+ extract IGenerateTypeCheck f. InstanceOfExpression.generateTypeCheck()
+ TypePattern to implement IGenerateTypeCheck, too.

fixes eclipse-jdt#2891
eclipse-jdt#2931)

* Rollback the change that relies on source level rather than compliance

* Bump up versions for reported bundles
…pse-jdt#2925)

+ precise implementation of TypePattern.isUnconditional()
   - remove implementations in parent / sibling classes
+ defer setting SwitchStatement.totalPattern until we know if a
  default case is present
  (otherwise we would generated inconsistent code for default).
+ clarify that flagDuplicateDefault() flags only conditionally,
  renamed to checkDuplicateDefault()
  - inside this method clarify that only one error is reported per loc.
+ remove all conflict reporting from CaseStatement.resolveCasePattern
  - will be done within SwitchStatement.resolve() anyway
+ remove IProblem.DuplicateTotalPattern and related code
  - all errors reported here coincided with a dominance error
+ adjust tests: no longer expect secondary errors

fixes eclipse-jdt#2915
eclipse-jdt#2953)

don't use the cached default import java.lang.* in implicitly declared classes.

fixes eclipse-jdt#2952
…clipse-jdt#2958)

when checking primitive conversions involving a type variable, always
use the superclass to find a boxing type, knowing that all boxing types
are classes, so other bounds are irrelevant.

fixes eclipse-jdt#2937
Change-Id: Ic9d5839d439d6f9a9e3160e5ba9deb033a61c7c3
@jarthana jarthana merged commit 983f530 into eclipse-jdt:master Sep 18, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants