Skip to content

Add unit test for release-specific SearchableEnvironment handling#11

Draft
Copilot wants to merge 3 commits intoissue_4399from
copilot/add-reconciler-unit-test
Draft

Add unit test for release-specific SearchableEnvironment handling#11
Copilot wants to merge 3 commits intoissue_4399from
copilot/add-reconciler-unit-test

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 22, 2025

This PR adds a comprehensive unit test to validate the fix for issue eclipse-jdt#4399, which addresses how SearchableEnvironment determines whether to enable Java 9+ features (like module support) when processing release-specific source folders.

Background

In PR eclipse-jdt#4529, SearchableEnvironment.java was updated to check both the release parameter and the project compliance level when determining if Java 9+ features should be enabled:

boolean java9plus = release >= JavaProject.FIRST_MULTI_RELEASE || 
    JavaCore.callReadOnly(() -> CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_COMPLIANCE, true)) >= ClassFileConstants.JDK9);

Previously, only the project compliance level was checked, which meant that source folders with release=9 or higher would not have Java 9+ features enabled if the overall project was set to Java 8 or lower.

Test Implementation

This PR adds testReleaseSpecificReconciliation() to ReconcilerMultiReleaseTests to verify the fix works correctly. The test:

  1. Uses a Java 8 project with JCL18_LIB but includes source folders with release=9 and release=21 attributes
  2. Tests cross-release type resolution by verifying that code in the release=21 folder can reference:
    • Types from the base source folder (release-agnostic)
    • Types and members from the release=9 folder
    • Types and members from the release=21 folder
  3. Validates reconciliation succeeds without errors, confirming that SearchableEnvironment correctly uses the release attribute to enable Java 9+ features

Example Scenario

The test validates this multi-release structure:

// Base src/p/A.java - available at all levels
public class A { }

// src9/p/B.java - Java 9 version
public class B {
    A fieldA;  // Added in Java 9
}

// src9/p/C.java - Only available in Java 9+
class C { }

// src21/p/B.java - Java 21 version
public class B {
    A fieldA;
    C fieldC;  // Added in Java 21
    public void m() { }  // Added in Java 21
}

// src21/p/D.java - Test reconciliation
public class D {
    void m(B b) {
        A a = b.fieldA;  // OK: A from src, fieldA from src9+
        C c = b.fieldC;  // OK: C from src9, fieldC from src21+
        b.m();           // OK: m() from src21+
    }
}

The test ensures that reconciliation of D.java completes without errors, validating that the release-specific SearchableEnvironment correctly resolves all types and members across different release levels.

Fixes eclipse-jdt#4399

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.eclipse.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/eclipse.jdt.core/eclipse.jdt.core org.codehaus.plexus.classworlds.launcher.Launcher clean compile -pl org.eclipse.jdt.core.tests.model -am -DskipTests (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Propose a unit test for the new feature

In eclipse-jdt#4529 there was asked for a new testcase in ReconcilerMultiReleaseTests, please suggest to enhance the test to cover the change in this branch.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

laeubi and others added 2 commits October 17, 2025 06:05
Currently in SearchableEnvironment we only check if the project level is
larger java9plus but when constructing a release specific
SearchableEnvironment this needs to take the release option into account
instead.

Fix eclipse-jdt#4399
Added testReleaseSpecificReconciliation() to verify that SearchableEnvironment
correctly enables Java 9+ features based on the release attribute of source
folders, not just the project compliance level.

The test validates the fix for issue eclipse-jdt#4399 where code in a release=21 folder
can correctly reference types and members across different release levels
(base src, release=9, and release=21) even when the project uses JCL18_LIB.

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit test for ReconcilerMultiRelease feature Add unit test for release-specific SearchableEnvironment handling Oct 22, 2025
Copilot AI requested a review from laeubi October 22, 2025 10:27
@laeubi laeubi force-pushed the issue_4399 branch 3 times, most recently from 47cfb3e to 64eb2e5 Compare November 3, 2025 11:02
@laeubi laeubi force-pushed the issue_4399 branch 3 times, most recently from 12fad88 to 6165d65 Compare November 11, 2025 14:35
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.

2 participants