This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 245860 - Deprecation warning is shown on implementation of deprecated method
Summary: Deprecation warning is shown on implementation of deprecated method
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-21 22:22 UTC by matthies
Modified: 2014-08-20 08:59 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description matthies 2014-07-21 22:22:45 UTC
Example:

A.java:
public interface A
{
    @Deprecated void foo();
}

B.java:
public class B implements A
{
    @SuppressWarnings("deprecation")
    public void foo() { }
}

A deprecation warning is shown on the implementation of foo() in spite of the @SuppressWarnings annotation.

In my opinion, the deprecation warning should not be shown even in absence of a @SuppressWarnings annotation, because an implementation of interface A necessarily has to implement foo(), deprecated or not. I.e. there is nothing to warn about in this situation.
Comment 1 Svata Dedic 2014-08-08 06:15:30 UTC
Javac reports override deprecation even if @SuppressWarnings is present on the overriding method - that's why NetBeans hint behave the same. Move @SuppressWarnings("deprecation") to the class decl to suppress deprecations throughout the class.

I have some doubts the compiler behaviour is correct, since the javadoc for @SuppressWarnings says that it suppresses warnings for the specific element - so it should be able to suppress deprecation for an individual method.

JLahoda may have additional comments on javac (desired) behaviour.
Comment 2 Jan Lahoda 2014-08-20 08:59:11 UTC
Regarding producing the warning when overriding a deprecated method (without @SuppressWarnings), that is specifically mandated by the JLS to my knowledge (JLS 9.6.4.6.).

@SuppressWarnings should obviously suppress the warning, this has been fixed as:
https://bugs.openjdk.java.net/browse/JDK-8033421
in JDK 9 codebase. I'll look into backporting options.