JDK-6724551 : Use Queues instead of Lists to link compiler phases
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-07-10
  • 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 Other
7 b32Fixed OpenJDK6Fixed
Description
Currently, JavaCompiler uses Lists to pass work between the attribute/flow/desugar/generate methods. Using queues would provide more flexibility, and facilitate limited support for multi-threaded javac.

Comments
EVALUATION This is a relatively simple refactoring in JavaCompiler to facilitate limited multi-threaded javac. Currently, the JavaCompiler analyze/flow/desugar/generate methods use (immutable) javac Lists to pass work between the stages. This fix changes them to use java.util.Queue instead, with their inherent limited mutability. (remove from front, append to end). The impl of Queue is provided by upgrading ListBuffer, which had close to the correct semantics, and just required a few more methods to implement the remainder of the Queue interface. There were two minor issues to address. 1) ListBuffer previously had an remove method that was incompatible with Queue, but although it was public, it was only used exactly once, in ListBuffer.next. As such, the two were folded together. 2) Queues prefer non-null elements. javac does not typically use null in Lists anyway, so this is not an issue, but adding a null-check in ListBuffer.add revealed a single instance in Enter where null was inapprorpiately added to a list. This was fixed at the one call site in Enter, by ignoring null when it occurs. In context, this is the correct and safe thing to do. The bug is noreg-cleanup as the changes are not externally visible. The changes have been tested with the regression tests (locally) and by building JDK and using that build as well to run the compiler regression tests.
10-07-2008