当前位置: 技术问答>java相关
如果我使用或者覆盖了一个不鼓励使用的API,会有什么后果,我怎么知道那些API不鼓励覆盖?
来源: 互联网 发布时间:2015-04-02
本文导语: ? | 无后果,放心的用吧。 | javac -deprecation | 不会有问题的,但最好不要用! 如果是不鼓励使用的话,会在JDKDOC中说明的,比如THEAD中的STOP方法: Deprecate...
?
|
无后果,放心的用吧。
|
javac -deprecation
|
不会有问题的,但最好不要用!
如果是不鼓励使用的话,会在JDKDOC中说明的,比如THEAD中的STOP方法:
Deprecated. This method is inherently unsafe. See stop() (with no arguments) for details. An additional danger of this method is that it may be used to generate exceptions that the target thread is unprepared to handle (including checked exceptions that the thread could not possibly throw, were it not for this method). For more information, see Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?.
如果是不鼓励使用的话,会在JDKDOC中说明的,比如THEAD中的STOP方法:
Deprecated. This method is inherently unsafe. See stop() (with no arguments) for details. An additional danger of this method is that it may be used to generate exceptions that the target thread is unprepared to handle (including checked exceptions that the thread could not possibly throw, were it not for this method). For more information, see Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?.
|
现在没有什么,但是再将来新的版本中,这些方法也许会不再别支持.所以兼容将来的版本会有问题.
在编译的时候通过java -deprecation可以得到警告.
在编译的时候通过java -deprecation可以得到警告.