United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6724551 Use Queues instead of Lists to link compiler phases
JDK-6724551 : Use Queues instead of Lists to link compiler phases

Details
Type:
Enhancement
Submit Date:
2008-07-10
Status:
Closed
Updated Date:
2011-05-18
Project Name:
JDK
Resolved Date:
2011-05-18
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

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.
                                     
2008-07-10



Hardware and Software, Engineered to Work Together