JDK-6177893 : Guard against the invocation of static methods via instances (-Xlint)
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2004-10-12
  • Updated: 2013-09-13
  • Resolved: 2004-10-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6Resolved
Related Reports
Duplicate :  
Relates :  
Description
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

Comments
EVALUATION This is a very reasonable request. It would make a nice addition to our effort to improve diagnostics by providing -Xlint. ###@###.### 10/18/04 16:36 GMT
12-10-2004