United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6492019 Overhaul compiler diagnostics
JDK-6492019 : Overhaul compiler diagnostics

Details
Type:
Enhancement
Submit Date:
2006-11-09
Status:
Resolved
Updated Date:
2013-05-09
Project Name:
JDK
Resolved Date:
2013-05-09
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
8

Related Reports
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
There are many compiler diagnostics that could be improved.
This RFE tracks all such issues.  Please either add a new
description note or link to related issues.
From jplan entry 403:

For an invalid cast, javac will write something like:

Cast.java:1: inconvertible types
found   : java.lang.Number
required: java.lang.String
See also: http://blogs.sun.com/ahe?entry=diagnosing_captured_wildcards
Object o = null;
        o -= null;

Gives:

Test.java:12: operator - cannot be applied to java.lang.Object,<nulltype>
        o -= null;
          ^

This should be improved.  This should not refer to the operator -, but
the operator -=.  Furthermore, "java.lang.Object,<nulltype>" is not very
helpful and we should have separate error messages for unary and binary
operators.

                                    

Comments
EVALUATION

This is an issue that we are trying to address with a bunch of compiler fixes/enhancements specifically targeting the javac diagnostic system. 
Here are (listed in a priority order) all the issue that should be tackled in order to address this problem:

1) Addressing the problem of diagnostic arguments prematurely converted into Strings (see CR 6717241)
2) Introducing a new (and possibly flexible) hierarchy of diagnostic formatters (see CR 6720185)
3) Creating a formatter that better integrates with javac type-system (6722234)
4) Addressing diagnostic-specific issues (as the ones described in this CR and also in 4881269, 4881267, 6231440, 5088624, 5101303)

See the related CRs for detailed explanations of the specific improvements we are aiming at. I'll keep updating this CR as soon as new pieces of this job will be accomplished.
                                     
2008-06-20
This is closed as it has been implemented in jdk 7 already.
                                     
2013-05-09



Hardware and Software, Engineered to Work Together