Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:38:22+00:00 2026-06-13T11:38:22+00:00

I am trying to use the @Deprecated annotation . The @Deprecated documentation says that:

  • 0

I am trying to use the @Deprecated annotation. The @Deprecated documentation says that: “Compilers warn when a deprecated program element is used or overridden in non-deprecated code”. I would think this should trigger it, but it did not. javac version 1.7.0_09 and compiled using and not using -Xlint and
-deprecation.

public class TestAnnotations {

   public static void main(String[] args)
   {
      TestAnnotations theApp = new TestAnnotations();
      theApp.thisIsDeprecated();
   }

   @Deprecated
   public void thisIsDeprecated()
   {
      System.out.println("doing it the old way");
   }
}

Edit: per the comment of gd1 below regarding it only working if the method is in another class, I added a second class. And it DOES WARN on the call to theOldWay():

public class TestAnnotations {

   public static void main(String[] args)
   {
      TestAnnotations theApp = new TestAnnotations();
      theApp.thisIsDeprecated();
      OtherClass thatClass = new OtherClass();
      thatClass.theOldWay();
   }

   @Deprecated
   public void thisIsDeprecated()
   {
      System.out.println("doing it the old way");
   }
}

class OtherClass {

   @Deprecated
   void theOldWay()
   {
      System.out.println("gone out of style");
   }


}

The warning:

/home/java/TestAnnotations.java:10: warning: [deprecation]
theOldWay() in OtherClass has been deprecated

    thatClass.theOldWay();
             ^

1 warning

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:38:23+00:00Added an answer on June 13, 2026 at 11:38 am

    From the Java Language Specification:

    A Java compiler must produce a deprecation warning when a type,
    method, field, or constructor whose declaration is annotated with the
    annotation @Deprecated is used (i.e. overridden, invoked, or
    referenced by name), unless:

    • The use is within an entity that is itself annotated with the annotation @Deprecated; or

    • The use is within an entity that is annotated to suppress the warning with the annotation @SuppressWarnings(“deprecation”); or

    • The use and declaration are both within the same outermost class.

    Your example is an example of the last condition: you’re only using the deprecated method from the same outermost class as the deprecated method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use the correct (non-deprecated) versions of Add/checkout/commit etc, but these
I'm trying to use the function [context].startSubActivity([intent i]) but that won't compile. Apparently startSubActivity()
I was trying to use Seq.first today, and the compiler says it has been
I am trying to use std::shared_ptr in my code. I have seen there have
I'm trying to use Assembly.Load() to load an assembly that is in the GAC.
I am trying to use the code below however Xcode tells me UIKeyboardBoundsUserInfoKey is
While trying to use Facebook's mobile authentication, I realized that they don't set any
I've been trying to use the code here: http://snafu.diarrhea.ch/blog/article/4-serving-static-content-with-rails but I'm getting errors like:
I am trying to use a PageAdapter. I found out that public Object instantiateItem(
I'm trying to use std::mem_fun_ref (Yes, the deprecated version. Reasons below) to call a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.