JDK-6720185 : DiagnosticFormatter refactoring
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2008-06-27
  • Updated: 2011-05-17
  • Resolved: 2011-05-17
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 b33Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
The class DiagnosticFormatter has some problems:

*) A single class is in charge for providing both raw format (-XdrawDiagnostics option) and standard format
*) All the formatting logic is accomplished by a single formatter method format(JCDiagnostic)

Those problems makes it very difficult to extend DiagnosticFormatter in order to provide more specific formatting capabilities:

*) Any subclass of DiagnosticFormatter must preserve the raw format. Such format is exploited in locale-independent regression tests, so that any minimal change to the raw format will cause a lot of regression failures.

*) It's not possible to redefine specific parts of the formatter's behavior (e.g. change the way in which the formatter renders a diagnostic's location) without redefining the whole formatting logic

Please, refactor the DiagnosticFormatter class.

Comments
SUGGESTED FIX A webrev for this CR is available at: http://sa.sfbay.sun.com/projects/langtools_data/7/6720185.3/
06-08-2008

EVALUATION A new hierarchy of formatter classes will address this problem: *) AbstractDiagnosticFormatter is the root of the new formatters hierarchy defining visitor-like methods for rendering different parts of a diagnostic *) RawDiagnosticFormatter renders diagnostics in raw, locale-independent format *) BasicDiagnosticFormatter provides a localized output - equivalent to current DiagnosticFormatter The advantages of having such a hierarchy are that: *) Subclasses of AbstractDiagnosticFormatter do not need to worry about raw diagnostics *) It's possible (thanks to the visitor-like methods) to redefine only specifc parts of the formatting logic
27-06-2008