• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to mark a method deprecated

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to deprecate a method in Java? If I place an @deprecated tag into the javadoc will it generate the compile time warnings on using a depricated method?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you try it yourself and see what the compiler says?

In Java 1.4 and older, you would use the @deprecated Javadoc tag for this:


In Java 5.0 and newer, you should use the @Deprecated annotation (although the old Javadoc tag will also still work):
 
Isuru Sampath
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. Will try it out.
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jesper Young:
Why don't you try it yourself and see what the compiler says?

In Java 1.4 and older, you would use the @deprecated Javadoc tag for this:


In Java 5.0 and newer, you should use the @Deprecated annotation (although the old Javadoc tag will also still work):



FWIW, I recall reading somewhere a recommendation (that made sense - but I forget the detail of the reasoning - probably something to do with compiling to earlier targets) to use both the language annotation and the javadoc annotation for 1.5+
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tony Morris:
FWIW, I recall reading somewhere a recommendation (that made sense - but I forget the detail of the reasoning - probably something to do with compiling to earlier targets) to use both the language annotation and the javadoc annotation for 1.5+



Beyond that, does the @Deprecated annotation show up in Javadocs?
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ken Blair:


Beyond that, does the @Deprecated annotation show up in Javadocs?



Yes it does. You will notice that the Deprecated annotation is annotated with the @Documented annotation. All such annotations appear in the javadoc.
 
pie. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic