How can I suppress javac warnings about deprecated api?

前端 未结 9 994
遥遥无期
遥遥无期 2020-12-09 01:40

When I compile, javac outputs:

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.`
相关标签:
9条回答
  • 2020-12-09 02:08

    Two possible ways:

    1. don't use deprecated API
    2. Use @SuppressWarnings("deprecation")
    0 讨论(0)
  • 2020-12-09 02:09

    @SuppressWarnings("deprecation") is not working for me, instead I've used

    @SuppressWarnings("unchecked")
    
    0 讨论(0)
  • 2020-12-09 02:10

    With Java 6, neither the @Depreated annotation, nor a comiler flag will help you here. The only solution that worked for me was to put a javadoc comment with the @deprecated (small caps) tag on the deprecated method:

    /**
      * @deprecated overriding deprecated method
      */
    @Override
    public javax.xml.bind.Validator createValidator() throws JAXBException {...}
    

    (The example is from a class that derives from JAXBContext.)

    (I didn't import the deprecated Validator class to avoid a warning on the import statement.)

    0 讨论(0)
提交回复
热议问题