JDK-6758789 : Some method resolution diagnostic should be improved
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2008-10-13
  • Updated: 2011-05-18
  • Resolved: 2011-05-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 7
7 b40Fixed
Related Reports
Relates :  
Relates :  
Description
The latest refactoring of diagnostic formatters (6720185) contained also an inprovement of method resolution error messages; that is instead of printing a message of the kind:

Test.java:8: test(X1, X2, ... Xn) in Test cannot be applied to (A1, A2, ... An)

javac now prints the following message:

Test.java:8: method test in class Test cannot be applied to given types
required: X1, X2 ... Xn
found: A1, A2 ... An

This diagnostic works better than the former one, as it is more compact and easier to read. However there is a problem with this diagnostic: since either the actual argument list or the formal argument list can be an empty list (no arguments accepted/provided) this causes weird error messages:

Test.java:8: method test in class Test cannot be applied to given types
required: 
found: A1, A2 ... An

The diagnostic output could be improved as follows:

Test.java:8: method test in class Test cannot be applied to given types
required: no arguments
found: A1, A2 ... An

Moreover, the diagnostic for unchecked method call should reflect this new layout; it currently sticks to the old layout for resolution errors:

Test2.java:8: warning: [unchecked] unchecked method invocation: <T>m2(Test<T>) in Test is applied to (Test)

instead of:

Test2.java:8: warning: [unchecked] unchecked method invocation: method <T>m2(Test<T>) in class Test is applied to given types
required: Test<T>
found: Test

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL http://hg.openjdk.java.net/jdk7/tl/langtools/rev/ddd75a295501
24-10-2008

EVALUATION Will fix
13-10-2008