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

Deprecation warnings are not suppressed in lambdas of deprecated methods #1370

Closed
Madjosz opened this issue Sep 12, 2023 · 2 comments · Fixed by #1460
Closed

Deprecation warnings are not suppressed in lambdas of deprecated methods #1370

Madjosz opened this issue Sep 12, 2023 · 2 comments · Fixed by #1460
Assignees

Comments

@Madjosz
Copy link

Madjosz commented Sep 12, 2023

Transfer of Bug 562113

Problem

Adding @Deprecated to a method normally tells the compiler to ignore all deprecation warnings in that method. This fails for calls to deprecated methods in a lambda in the deprecated method.

Example

public class IamDeprecated {
  @Deprecated
  static void deprecatedMethod(Object o) {}
}

public class DeprecationWarning {
  @Deprecated
  void callDeprecated() {
    IamDeprecated.deprecatedMethod(null);                   // no warning
    List.of().forEach(IamDeprecated::deprecatedMethod);     // no warning
    List.of().forEach(o -> IamDeprecated.deprecatedMethod(o)); // warning
  }
}

Expected behaviour

javac -Xlint:deprecation shows no deprecation warnings in all 3 cases.

Additional: @SuppressWarnings("deprecation") will suppress all 3 warnings when callDeprecated() is not @Deprecated (and also when it is)

System information

Eclipse SDK
Version: 2023-12 (4.30)
Build id: I20230911-1800

openjdk version "20.0.2" 2023-07-18
OpenJDK Runtime Environment Temurin-20.0.2+9 (build 20.0.2+9)
OpenJDK 64-Bit Server VM Temurin-20.0.2+9 (build 20.0.2+9, mixed mode, sharing)

Microsoft Windows 10 Pro 10.0.19045

@jjohnstn jjohnstn transferred this issue from eclipse-jdt/eclipse.jdt.ui Sep 12, 2023
@srikanth-sankaran srikanth-sankaran self-assigned this Sep 12, 2023
@srikanth-sankaran
Copy link
Contributor

I'll take a look

@srikanth-sankaran srikanth-sankaran linked a pull request Oct 2, 2023 that will close this issue
3 tasks
srikanth-sankaran added a commit that referenced this issue Oct 2, 2023
…1460)

We should not emit deprecation warnings inside a LE if that features in a deprecated context itself

Fixes #1370
and its duplicate https://bugs.eclipse.org/bugs/show_bug.cgi?id=562113
@Madjosz
Copy link
Author

Madjosz commented Oct 4, 2023

Confirmed works in I20231004-0320.
Thank you for fixing this long lasting bug! 🚀

robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Jul 18, 2024
…clipse-jdt#1460)

We should not emit deprecation warnings inside a LE if that features in a deprecated context itself

Fixes eclipse-jdt#1370
and its duplicate https://bugs.eclipse.org/bugs/show_bug.cgi?id=562113
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 a pull request may close this issue.

2 participants