Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Deprecated Class using a Deprecated Class -- Can I turn off the compiler warning?
    primarykey
    data
    text
    <p>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.</p> <p>Here is a quick example:</p> <p>First class:</p> <pre><code>/** * @deprecated No longer in use. **/ @Deprecated public class OldSubClass { } </code></pre> <p>Second class:</p> <pre><code>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 ... } </code></pre> <p>Okay, this is the bare minimum that allows me to reproduce the problem (even with @SupressWarnings turned on:</p> <p>Mother class:</p> <pre><code>import another.pack.ChildClass; @SuppressWarnings("deprecation") public class MotherClass { } </code></pre> <p>Child class:</p> <pre><code>package another.pack; /** * @deprecated */ public class ChildClass { } </code></pre> <p>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).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload