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

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P4
    • 6
    • Affects Version/s: 5.0
    • Component/s: 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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: