-
Enhancement
-
Resolution: Cannot Reproduce
-
P5
-
None
-
6u10
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
@Deprecated on an overridden method whose return type is deprecated should not generated a deprecation warning at compile time. This kind of warning was found in Tiger when extending sun.awt.FontConfiguration and implementing the getDefaultFontCharset method, whose return type CharToByteConverter is deprecated. A sample program shows that the same behavior occurs in Mustang. Using a @deprecated javadoc instead of the annotation removes the warning.
JUSTIFICATION :
If the method itself is deprecated, there's no need to generate a warning about its return type being deprecated. A warning should be generated if the method itself is used. The annotation should act like the javadoc and prevent the compiler to generate a warning.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In the following program, I would not expect SomethingElse#getInfo to generate a deprecation warning.
D:\temp\java>javac -Xlint:deprecation DeprecatedTest.java
DeprecatedTest.java:10: warning:[deprecation] DeprecatedClass in unnamed package has been deprecated
abstract public DeprecatedClass getInfo();
^
1 warnings
ACTUAL -
D:\temp\java>javac -Xlint:deprecation DeprecatedTest.java
DeprecatedTest.java:10: warning:[deprecation] DeprecatedClass in unnamed package has been deprecated
abstract public DeprecatedClass getInfo(); <-- ok
^
DeprecatedTest.java:16: warning:[deprecation] DeprecatedClass in unnamed package has been deprecated
public DeprecatedClass getInfo() { <-- ng
^
2 warnings
---------- BEGIN SOURCE ----------
class DeprecatedClass {
}
abstract class Something {
abstract public DeprecatedClass getInfo();
}
class SomethingElse {
@Deprecated
public DeprecatedClass getInfo() {
return null;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Using the @deprecated javadoc removes the warning.
@Deprecated on an overridden method whose return type is deprecated should not generated a deprecation warning at compile time. This kind of warning was found in Tiger when extending sun.awt.FontConfiguration and implementing the getDefaultFontCharset method, whose return type CharToByteConverter is deprecated. A sample program shows that the same behavior occurs in Mustang. Using a @deprecated javadoc instead of the annotation removes the warning.
JUSTIFICATION :
If the method itself is deprecated, there's no need to generate a warning about its return type being deprecated. A warning should be generated if the method itself is used. The annotation should act like the javadoc and prevent the compiler to generate a warning.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In the following program, I would not expect SomethingElse#getInfo to generate a deprecation warning.
D:\temp\java>javac -Xlint:deprecation DeprecatedTest.java
DeprecatedTest.java:10: warning:[deprecation] DeprecatedClass in unnamed package has been deprecated
abstract public DeprecatedClass getInfo();
^
1 warnings
ACTUAL -
D:\temp\java>javac -Xlint:deprecation DeprecatedTest.java
DeprecatedTest.java:10: warning:[deprecation] DeprecatedClass in unnamed package has been deprecated
abstract public DeprecatedClass getInfo(); <-- ok
^
DeprecatedTest.java:16: warning:[deprecation] DeprecatedClass in unnamed package has been deprecated
public DeprecatedClass getInfo() { <-- ng
^
2 warnings
---------- BEGIN SOURCE ----------
class DeprecatedClass {
}
abstract class Something {
abstract public DeprecatedClass getInfo();
}
class SomethingElse {
@Deprecated
public DeprecatedClass getInfo() {
return null;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Using the @deprecated javadoc removes the warning.