JDK-5048539 : apt needs a listener mechanism
  • Type: Bug
  • Component: tools
  • Sub-Component: apt
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-05-17
  • Updated: 2017-05-16
  • Resolved: 2004-07-16
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.
Other
5.0 b59Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
Feedback from internal and external apt uses has revealed the need for a listener mechanism to let processors/factories know when annotation processing is finished so the trailing bits of files can be written, etc.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-rc FIXED IN: tiger-rc INTEGRATED IN: tiger-b59 tiger-rc
03-08-2004

SUGGESTED FIX New files: src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java src/share/classes/com/sun/mirror/apt/RoundState.java src/share/classes/com/sun/tools/apt/mirror/apt/RoundStateImpl.java src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java Modified files: src/share/classes/com/sun/mirror/apt>sccs sccsdiff -r1.5 -r1.6 AnnotationProcessorEnvironment.java ------- AnnotationProcessorEnvironment.java ------- 141a142,160 > > /** > * Add a listener. If the listener is currently registered to listen, > * adding it again will have no effect. > * > * @param listener The listener to add. > * @throws NullPointerException if the listener is null > */ > void addListener(AnnotationProcessorListener listener); > > > /** > * Remove a listener. If the listener is not currently listening, > * the method call does nothing. > * > * @param listener The listener to remove. > * @throws NullPointerException if the listener is null > */ > void removeListener(AnnotationProcessorListener listener); src/share/classes/com/sun/tools/apt/mirror/apt>sccs sccsdiff -r1.9 -r1.10 AnnotationProcessorEnvironmentImpl.javaa ------- AnnotationProcessorEnvironmentImpl.java ------- 15a16 > import com.sun.tools.apt.util.Bark; 19a21,22 > import com.sun.tools.apt.mirror.apt.RoundStateImpl; > import com.sun.tools.apt.mirror.apt.RoundCompleteEventImpl; 38,39c41,44 < Filer filer; < --- > FilerImpl filer; > Bark bark; > Set<RoundCompleteListener> roundCompleteListeners; > 54a60,61 > bark = Bark.instance(context); > roundCompleteListeners = new LinkedHashSet<RoundCompleteListener>(); 69,72d75 < // public Collection<PackageDeclaration> getSpecifiedPackages() { < // throw new UnsupportedOperationException(); < // } < 134a138,164 > > public void addListener(AnnotationProcessorListener listener) { > if (listener == null) > throw new NullPointerException(); > else { > if (listener instanceof RoundCompleteListener) > roundCompleteListeners.add((RoundCompleteListener)listener); > } > } > > public void removeListener(AnnotationProcessorListener listener) { > if (listener == null) > throw new NullPointerException(); > else > roundCompleteListeners.remove(listener); > } > > public void roundComplete() { > RoundState roundState = new RoundStateImpl(bark.nerrors > 0, > filer.getSourceFileNames().size() > 0, > filer.getClassFileNames().size() > 0); > RoundCompleteEvent roundCompleteEvent = new RoundCompleteEventImpl(this, roundState); > > filer.roundOver(); > for(RoundCompleteListener rcl: roundCompleteListeners) > rcl.roundComplete(roundCompleteEvent); > } src/share/classes/com/sun/tools/apt/mirror/apt>sccs sccsdiff -r1.5 -r1.6 FilerImpl.java ------- FilerImpl.java ------- 56a57,64 > // Names of newly created source files > private HashSet<String> sourceFileNames = new HashSet<String>(); > > // Names of newly created class files > private HashSet<String> classFileNames = new HashSet<String>(); > > private boolean roundOver; > 80c88 < --- > roundOver = false; 204,208d211 < < < private HashSet<String> sourceFileNames = new HashSet<String>(); < private HashSet<String> classFileNames = new HashSet<String>(); < 216a220,223 > public void roundOver() { > roundOver = true; > } > 218,220c225,227 < * Checks that the file has not already been created during this run. < * If not, creates intermediate directories, and deletes the file if < * it already exists. --- > * Checks that the file has not already been created during this > * invocation. If not, creates intermediate directories, and > * deletes the file if it already exists. 222a230,233 > if (roundOver) { > bark.warning(Position.NOPOS, "NoNewFilesAfterRound", file.toString()); > throw new IOException(); > } src/share/classes/com/sun/tools/apt/comp>sccs sccsdiff -r1.14 -r1.15 Apt.java ------- Apt.java ------- 205c205 < AnnotationProcessorEnvironment trivAPE = --- > AnnotationProcessorEnvironmentImpl trivAPE = 408a409,411 > // Invoke listener callback mechanism > trivAPE.roundComplete(); > src/share/classes/com/sun/tools/apt/resources>sccs sccsdiff -r1.5 -r1.6 apt.properties ------- apt.properties ------- 122a123,125 > apt.warn.NoNewFilesAfterRound=> Cannot create file ''{0}'' after a round has ended. > ###@###.### 2004-06-25
25-06-2004

EVALUATION Should be fixed. ###@###.### 2004-05-17
17-05-2004