I am working on deprecating a set of Java classes so they aren't used anymore. I don't want to turn off the compiler warnings for deprecated usage, but I'm finding that if one of my deprecated classes imports another deprecated class I get a warning on that, too. I don't want to modify the code I'm deprecating, but I also don't want the warning for those cases. Is there a way to (a) annotate / comment the code to disable the warning (b) turn off compiler warnings in these cases? I'm using NetBeans, so if there is a NetBeans specific way, that works, too.
Here is a quick example:
First class:
/**
* @deprecated No longer in use.
**/
@Deprecated
public class OldSubClass {
}
Second class:
import com.old.package.OldSubClass; // Don't want this to create a warning
/**
* @deprecated No longer in use.
**/
@Deprecated
public class OldClass {
// code that makes use of OldSubClass that I don't want to change ...
// Any methods that use OldSubClass are also deprecated ...
}
Okay, this is the bare minimum that allows me to reproduce the problem (even with @SupressWarnings turned on:
Mother class:
import another.pack.ChildClass;
@SuppressWarnings("deprecation")
public class MotherClass {
}
Child class:
package another.pack;
/**
* @deprecated
*/
public class ChildClass {
}
Note that it is the JavaDoc @deprecated tag that even allows the compiler to throw the warning. If I only use the @Deprecated annotation, I never get the warning (even without the supress).