JDK-6968793 : issues with diagnostics
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-07-13
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
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 b128Fixed
Related Reports
Relates :  
Description
The following were reported while reviewing test/tools/javac/diags/examples:


-CantResolve.java

examples/CantResolve.java:29: cannot find symbol
        Object o = t.v;
                    ^
  symbol: variable v
1 error

I wonder why the compiler doesn't include a 'location: type-variable T', which would have the benefit of also adding a 'where' clause at the end of the diagnostic (which would help understanding why T does not have a 'v' member).


-DiamondNotSupported.java (can't remember if you already filed this):

examples/DiamondNotSupported.java:31: diamond operator is not supported in -source 1.6
        List<String> list = new ArrayList<>();
                                          ^
  (use -source 7 or higher to enable *multi-catch statement*)

-EnumConstRequired.java

I think the output of this test is actually worse than the one of the subsequent test (EnumLabelUnqualified.java), we might want to consider to unify the two keys.


-ForeachNotApplicable.java

examples/ForeachNotApplicable.java:28: foreach not applicable to expression type
        for (String a: arg) {
                       ^

two comments: (i) 'for-each' instead of 'foreach'  [so that it would be consistent with other diagnostics] and (ii) it could be helpful to add a found/required couple in order to explain why the type is not supported. E.g.

found: String
required: array or java.lang.Iterable<?>


- NotWithinBounds.java

I guess this message can be improved by adding a reference to the declared type-variable (which will cause a 'where' clause to be generated, showing the variable's declared bound)

- OperatorCantBeApplied.java

I always found this one a bit confusing - I guess that surrounding the operator ( '-'  in this case) with ' ' as in '-' would result in a cleaner message.

- PkgClashWithClass.java

It is not clear from the message what clashes with what; we should add a 'kindname' as a diagnostic argument so that the message becomes ' *class* p clashes with package with the same name'

- UndeterminedType1.java

this message should look similar to other inference messages (I did some work in this area and changed the shape of inference messages so that they look less cryptic, see InferredDoNotConformToBounds.java)

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

EVALUATION Will fix.
24-01-2011