United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6511613 javac unexpectedly doesn't fail in some cases if an annotation processor specified
JDK-6511613 : javac unexpectedly doesn't fail in some cases if an annotation processor specified

Details
Type:
Bug
Submit Date:
2007-01-10
Status:
Closed
Updated Date:
2012-03-22
Project Name:
JDK
Resolved Date:
2011-06-22
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
generic
Priority:
P3
Resolution:
Won't Fix
Affected Versions:
6,7
Fixed Versions:
6

Related Reports
Backport:

Sub Tasks

Description
The javac doesn't fail while processing the attached negative JCK lang tests if an annotation processor is specified. Consider steps to reproduce the problem using the simple annotation processor below.

===DummyProcessor.java===
import javax.annotation.processing.AbstractProcessor;
import javax.lang.model.element.TypeElement;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import java.util.Set;
import javax.lang.model.SourceVersion;

@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
public class DummyProcessor extends AbstractProcessor {

    public boolean process(Set<? extends TypeElement> elems, 
            RoundEnvironment renv) {
        return false;
    }
}
===
Steps to reproduce:
===
<ag153348@spb-orion> javac clss41701.java
clss41701.java:18: a type variable may not be followed by other bounds
                 C extends A&B> {
                             ^
1 error
<ag153348@spb-orion> javac DummyProcessor.java
<ag153348@spb-orion> javac -cp . -processor DummyProcessor clss41701.java 
clss41701.java:18: a type variable may not be followed by other bounds
                 C extends A&B> {
                             ^
<ag153348@spb-orion> ls *.class
DummyProcessor.class  clss41701a.class
clss41701.class       clss41701i.class
===
As you can see if an annotation processor specified the javac generates output classes.

                                    

Comments
EVALUATION

The fault is Attr.java:2639. In the error recovery after printing the error, the code modifies the original tree to remove the fault.

>                 // if first bound was a typevar, do not accept further bounds.
>                 if (tree.bounds.tail.nonEmpty()) {
>                     log.error(tree.bounds.tail.head.pos(),
>                               "type.var.may.not.be.followed.by.other.bounds");
>                     tree.bounds = List.of(tree.bounds.head);
>                     a.bound = bs.head;
>                 }
                                     
2010-02-23
SUGGESTED FIX

Convert JavaCompiler.parseErrors to Log.unrecoverableError and set that flag when this error occurs.
                                     
2010-02-24



Hardware and Software, Engineered to Work Together