Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6218903

Calling deprecated method from its main method does not give compile time warinings.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Not an Issue
    • Affects Version/s: 6
    • Fix Version/s: 6
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Tried on Solaris-9 JDK 1.6.0-ea-b15

      If a deprecated method is called from it's own main method, there is no warning. eg. See the following testcase, deprecated dep.doit() called from dep.main() does not give a warning. But if dep.doit() is called from another class foo.main(), it gives a warning.

      Testcase:
      class dep {
        /**
         *@deprecated test deprecation message from compiler
         * Compare to pre 1.5 by comment out deprecated annotation
         */
         @Deprecated
         public void doit(){
           String msg = "doit that takes no args";
           System.out.println(msg);
         }

        /**
         *@deprecated test deprecation message from compiler
         * Compare to pre 1.5 by comment out deprecated annotation
         */
         @Deprecated
         public void doit(String msg){
           System.out.println(msg);
         }

         //This does NOT get deprecation warnings.
         public static void main(String[] args) {
          dep d = new dep();
          d.doit();
          d.doit("called from dep's main");
         }
      }

      public class foo {
        public static void main(String[] args) {
          dep d = new dep();
          d.doit("called from foo's main");
        }
      }

      Execute:
       javac -Xlint:deprecation foo.java

      Output :
      foo.java:33: warning: [deprecation] doit(java.lang.String) in dep has been deprecated
          d.doit("called from foo's main");
           ^
      1 warning



      ###@###.### 2005-1-19 10:51:47 GMT

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              savadhansunw Seetharama Avadhanam (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: