JDK-6732461 : broken message file for annotation processing
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-08-01
  • 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 b34Fixed
Related Reports
Relates :  
Relates :  
Description
running processor on file that has unsupported annotations and annotaions without processors results in brokem message file:

< warning: compiler message file broken: key=apt.warn.AnnotationsWithoutProcessors arguments=test.apf.C,D, {1}, {2}, {3}, {4}, {5}, {6}, {7}
---
> warning: Annotation types without processors: [test.apf.C, D]
3c3
< warning: compiler message file broken: key=apt.warn.AnnotationsWithoutProcessors arguments=test.apf.C, {1}, {2}, {3}, {4}, {5}, {6}, {7}
---
> warning: Annotation types without processors: [test.apf.C]
Err out did not match.

Comments
SUGGESTED FIX A webrev of the fix is avavilable at: http://sa.sfbay.sun.com/projects/langtools_data/7/6732461
08-08-2008

EVALUATION Only apt has a "Bark" like wrapper around Log. No other javac-related tools has the same awkward architecture. I'd recommend changing apt as little as possible to work when interfacing to the improved javac message reporting.
07-08-2008

EVALUATION This is a regression introduced during the ongoing work on javac diagnostic (in particular by CR 6720185). The problem described in this CR is relatively simple: the APT's Bark class doesn't update the Log's diagnostic formatter. As such, the default diagnostic formatter is used for generating the diagnostic output. Unfortunately the default formatter cannot localize apt messages, as its Messages object doesn't contain the apt resource bundle list. Solution: the Log's formatter should be updated to a new diagnostic formatter the stores the correct Messages object. This is quite easy to do - I did it and the problem disappeared as expected. But this made me quite worried for a number of reasons: 1) What is/should be the relationship between the Log's diagnostic formatter and the DiagnosticFactory's formatter? Currently those are two different objects; not sure that this is the right approach. We could have the Log to update the DiagnosticFormatter's formatter so that the two references point to the very same object (the one created in Log). 2) There's a scary initialization loop in APT's Bark. Log gets initialized on its own during APT startup and then it basically gets re-initialized when an instance of Bark (that subclasses Log) get created. When Bark has been created there are two live Log objects, a javac-like Log and an apt-specific Log (Bark). This means two diagnostic factories, two diagnostic formatters (actually four of them, since, as I said, factories and logs don't share the same formatter object). Lot of error-prone replication - at least in my opinion. 3) Is there any other tool (javap, javah, and so on) that could have been broken in a similar way? I.e. does each tool define its own Log's subclass? Or, rather, this is a setting that only occurs within apt, given its closeness to javac? I tried to look inside javap and I found that javap handles all the diagnostic-dependent code internally, with no dependency from Log; this would mean no problem! Can I assume this behaviour for all the other tools? Is my guessing about javap correct? 4) The code handling ResourceBundle(s) in AbstractDiagnosticFormatter is not good enough. In particular, in line 134 of AbstractDiagnosticFormatter.java there is a dangerous call to Messages.getDefaultBundle(); I added this call when we decided to introduce Formattable arguments; since the toString() of a Formattable argument accepts a ResourceBundle I need to pass one from the diagnostic formatter when the formatter has to format a formattable arg. The problem is that the formatter stores a Messages object and that this object doesn't expose the bundles that it uses internally (actually there is a list of bundles). But, even with Messages exposing the bundles, the toString(ResourceBundle) method of a Formattable arg would still be problematic, as a tool like javap creates a Messages object with two ResourceBundles in it, and one should look at both in order to localize a given key.
06-08-2008