7129225: javac fails to run annotation processors when star import of package of gensrc

Tue, 24 Jan 2012 16:31:15 -0800

author
jjh
date
Tue, 24 Jan 2012 16:31:15 -0800
changeset 1188
d16b464e742c
parent 1187
ac36176b7de0
child 1189
332dfa0f91df

7129225: javac fails to run annotation processors when star import of package of gensrc
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/comp/MemberEnter.java file | annotate | diff | comparison | revisions
test/tools/javac/7129225/Anno.java file | annotate | diff | comparison | revisions
test/tools/javac/7129225/AnnoProcessor.java file | annotate | diff | comparison | revisions
test/tools/javac/7129225/NegTest.ref file | annotate | diff | comparison | revisions
test/tools/javac/7129225/TestImportStar.java file | annotate | diff | comparison | revisions
test/tools/javac/7129225/TestImportStar.ref file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Jan 24 15:51:44 2012 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Jan 24 16:31:15 2012 -0800
     1.3 @@ -44,6 +44,7 @@
     1.4  import static com.sun.tools.javac.code.Kinds.*;
     1.5  import static com.sun.tools.javac.code.TypeTags.*;
     1.6  import static com.sun.tools.javac.tree.JCTree.Tag.*;
     1.7 +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
     1.8  import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
     1.9  
    1.10  /** This is the second phase of Enter, in which classes are completed
    1.11 @@ -142,7 +143,7 @@
    1.12                  JCDiagnostic msg = diags.fragment("fatal.err.no.java.lang");
    1.13                  throw new FatalError(msg);
    1.14              } else {
    1.15 -                log.error(pos, "doesnt.exist", tsym);
    1.16 +                log.error(DiagnosticFlag.RESOLVE_ERROR, pos, "doesnt.exist", tsym);
    1.17              }
    1.18          }
    1.19          env.toplevel.starImportScope.importAll(tsym.members());
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/7129225/Anno.java	Tue Jan 24 16:31:15 2012 -0800
     2.3 @@ -0,0 +1,31 @@
     2.4 +/*
     2.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.  Oracle designates this
    2.11 + * particular file as subject to the "Classpath" exception as provided
    2.12 + * by Oracle in the LICENSE file that accompanied this code.
    2.13 + *
    2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.17 + * version 2 for more details (a copy is included in the LICENSE file that
    2.18 + * accompanied this code).
    2.19 + *
    2.20 + * You should have received a copy of the GNU General Public License version
    2.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.23 + *
    2.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.25 + * or visit www.oracle.com if you need additional information or have any
    2.26 + * questions.
    2.27 + */
    2.28 +
    2.29 +import java.lang.annotation.ElementType;
    2.30 +import java.lang.annotation.Target;
    2.31 +
    2.32 +@Target(ElementType.TYPE)
    2.33 +public @interface Anno {
    2.34 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/7129225/AnnoProcessor.java	Tue Jan 24 16:31:15 2012 -0800
     3.3 @@ -0,0 +1,43 @@
     3.4 +/*
     3.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.  Oracle designates this
    3.11 + * particular file as subject to the "Classpath" exception as provided
    3.12 + * by Oracle in the LICENSE file that accompanied this code.
    3.13 + *
    3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.17 + * version 2 for more details (a copy is included in the LICENSE file that
    3.18 + * accompanied this code).
    3.19 + *
    3.20 + * You should have received a copy of the GNU General Public License version
    3.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.23 + *
    3.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.25 + * or visit www.oracle.com if you need additional information or have any
    3.26 + * questions.
    3.27 + */
    3.28 +
    3.29 +import java.util.Set;
    3.30 +import javax.annotation.processing.*;
    3.31 +import javax.lang.model.SourceVersion;
    3.32 +import javax.lang.model.element.TypeElement;
    3.33 +
    3.34 +@SupportedAnnotationTypes("Anno")
    3.35 +public class AnnoProcessor extends AbstractProcessor {
    3.36 +    @Override
    3.37 +    public SourceVersion getSupportedSourceVersion() {
    3.38 +        return SourceVersion.latest();
    3.39 +    }
    3.40 +
    3.41 +    @Override
    3.42 +    public boolean process(Set<? extends TypeElement> set, RoundEnvironment re) {
    3.43 +        System.out.println("RUNNING...");
    3.44 +        return true;
    3.45 +    }
    3.46 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/7129225/NegTest.ref	Tue Jan 24 16:31:15 2012 -0800
     4.3 @@ -0,0 +1,2 @@
     4.4 +TestImportStar.java:37:1: compiler.err.doesnt.exist: xxx
     4.5 +1 error
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/tools/javac/7129225/TestImportStar.java	Tue Jan 24 16:31:15 2012 -0800
     5.3 @@ -0,0 +1,41 @@
     5.4 +/*
     5.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.  Oracle designates this
    5.11 + * particular file as subject to the "Classpath" exception as provided
    5.12 + * by Oracle in the LICENSE file that accompanied this code.
    5.13 + *
    5.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.17 + * version 2 for more details (a copy is included in the LICENSE file that
    5.18 + * accompanied this code).
    5.19 + *
    5.20 + * You should have received a copy of the GNU General Public License version
    5.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.23 + *
    5.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.25 + * or visit www.oracle.com if you need additional information or have any
    5.26 + * questions.
    5.27 + */
    5.28 +
    5.29 +/* @test
    5.30 + * @bug 7129225
    5.31 + * @summary import xxx.* isn't handled correctly by annotation processing
    5.32 + * @compile/fail/ref=NegTest.ref -XDrawDiagnostics TestImportStar.java
    5.33 + * @compile Anno.java AnnoProcessor.java
    5.34 + * @compile/ref=TestImportStar.ref -XDrawDiagnostics -processor AnnoProcessor -proc:only TestImportStar.java
    5.35 + */
    5.36 +
    5.37 + //The @compile/fail... verifies that the fix doesn't break the normal compilation of import xxx.*
    5.38 + //The @comple/ref... verifies the fix fixes the bug
    5.39 +
    5.40 +import xxx.*;
    5.41 +
    5.42 +@Anno
    5.43 +public class TestImportStar {
    5.44 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/tools/javac/7129225/TestImportStar.ref	Tue Jan 24 16:31:15 2012 -0800
     6.3 @@ -0,0 +1,3 @@
     6.4 +RUNNING...
     6.5 +RUNNING...
     6.6 +TestImportStar.java:37:1: compiler.err.doesnt.exist: xxx

mercurial