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

Guard against the invocation of static methods via instances (-Xlint)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • 6
    • 5.0
    • tools
    • generic
    • generic

      Date: Fri, 08 Oct 2004 16:38:18 -0700
      From: Bill Shannon <###@###.###>

      In JavaMail the Transport class has a static "send" message and a
      non-static "sendMessage" method. A common error is to create
      your own Transport instance and then invoke the send method on
      the instance instead of the sendMessage method.

      I'd like javac to give me a warning when a static method is invoked
      on an instance. Seeing as how javac doesn't produce warnings by
      default, I assume this would be a lint-like warning that you would
      have to explicitly enable.

      I'd also like an annotation that I could apply to a static method
      that made it an error to invoke that method on an instance. Or,
      possibly this would just cause javac to produce this warning by
      default.
      ###@###.### 10/12/04 20:26 GMT

            Unassigned Unassigned
            mr Mark Reinhold
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: