Skip to content

Fix deprecation warning suppression for inherited interface methods#12

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/add-testcase-for-regression
Draft

Fix deprecation warning suppression for inherited interface methods#12
Copilot wants to merge 3 commits intomasterfrom
copilot/add-testcase-for-regression

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 26, 2025

Fixes regression from PR eclipse-jdt#4293 where deprecation warnings were incorrectly suppressed when calling deprecated methods through inherited interfaces, causing @SuppressWarnings("deprecation") to be flagged as unnecessary.

Problem

// BaseInterface.java
public interface BaseInterface {
    /** @deprecated */
    void method();
}

// DerivedInterface.java  
public interface DerivedInterface extends BaseInterface {}

// Caller.java
void test(DerivedInterface obj) {
    obj.method(); // No deprecation warning emitted
}

Root Cause

ASTNode.isMethodUseDeprecated() incorrectly reused the isExplicitUse flag (introduced for access restriction checking) to suppress deprecation warnings for non-directly-declared method calls.

Changes

  • Compiler fix: Removed lines 551-554 in ASTNode.isMethodUseDeprecated() that suppressed deprecation warnings when !isExplicitUse && !@Deprecated
  • Tests: Added testInheritedInterfaceDeprecatedMethod() and testInheritedInterfaceDeprecatedMethodWithSuppressWarnings() to verify correct behavior

Deprecation warnings now emit for all deprecated methods regardless of inheritance hierarchy. Access restriction behavior remains unchanged (correctly checks only explicit uses).

Addresses TODO comment: "consider separating concerns between deprecation and access restriction"

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.compiler.batch,org.eclipse.jdt.core.tests.compiler -am -DskipTests (dns block)

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

Original prompt

Analyze eclipse-jdt#4553

The issue indicates we have a regression, possibly from eclipse-jdt#4293

We should

  • create a testcase for this particular case (calling a deprecated method through an inherited interface method)
  • check if it is a regression from the code change about access restrictions

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

Copilot AI self-assigned this Oct 26, 2025
Copilot AI and others added 2 commits October 26, 2025 06:41
…cated method

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
… deprecation warnings

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add testcase for deprecated method regression Fix deprecation warning suppression for inherited interface methods Oct 26, 2025
Copilot AI requested a review from laeubi October 26, 2025 06:50
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