-
Bug
-
Resolution: Fixed
-
P4
-
8
-
b14
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8045162 | 8u25 | Jan Lahoda | P4 | Resolved | Fixed | b01 |
JDK-8042817 | 8u20 | Jan Lahoda | P4 | Resolved | Fixed | b15 |
JDK-8052601 | emb-8u26 | Jan Lahoda | P4 | Resolved | Fixed | b17 |
FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
End of compilation stage analyze can be reported twice to listener implementing com.sun.source.util.TaskListener in some cases.
In the example annotation processor is modified to process TaskListener notifications and print information about events.
Annotation processor is used for compilation of two classes, one of which extends other. If extending class is mentioned first in command line additional notification about analyze stage completion is reported for other class.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Modify any annotation processor to process TaskListener notifications:
public class Processor extends AbstractProcessor implements TaskListener {
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
JavacTask.instance(processingEnv).setTaskListener(this);
}
public void finished(TaskEvent event) {
System.out.print(event.getKind());
System.out.print(" - ");
System.out.print(event.getTypeElement());
System.out.print(" - ");
System.out.println(Trees.instance(processingEnv).getPath(event.getTypeElement()));
}
public void started(TaskEvent arg0) {}
...
}
Create source files A.java and B.java:
public abstract class A {}
public class B extends A {}
Compile using modified annotation processor:
javac -processorpath plugin.jar B.java A.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ANNOTATION_PROCESSING_ROUND - null - null
ENTER - null - null
ENTER - null - null
ANNOTATION_PROCESSING_ROUND - null - null
ANNOTATION_PROCESSING - null - null
ENTER - null - null
ENTER - null - null
ANALYZE - B - com.sun.source.util.TreePath@5a61f5df
ANALYZE - A - com.sun.source.util.TreePath@52af6cff
GENERATE - B - null
GENERATE - A - null
ACTUAL -
ANNOTATION_PROCESSING_ROUND - null - null
ENTER - null - null
ENTER - null - null
ANNOTATION_PROCESSING_ROUND - null - null
ANNOTATION_PROCESSING - null - null
ENTER - null - null
ENTER - null - null
ANALYZE - B - com.sun.source.util.TreePath@5a61f5df
ANALYZE - A - com.sun.source.util.TreePath@52af6cff
GENERATE - B - null
ANALYZE - A - null
GENERATE - A - null
Note additional line "ANALYZE - A - null".
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Annotation processor processor.java:
---------------------------
package test;
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.element.TypeElement;
import javax.lang.model.SourceVersion;
import com.sun.source.util.*;
@SupportedAnnotationTypes("*")
public class Processor extends AbstractProcessor implements TaskListener {
boolean debug;
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
JavacTask.instance(processingEnv).setTaskListener(this);
}
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
return false;
}
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
public void finished(TaskEvent event) {
System.out.print(event.getKind());
System.out.print(" - ");
System.out.print(event.getTypeElement());
System.out.print(" - ");
System.out.println(Trees.instance(processingEnv).getPath(event.getTypeElement()));
}
public void started(TaskEvent arg0) {}
}
---------------------------
A.java:
---------------------------
public abstract class A {}
---------------------------
B.java:
---------------------------
public class B extends A {}
---------------------------
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Receiver of notification can filter out duplicated notifications.
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
End of compilation stage analyze can be reported twice to listener implementing com.sun.source.util.TaskListener in some cases.
In the example annotation processor is modified to process TaskListener notifications and print information about events.
Annotation processor is used for compilation of two classes, one of which extends other. If extending class is mentioned first in command line additional notification about analyze stage completion is reported for other class.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Modify any annotation processor to process TaskListener notifications:
public class Processor extends AbstractProcessor implements TaskListener {
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
JavacTask.instance(processingEnv).setTaskListener(this);
}
public void finished(TaskEvent event) {
System.out.print(event.getKind());
System.out.print(" - ");
System.out.print(event.getTypeElement());
System.out.print(" - ");
System.out.println(Trees.instance(processingEnv).getPath(event.getTypeElement()));
}
public void started(TaskEvent arg0) {}
...
}
Create source files A.java and B.java:
public abstract class A {}
public class B extends A {}
Compile using modified annotation processor:
javac -processorpath plugin.jar B.java A.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ANNOTATION_PROCESSING_ROUND - null - null
ENTER - null - null
ENTER - null - null
ANNOTATION_PROCESSING_ROUND - null - null
ANNOTATION_PROCESSING - null - null
ENTER - null - null
ENTER - null - null
ANALYZE - B - com.sun.source.util.TreePath@5a61f5df
ANALYZE - A - com.sun.source.util.TreePath@52af6cff
GENERATE - B - null
GENERATE - A - null
ACTUAL -
ANNOTATION_PROCESSING_ROUND - null - null
ENTER - null - null
ENTER - null - null
ANNOTATION_PROCESSING_ROUND - null - null
ANNOTATION_PROCESSING - null - null
ENTER - null - null
ENTER - null - null
ANALYZE - B - com.sun.source.util.TreePath@5a61f5df
ANALYZE - A - com.sun.source.util.TreePath@52af6cff
GENERATE - B - null
ANALYZE - A - null
GENERATE - A - null
Note additional line "ANALYZE - A - null".
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
Annotation processor processor.java:
---------------------------
package test;
import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.element.TypeElement;
import javax.lang.model.SourceVersion;
import com.sun.source.util.*;
@SupportedAnnotationTypes("*")
public class Processor extends AbstractProcessor implements TaskListener {
boolean debug;
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
JavacTask.instance(processingEnv).setTaskListener(this);
}
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
return false;
}
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
public void finished(TaskEvent event) {
System.out.print(event.getKind());
System.out.print(" - ");
System.out.print(event.getTypeElement());
System.out.print(" - ");
System.out.println(Trees.instance(processingEnv).getPath(event.getTypeElement()));
}
public void started(TaskEvent arg0) {}
}
---------------------------
A.java:
---------------------------
public abstract class A {}
---------------------------
B.java:
---------------------------
public class B extends A {}
---------------------------
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Receiver of notification can filter out duplicated notifications.
- backported by
-
JDK-8042817 Duplicated notifications can be sent to TaskListener
-
- Resolved
-
-
JDK-8045162 Duplicated notifications can be sent to TaskListener
-
- Resolved
-
-
JDK-8052601 Duplicated notifications can be sent to TaskListener
-
- Resolved
-