JDK-6511613 : javac unexpectedly doesn't fail in some cases if an annotation processor specified
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6,7
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2007-01-10
  • Updated: 2012-03-22
  • Resolved: 2011-06-22
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
7Fixed
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
SUGGESTED FIX Convert JavaCompiler.parseErrors to Log.unrecoverableError and set that flag when this error occurs.
24-02-2010

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; > }
23-02-2010