Warning message "uses or cancels deprecated API" that occurs when compiling code

I compiled my program and I got the following error. How to resolve it?

Note: ClientThreadClients.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 
+7
java multithreading
source share
2 answers

What you have to do is what the warning messages say. Recompile this class with the -Xlint:deprecation parameter.

The compiler will then tell you which deprecated API you are using or overriding.

Alternatively, if you showed us the source code for this class, we can determine the problem for you ... or compile it yourself.


But I'm going to guess that you are using one of the deprecated methods in the Thread class:

  • countStackFrames()
  • destroy()
  • pause()
  • resume()
  • stop()
  • stop(Throwable)
  • suspend()

These methods are either unreliable or unsafe, or both. You are strongly advised not to use them. Read this explanation: Why are Thread.stop, Thread.suspend, and Thread.resume deprecated? "

+11
source share

Step 1: Find out which deprecated API the code is using. If you use a modern IDE (eclipse or a similar tool), outdated code will be clearly marked, usually with a crossed out font. If you are compiling from the command line, add -Xlint:deprecation to the command line when compiling.

Step 2. Read the documentation for the legacy API to find out how to replace it.

+4
source share

All Articles