Community
Participate
Working Groups
build I20061003-0800 package p; public class M1 { public void foo() {} /** @deprecated */ public class M2 { public void foo() {} public class M3 { public void foo() {} } } void bar() { a.N1.N2.N3 m = null; m.foo(); } } package a; public class N1 { public void foo() {} /** @deprecated */ public class N2 { public void foo() {} public class N3 { public void foo() {} } } void bar() { } } When i do a full build of a workspace with these two class there is no warning. But if i edit M1 and do an incremental build then the warnings to signal deprecated references are present.
With these two classes the deprected references are correctly detected in N1.java package p; public class M1 { public void foo() {} /** @deprecated */ public class M2 { public void foo() {} public class M3 { public void foo() {} } } void bar() { a.N1.N2.N3 m = null; m.foo(); } } package a; public class N1 { public void foo() {} /** @deprecated */ public class N2 { public void foo() {} public class N3 { public void foo() {} } } void bar() { p.M1.M2.M3 m = null; m.foo(); } }
The bug is the same if you replace the javadoc tag by the @Deprecated annotation package p; public class M1 { public void foo() {} @Deprecated public class M2 { public void foo() {} public class M3 { public void foo() {} } } void bar() { a.N1.N2.N3 m = null; m.foo(); } } package a; public class N1 { public void foo() {} @Deprecated public class N2 { public void foo() {} public class N3 { public void foo() {} } } void bar() { p.M1.M2.M3 m = null; m.foo(); } }
Reproduced. Added DeprecatedTest#test015 to 018, Deprecated15Tests#test002 and DependencyTests#test0100, of which all but two are inactive.
The issue came from the fact that, in case of a forward reference to a member type, the deprecation detection started with the said member type and omitted to climb up the enclosing types chain to detect potential implicit deprecation.
Created attachment 51832 [details] Fix + test cases tuning
Released for 3.3 M3.
I would have written the MemberTypeBinding override as: public void initializeDeprecatedAnnotationTagBits() { if ((this.tagBits & (TagBits.AnnotationResolved|TagBits.AnnotationDeprecated)) == 0) { super.initializeDeprecatedAnnotationTagBits(); if ((this.tagBits & TagBits.AnnotationDeprecated) == 0) { // check enclosing for propagatin ReferenceBinding enclosing = this.enclosingType(); enclosing.initializeDeprecatedAnnotationTagBits(); if ((enclosing.modifiers & (ClassFileConstants.AccDeprecated | ExtraCompilerModifiers.AccDeprecatedImplicitly)) != 0) { this.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; } } } }
What about local types ?
Opened bug 161214 for fup items.
Verified for 3.3 M3 using warm-up build I20061030-0800