diff --git a/test/tools/javac/lib/JavacTestingAbstractProcessor.java b/test/tools/javac/lib/JavacTestingAbstractProcessor.java new file mode 100644 index 0000000000000000000000000000000000000000..2706782b10d34061c20418485ec0f636ec9329df --- /dev/null +++ b/test/tools/javac/lib/JavacTestingAbstractProcessor.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import static javax.lang.model.SourceVersion.*; +import javax.lang.model.element.*; +import javax.lang.model.util.*; + +/** + * An abstract annotation processor tailored to javac regression testing. + */ +public abstract class JavacTestingAbstractProcessor extends AbstractProcessor { + private static final Set allAnnotations; + + static { + Set tmp = new HashSet<>(); + tmp.add("*"); + allAnnotations = Collections.unmodifiableSet(tmp); + } + + protected Elements eltUtils; + protected Elements elements; + protected Types typeUtils; + protected Types types; + protected Filer filer; + protected Messager messager; + protected Map options; + + /** + * Constructor for subclasses to call. + */ + protected JavacTestingAbstractProcessor() { + super(); + } + + /** + * Return the latest source version. Unless this method is + * overridden, an {@code IllegalStateException} will be thrown if a + * subclass has a {@code SupportedSourceVersion} annotation. + */ + @Override + public SourceVersion getSupportedSourceVersion() { + SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class); + if (ssv != null) + throw new IllegalStateException("SupportedSourceVersion annotation not supported here."); + + return SourceVersion.latest(); + } + + /** + * If the processor class is annotated with {@link + * SupportedAnnotationTypes}, return an unmodifiable set with the + * same set of strings as the annotation. If the class is not so + * annotated, a one-element set containing {@code "*"} is returned + * to indicate all annotations are processed. + * + * @return the names of the annotation types supported by this + * processor, or an empty set if none + */ + @Override + public Set getSupportedAnnotationTypes() { + SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class); + if (sat != null) + return super.getSupportedAnnotationTypes(); + else + return allAnnotations; + } + + @Override + public void init(ProcessingEnvironment processingEnv) { + super.init(processingEnv); + elements = eltUtils = processingEnv.getElementUtils(); + types = typeUtils = processingEnv.getTypeUtils(); + filer = processingEnv.getFiler(); + messager = processingEnv.getMessager(); + options = processingEnv.getOptions(); + } +} diff --git a/test/tools/javac/processing/6348499/A.java b/test/tools/javac/processing/6348499/A.java index 9bdafaee3e2a158bc2d6c598b0b835483012e61e..b5b3aaf37f2436ed5d0ecdbde55805b176fcb5d5 100644 --- a/test/tools/javac/processing/6348499/A.java +++ b/test/tools/javac/processing/6348499/A.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,10 +27,8 @@ import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; -@SupportedAnnotationTypes("*") -public class A extends AbstractProcessor { +public class A extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment renv) { - Filer filer = processingEnv.getFiler(); try { OutputStream out = filer.createClassFile(getClass().getName()+"_0").openOutputStream(); out.close(); @@ -39,8 +37,4 @@ public class A extends AbstractProcessor { } return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/6348499/T6348499.java b/test/tools/javac/processing/6348499/T6348499.java index e558cc1297298c394ddc747293c8c6ede2895171..25e2a07a03f876be8ad82e14d1926ff2d3211947 100644 --- a/test/tools/javac/processing/6348499/T6348499.java +++ b/test/tools/javac/processing/6348499/T6348499.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ * @test * @bug 6441871 * @summary javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile - * @build A + * @library ../../lib + * @build JavacTestingAbstractProcessor A * @run main T6348499 */ @@ -54,7 +55,6 @@ public class T6348499 { fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java"))); Iterable opts = Arrays.asList("-proc:only", "-processor", "A", - "-source", "1.6", "-processorpath", testClasses); StringWriter out = new StringWriter(); JavacTask task = tool.getTask(out, fm, dl, opts, null, files); diff --git a/test/tools/javac/processing/6359313/T6359313.java b/test/tools/javac/processing/6359313/T6359313.java index 025a4821a006e9ff5e0e3c0ffbeeb53ab5d444f7..719ea12ff12cd04df7eb267fe8734471c479d974 100644 --- a/test/tools/javac/processing/6359313/T6359313.java +++ b/test/tools/javac/processing/6359313/T6359313.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6359313 * @summary error compiling annotated package * @author Peter von der Ah\u00e9 + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile T6359313.java * @compile -processor T6359313 package-info.java Foo.java */ @@ -37,7 +39,7 @@ import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.element.TypeElement; @SupportedAnnotationTypes("Foo") -public class T6359313 extends AbstractProcessor { +public class T6359313 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { return true; diff --git a/test/tools/javac/processing/6365040/ProcBar.java b/test/tools/javac/processing/6365040/ProcBar.java index 1fd93bc6acb1e1549250e155340300612a7b8042..3241692b08dc162cf67466055a91cb8bc1090948 100644 --- a/test/tools/javac/processing/6365040/ProcBar.java +++ b/test/tools/javac/processing/6365040/ProcBar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,13 +31,11 @@ import static javax.tools.Diagnostic.Kind.*; /** * Second of several processors to run. */ -@SupportedAnnotationTypes("*") -public class ProcBar extends AbstractProcessor { +public class ProcBar extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { if (!roundEnvironment.processingOver()) - processingEnv.getMessager().printMessage(NOTE, - "Hello from ProcBar"); + messager.printMessage(NOTE, "Hello from ProcBar"); return false; } } diff --git a/test/tools/javac/processing/6365040/ProcFoo.java b/test/tools/javac/processing/6365040/ProcFoo.java index f86d0ddbec11de30ee2cb346404173635ff22189..14cdec25adecc9eeb4e28fd16a794da79db66272 100644 --- a/test/tools/javac/processing/6365040/ProcFoo.java +++ b/test/tools/javac/processing/6365040/ProcFoo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,13 +31,11 @@ import static javax.tools.Diagnostic.Kind.*; /** * First of several processors to run. */ -@SupportedAnnotationTypes("*") -public class ProcFoo extends AbstractProcessor { +public class ProcFoo extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { if (!roundEnvironment.processingOver()) - processingEnv.getMessager().printMessage(NOTE, - "Hello from ProcFoo"); + messager.printMessage(NOTE, "Hello from ProcFoo"); return false; } } diff --git a/test/tools/javac/processing/6365040/T6365040.java b/test/tools/javac/processing/6365040/T6365040.java index 5215459bee76a1ca6ff9bf8a822f94814cab9b33..0b1e0dc851ca954eac2ab9d40ddc30f5b0c959fa 100644 --- a/test/tools/javac/processing/6365040/T6365040.java +++ b/test/tools/javac/processing/6365040/T6365040.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6365040 6358129 * @summary Test -processor foo,bar,baz * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile ProcFoo.java * @compile ProcBar.java * @compile T6365040.java @@ -43,13 +45,11 @@ import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.element.TypeElement; import static javax.tools.Diagnostic.Kind.*; -@SupportedAnnotationTypes("*") -public class T6365040 extends AbstractProcessor { +public class T6365040 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { if (!roundEnvironment.processingOver()) - processingEnv.getMessager().printMessage(NOTE, - "Hello from T6365040"); + messager.printMessage(NOTE, "Hello from T6365040"); return true; } } diff --git a/test/tools/javac/processing/6413690/T6413690.java b/test/tools/javac/processing/6413690/T6413690.java index c51586263ab060d0ea076163301a42243e7e9aaa..a4b2b3fab332abd6c4db0699858b23356801a240 100644 --- a/test/tools/javac/processing/6413690/T6413690.java +++ b/test/tools/javac/processing/6413690/T6413690.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6413690 6380018 * @summary JavacProcessingEnvironment does not enter trees from preceding rounds * @author Peter von der Ah\u00e9 + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile T6413690.java * @compile -XDfatalEnterError -verbose -processor T6413690 src/Super.java TestMe.java */ @@ -42,11 +44,9 @@ import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; @SupportedAnnotationTypes("TestMe") -public class T6413690 extends AbstractProcessor { +public class T6413690 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { - Elements elements = processingEnv.getElementUtils(); - Filer filer = processingEnv.getFiler(); TypeElement testMe = elements.getTypeElement(TestMe.class.getName()); Set supers = roundEnvironment.getElementsAnnotatedWith(testMe); try { diff --git a/test/tools/javac/processing/6414633/A.java b/test/tools/javac/processing/6414633/A.java index 814106a7aef664a560fe4e5384a089b3c2788816..13754d09cbeb474caec1639b86c6f6255b0f145b 100644 --- a/test/tools/javac/processing/6414633/A.java +++ b/test/tools/javac/processing/6414633/A.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,9 +29,8 @@ import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class A extends AbstractProcessor { - +@SuppressWarnings("") +public class A extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { Messager m = processingEnv.getMessager(); for (TypeElement anno: annotations) { @@ -42,8 +41,6 @@ public class A extends AbstractProcessor { return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } + @SuppressWarnings("") + private void foo() {} } diff --git a/test/tools/javac/processing/6414633/T6414633.java b/test/tools/javac/processing/6414633/T6414633.java index 29ef3caf5997c77fe83a40b601bc10314026445c..0ae395153cb847e582569b4a798acc8e24270ca3 100644 --- a/test/tools/javac/processing/6414633/T6414633.java +++ b/test/tools/javac/processing/6414633/T6414633.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ * @test * @bug 6414633 6440109 * @summary Only the first processor message at a source location is reported - * @build A T6414633 + * @library ../../lib + * @build JavacTestingAbstractProcessor A T6414633 * @run main T6414633 */ @@ -55,8 +56,7 @@ public class T6414633 { fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java"))); String[] opts = { "-proc:only", "-processor", A.class.getName(), - "-source", "1.6", - "-classpath", testClasses }; + "-classpath", testClasses + System.getProperty("path.separator") + "../../lib" }; JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files); task.call(); diff --git a/test/tools/javac/processing/6430209/T6430209.java b/test/tools/javac/processing/6430209/T6430209.java index 69b7bf5d29423a1e0a76eb8e41d0ea7503551117..0f65f86be07d0fd5a4442c98d1f246b51775316b 100644 --- a/test/tools/javac/processing/6430209/T6430209.java +++ b/test/tools/javac/processing/6430209/T6430209.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,8 @@ * @test * @bug 6441871 * @summary spurious compiler error elicited by packageElement.getEnclosedElements() - * @build b6341534 + * @library ../../lib + * @build JavacTestingAbstractProcessor b6341534 * @run main T6430209 */ @@ -54,7 +55,7 @@ public class T6430209 { // run annotation processor b6341534 so we can check diagnostics // -proc:only -processor b6341534 -cp . ./src/*.java String testSrc = System.getProperty("test.src", "."); - String testClasses = System.getProperty("test.classes"); + String testClasses = System.getProperty("test.classes") + System.getProperty("path.separator") + "../../lib"; JavacTool tool = JavacTool.create(); MyDiagListener dl = new MyDiagListener(); StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); diff --git a/test/tools/javac/processing/6430209/b6341534.java b/test/tools/javac/processing/6430209/b6341534.java index cc52af24a39411ee7537f4791da97e714186f704..5dfad046c9030848d4b9626f1df551c6ca04f2a3 100644 --- a/test/tools/javac/processing/6430209/b6341534.java +++ b/test/tools/javac/processing/6430209/b6341534.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,16 +30,9 @@ import static javax.tools.Diagnostic.Kind.*; import java.util.*; import java.util.Set; -@SupportedAnnotationTypes({"*"}) -public class b6341534 extends AbstractProcessor { +public class b6341534 extends JavacTestingAbstractProcessor { static int r = 0; - static Elements E = null; - static Messager msgr = null; - public void init(ProcessingEnvironment penv) { - processingEnv = penv; - msgr = penv.getMessager(); - E = penv.getElementUtils(); - } + //Create directory 'dir1' and a test class in dir1 public boolean process(Set tes, RoundEnvironment renv) { @@ -49,13 +42,13 @@ public class b6341534 extends AbstractProcessor { System.out.println("Round"+r+ ": " + t.toString()); try { - PackageElement PE = E.getPackageElement("dir1"); + PackageElement PE = eltUtils.getPackageElement("dir1"); List LEE = PE.getEnclosedElements(); /* <=This line elicits the error message. */ for(Element e : LEE) System.out.println("found " + e.toString() + " in dir1."); } catch(NullPointerException npe) { - msgr.printMessage(ERROR,npe.toString()); + messager.printMessage(ERROR,npe.toString()); //npe.printStackTrace(); return false; } @@ -63,13 +56,8 @@ public class b6341534 extends AbstractProcessor { // on round 1, expect errorRaised == false && processingOver == false // on round 2, expect errorRaised == true && processingOver == true if( renv.errorRaised() != renv.processingOver()) { - msgr.printMessage(ERROR, "FAILED"); + messager.printMessage(ERROR, "FAILED"); } return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/6499119/ClassProcessor.java b/test/tools/javac/processing/6499119/ClassProcessor.java index 900474e846047514f36bf562563eebe227ee71e0..b2b7203c0e791e99415cee4f826cc3915d476a26 100644 --- a/test/tools/javac/processing/6499119/ClassProcessor.java +++ b/test/tools/javac/processing/6499119/ClassProcessor.java @@ -32,20 +32,17 @@ import javax.tools.Diagnostic.Kind; * @test * @bug 6499119 * @summary Created package-info class file modeled improperly + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile ClassProcessor.java package-info.java * @compile/process -cp . -processor ClassProcessor -Akind=java java.lang.Object * @compile/process -cp . -processor ClassProcessor -Akind=class java.lang.Object */ @SupportedOptions({ "gen", "expect" }) -@SupportedAnnotationTypes({"*"}) -public class ClassProcessor extends AbstractProcessor { +public class ClassProcessor extends JavacTestingAbstractProcessor { int round = 1; - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - public boolean process(Set annotations, RoundEnvironment roundEnv) { if (round == 1) { System.out.println("-- Round 1 --"); @@ -71,8 +68,6 @@ public class ClassProcessor extends AbstractProcessor { } private void createPackageFile() { - Filer filer = processingEnv.getFiler(); - String kind = processingEnv.getOptions().get("kind"); File pkgInfo; @@ -125,7 +120,6 @@ public class ClassProcessor extends AbstractProcessor { } private void error(String msg) { - Messager messager = processingEnv.getMessager(); messager.printMessage(Kind.ERROR, msg); } } diff --git a/test/tools/javac/processing/6511613/DummyProcessor.java b/test/tools/javac/processing/6511613/DummyProcessor.java index a5307f2f1ca38a01c0960e3276db8bb36ed7ac5c..c05537ed6ecb30e12501e9f8187da63d803fe844 100644 --- a/test/tools/javac/processing/6511613/DummyProcessor.java +++ b/test/tools/javac/processing/6511613/DummyProcessor.java @@ -26,15 +26,10 @@ import javax.lang.model.*; import javax.lang.model.element.*; import java.util.Set; -@SupportedAnnotationTypes("*") -public class DummyProcessor extends AbstractProcessor { +public class DummyProcessor extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/6511613/clss41701.java b/test/tools/javac/processing/6511613/clss41701.java index 1d5c7819f2e94e8c0e801eadf5936a5bb7df0819..670ae5e269f9c12ac936703c5c33debcd9753a6c 100644 --- a/test/tools/javac/processing/6511613/clss41701.java +++ b/test/tools/javac/processing/6511613/clss41701.java @@ -26,7 +26,8 @@ * @bug 6511613 * @summary javac unexpectedly doesn't fail in some cases if an annotation processor specified * - * @build DummyProcessor + * @library ../../lib + * @build JavacTestingAbstractProcessor DummyProcessor * @compile/fail clss41701.java * @compile/fail -processor DummyProcessor clss41701.java */ diff --git a/test/tools/javac/processing/6512707/T6512707.java b/test/tools/javac/processing/6512707/T6512707.java index 505528fd8eebf1f66fb8e78e17d7838487e92948..26c72f9ff9509ad1c2ca1d8279740415b1310038 100644 --- a/test/tools/javac/processing/6512707/T6512707.java +++ b/test/tools/javac/processing/6512707/T6512707.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,8 +26,9 @@ * @bug 6512707 * @summary "incompatible types" after (unrelated) annotation processing * @author Peter Runge + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile T6512707.java - * * @compile -processor T6512707 TestAnnotation.java */ @@ -41,16 +42,10 @@ import javax.lang.model.util.*; * Dummy processor to force bug 6512707 to show - it does not matter what * the annotation processor does for this bug. */ -@SupportedAnnotationTypes("*") -public class T6512707 extends AbstractProcessor { +public class T6512707 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { - return(false); - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); + return false; } } diff --git a/test/tools/javac/processing/6634138/T6634138.java b/test/tools/javac/processing/6634138/T6634138.java index c7ce94b6e26f1f7179a20053f6dc36e4ee0c9797..54409e5ecb401d5bbead5a338034649020fdc782 100644 --- a/test/tools/javac/processing/6634138/T6634138.java +++ b/test/tools/javac/processing/6634138/T6634138.java @@ -26,6 +26,8 @@ * @bug 6634138 * @author Joseph D. Darcy * @summary Verify source files output after processing is over are compiled + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile T6634138.java * @compile -processor T6634138 Dummy.java * @run main ExerciseDependency @@ -44,10 +46,7 @@ import javax.lang.model.SourceVersion; import javax.lang.model.element.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class T6634138 extends AbstractProcessor { - private Filer filer; - +public class T6634138 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { // Write out files *after* processing is over. @@ -77,16 +76,6 @@ public class T6634138 extends AbstractProcessor { } return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - filer = processingEnv.getFiler(); - } } diff --git a/test/tools/javac/processing/T6439826.java b/test/tools/javac/processing/T6439826.java index 91c36aeed5141fd87af420a69913868342f96a2d..ac484655f376aed3d3f0de72539cb9af842d521b 100644 --- a/test/tools/javac/processing/T6439826.java +++ b/test/tools/javac/processing/T6439826.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,8 +48,7 @@ public class T6439826 extends AbstractProcessor { StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); Iterable files = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java"))); - Iterable opts = Arrays.asList("-source","1.6", - "-proc:only", + Iterable opts = Arrays.asList("-proc:only", "-processor", "T6439826", "-processorpath", testClasses); StringWriter out = new StringWriter(); diff --git a/test/tools/javac/processing/T6920317.java b/test/tools/javac/processing/T6920317.java index 981607cf01cf0a31a87ab847014cbfce75754961..1f005090361a85b3ecffa518a364103c8c76d870 100644 --- a/test/tools/javac/processing/T6920317.java +++ b/test/tools/javac/processing/T6920317.java @@ -25,6 +25,7 @@ * @test * @bug 6920317 * @summary package-info.java file has to be specified on the javac cmdline, else it will not be avail + * @library ../lib */ import java.io.*; @@ -349,12 +350,7 @@ public class T6920317 { /** Annotation processor used to verify the expected value for the package annotations found by javac. */ @SupportedOptions({ "gen", "expect" }) - @SupportedAnnotationTypes({"*"}) - public static class Processor extends AbstractProcessor { - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - + public static class Processor extends JavacTestingAbstractProcessor { public boolean process(Set annots, RoundEnvironment renv) { round++; System.err.println("Round " + round + " annots:" + annots + " rootElems:" + renv.getRootElements()); diff --git a/test/tools/javac/processing/environment/TestSourceVersion.java b/test/tools/javac/processing/environment/TestSourceVersion.java index dc3e7773a03aec6f2110136aea014ecbcf205194..28118bb7e0a46a0d9e359c7dc0b253063af98fd6 100644 --- a/test/tools/javac/processing/environment/TestSourceVersion.java +++ b/test/tools/javac/processing/environment/TestSourceVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6402506 * @summary Test that getSourceVersion works properly * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestSourceVersion.java * @compile -processor TestSourceVersion -proc:only -source 1.2 -AExpectedVersion=RELEASE_2 HelloWorld.java * @compile -processor TestSourceVersion -proc:only -source 1.3 -AExpectedVersion=RELEASE_3 HelloWorld.java @@ -52,9 +54,8 @@ import static javax.tools.Diagnostic.Kind.*; * This processor checks that ProcessingEnvironment.getSourceVersion() * is consistent with the setting of the -source option. */ -@SupportedAnnotationTypes("*") @SupportedOptions("ExpectedVersion") -public class TestSourceVersion extends AbstractProcessor { +public class TestSourceVersion extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { @@ -68,9 +69,4 @@ public class TestSourceVersion extends AbstractProcessor { return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java index 22b180ad085787d3653dc76fd03dedd238a11294..0bf241b8e80bad761752ab328ea5692403d696fa 100644 --- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 * @summary Tests that getElementsAnnotatedWith works properly. * @author Joseph D. Darcy + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile TestElementsAnnotatedWith.java * @compile InheritedAnnotation.java * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java @@ -57,16 +59,13 @@ import static javax.lang.model.util.ElementFilter.*; * getElementsAnnotatedWith is consistent with the expected results * stored in an AnnotatedElementInfo annotation. */ -@SupportedAnnotationTypes("*") @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", expectedSize=0, names={}) -public class TestElementsAnnotatedWith extends AbstractProcessor { +public class TestElementsAnnotatedWith extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { - Elements elementUtils = processingEnv.getElementUtils(); - TypeElement annotatedElementInfoElement = - elementUtils.getTypeElement("AnnotatedElementInfo"); + elements.getTypeElement("AnnotatedElementInfo"); Set resultsMeta = Collections.emptySet(); Set resultsBase = Collections.emptySet(); @@ -93,9 +92,7 @@ public class TestElementsAnnotatedWith extends AbstractProcessor { resultsMeta = roundEnvironment. - getElementsAnnotatedWith(elementUtils. - getTypeElement(annotatedElementInfo. - annotationName())) ; + getElementsAnnotatedWith(elements.getTypeElement(annotatedElementInfo.annotationName())); System.err.println("Results: " + resultsMeta); @@ -167,9 +164,4 @@ public class TestElementsAnnotatedWith extends AbstractProcessor { throw new RuntimeException("Illegal argument exception not thrown"); } catch(IllegalArgumentException iae) {} } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java b/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java index 0ba614d42741ec48e8b987e144febaaaf269ebf9..cd42f6bd06a35c8470316e1a5c96ebb6b16f53bf 100644 --- a/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java +++ b/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,9 @@ * @bug 6403459 * @summary Test that generating programs with syntax errors is a fatal condition * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor + * @compile TestReturnCode.java * @compile TestFatalityOfParseErrors.java * @compile/fail -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java */ @@ -45,11 +48,8 @@ import java.io.IOException; * Write out an incomplete source file and observe that the next round * is marked as an error. */ -@SupportedAnnotationTypes("*") -public class TestFatalityOfParseErrors extends AbstractProcessor { +public class TestFatalityOfParseErrors extends JavacTestingAbstractProcessor { int round = 0; - Messager messager; - Filer filer; public boolean process(Set annotations, RoundEnvironment roundEnvironment) { @@ -87,14 +87,4 @@ public class TestFatalityOfParseErrors extends AbstractProcessor { } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - messager = processingEnv.getMessager(); - filer = processingEnv.getFiler(); - } } diff --git a/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java b/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java index 6784def2cd587253f2e282a213f4e3734cf7299c..4f2ad1b2243d3aa3485a587ee84df0523ca05c92 100644 --- a/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java +++ b/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6406212 * @summary Test that annotation processor options with illegal syntax are rejected * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestOptionSyntaxErrors.java * @compile/fail -A TestOptionSyntaxErrors.java * @compile/fail -A8adOption TestOptionSyntaxErrors.java @@ -46,14 +48,9 @@ import static javax.tools.Diagnostic.Kind.*; /** * No-op processor; should not be run. */ -@SupportedAnnotationTypes("*") -public class TestOptionSyntaxErrors extends AbstractProcessor { +public class TestOptionSyntaxErrors extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/errors/TestReturnCode.java b/test/tools/javac/processing/errors/TestReturnCode.java index 61cb2a05b72819e3771d80d11f8bfe7d1241c463..22c9aae24f7b69c0460e16624345db646255964c 100644 --- a/test/tools/javac/processing/errors/TestReturnCode.java +++ b/test/tools/javac/processing/errors/TestReturnCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6403468 * @summary Test that an erroneous return code results from raising an error. * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestReturnCode.java * * @compile -processor TestReturnCode -proc:only Foo.java @@ -60,20 +62,17 @@ import static javax.tools.Diagnostic.Kind.*; * This processor raises errors or throws exceptions on different * rounds to allow the return code to be test. */ -@SupportedAnnotationTypes("*") @SupportedOptions({"ErrorOnFirst", "ErrorOnLast", "ExceptionOnFirst", "ExceptionOnLast"}) -public class TestReturnCode extends AbstractProcessor { +public class TestReturnCode extends JavacTestingAbstractProcessor { private boolean errorOnFirst; private boolean errorOnLast; private boolean exceptionOnFirst; private boolean exceptionOnLast; - private Messager messager; - public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { @@ -103,11 +102,5 @@ public class TestReturnCode extends AbstractProcessor { errorOnLast = keySet.contains("ErrorOnLast"); exceptionOnFirst = keySet.contains("ExceptionOnFirst"); exceptionOnLast = keySet.contains("ExceptionOnLast"); - messager = processingEnv.getMessager(); - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); } } diff --git a/test/tools/javac/processing/filer/TestFilerConstraints.java b/test/tools/javac/processing/filer/TestFilerConstraints.java index 7f3202eca30e8ff89dd63a46c76db86d49036b66..8509fb2e15a7477eb0382154888813efb7500c6a 100644 --- a/test/tools/javac/processing/filer/TestFilerConstraints.java +++ b/test/tools/javac/processing/filer/TestFilerConstraints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 6380018 6453386 6457283 * @summary Test that the constraints guaranteed by the Filer and maintained * @author Joseph D. Darcy + * @library ../../lib * @build TestFilerConstraints * @compile -encoding iso-8859-1 -processor TestFilerConstraints -proc:only TestFilerConstraints.java */ @@ -69,11 +70,8 @@ import java.nio.charset.Charset; * * */ -@SupportedAnnotationTypes("*") -public class TestFilerConstraints extends AbstractProcessor { +public class TestFilerConstraints extends JavacTestingAbstractProcessor { private int round = 0; - private Messager messager; - private Filer filer; private PrintWriter pw_src1 = null; private PrintWriter pw_src2 = null; @@ -167,17 +165,6 @@ public class TestFilerConstraints extends AbstractProcessor { return true; } - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - messager = processingEnv.getMessager(); - filer = processingEnv.getFiler(); - - } - /** * Test that the single expected expected type, name, is the root * element. diff --git a/test/tools/javac/processing/filer/TestGetResource.java b/test/tools/javac/processing/filer/TestGetResource.java index ee55a1a4389a6041f71225c2c41668239758a09c..5d5641214e1c8e8b7fd44dcf35f488b4727e6453 100644 --- a/test/tools/javac/processing/filer/TestGetResource.java +++ b/test/tools/javac/processing/filer/TestGetResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6380018 6449798 * @summary Test Filer.getResource * @author Joseph D. Darcy - * @build TestGetResource + * @library ../../lib + * @build JavacTestingAbstractProcessor TestGetResource * @compile -processor TestGetResource -proc:only -Aphase=write TestGetResource.java * @compile -processor TestGetResource -proc:only -Aphase=read TestGetResource.java */ @@ -49,13 +50,8 @@ import java.io.PrintWriter; * first run of the annotation processor, write out a resource file * and on the second run read it in. */ -@SupportedAnnotationTypes("*") @SupportedOptions("phase") -public class TestGetResource extends AbstractProcessor { - private Messager messager; - private Filer filer; - private Map options; - +public class TestGetResource extends JavacTestingAbstractProcessor { private static String CONTENTS = "Hello World."; private static String PKG = ""; private static String RESOURCE_NAME = "Resource1"; @@ -92,15 +88,4 @@ public class TestGetResource extends AbstractProcessor { } return false; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - messager = processingEnv.getMessager(); - filer = processingEnv.getFiler(); - options = processingEnv.getOptions(); - } } diff --git a/test/tools/javac/processing/filer/TestGetResource2.java b/test/tools/javac/processing/filer/TestGetResource2.java index 49befdf4e34771dede4613093b6c026002701d37..6ce067d4c31a08c9ae3f9392b2efd3585ba10f58 100644 --- a/test/tools/javac/processing/filer/TestGetResource2.java +++ b/test/tools/javac/processing/filer/TestGetResource2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* @test * @bug 6929404 * @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry + * @library ../../lib */ import java.io.*; @@ -114,8 +115,7 @@ public class TestGetResource2 { throw new Exception(errors + " errors occurred"); } - @SupportedAnnotationTypes("*") - static class AnnoProc extends AbstractProcessor { + static class AnnoProc extends JavacTestingAbstractProcessor { public @Override boolean process(Set annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { @@ -123,27 +123,23 @@ public class TestGetResource2 { } try { - FileObject resource = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt"); + FileObject resource = filer.getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt"); try { resource.openInputStream().close(); - processingEnv.getMessager().printMessage(Kind.NOTE, "found: " + resource.toUri()); + messager.printMessage(Kind.NOTE, "found: " + resource.toUri()); return true; } catch (IOException x) { - processingEnv.getMessager().printMessage(Kind.ERROR, "could not read: " + resource.toUri()); + messager.printMessage(Kind.ERROR, "could not read: " + resource.toUri()); x.printStackTrace(); } } catch (IOException x) { - processingEnv.getMessager().printMessage(Kind.ERROR, "did not find resource"); + messager.printMessage(Kind.ERROR, "did not find resource"); x.printStackTrace(); } return false; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } private File write(File dir, String path, String contents) throws IOException { diff --git a/test/tools/javac/processing/filer/TestInvalidRelativeNames.java b/test/tools/javac/processing/filer/TestInvalidRelativeNames.java index 5c8a7a5f2ab36ced16f5a1e1172d3cd9556e9cca..4a0efd53560482156f34fae2a4ab30eb7845bc27 100644 --- a/test/tools/javac/processing/filer/TestInvalidRelativeNames.java +++ b/test/tools/javac/processing/filer/TestInvalidRelativeNames.java @@ -25,6 +25,8 @@ * @test * @bug 6502392 * @summary Invalid relative names for Filer.createResource and Filer.getResource + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestInvalidRelativeNames.java * @compile/process -processor TestInvalidRelativeNames java.lang.Object */ @@ -37,30 +39,13 @@ import javax.lang.model.element.*; import javax.tools.Diagnostic; import javax.tools.StandardLocation; - -@SupportedAnnotationTypes("*") -public class TestInvalidRelativeNames extends AbstractProcessor { +public class TestInvalidRelativeNames extends JavacTestingAbstractProcessor { enum Kind { CREATE_WRITER, GET_READER, CREATE_OUTPUT_STREAM, GET_INPUT_STREAM }; static final String[] invalidRelativeNames = { "/boo", "goo/../hoo", "./ioo", "" }; - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - Filer filer; - Messager messager; - - @Override - public void init(ProcessingEnvironment pEnv) { - super.init(pEnv); - filer = processingEnv.getFiler(); - messager = processingEnv.getMessager(); - } - public boolean process(Set annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { for (String relative: invalidRelativeNames) { diff --git a/test/tools/javac/processing/filer/TestLastRound.java b/test/tools/javac/processing/filer/TestLastRound.java index efef9e15ec0865c67656fb7b5ad0038d51325f20..57c76af78e754e344a8b43b715d9373926bf313c 100644 --- a/test/tools/javac/processing/filer/TestLastRound.java +++ b/test/tools/javac/processing/filer/TestLastRound.java @@ -24,6 +24,8 @@ /* * @test 6966604 * @summary JavacFiler not correctly notified of lastRound + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestLastRound.java * @compile/fail/ref=TestLastRound.out -XDrawDiagnostics -Werror -proc:only -processor TestLastRound TestLastRound.java */ @@ -35,12 +37,10 @@ import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class TestLastRound extends AbstractProcessor { +public class TestLastRound extends JavacTestingAbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - Filer filer = processingEnv.getFiler(); if (roundEnv.processingOver()) { try { JavaFileObject fo = filer.createSourceFile("LastRound.java"); @@ -52,9 +52,4 @@ public class TestLastRound extends AbstractProcessor { } return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/filer/TestPackageInfo.java b/test/tools/javac/processing/filer/TestPackageInfo.java index 2e7ae10521c6fdb6434b940bcb28b05dc5625dd3..7a905467370f217627d99663732294cbb63e778e 100644 --- a/test/tools/javac/processing/filer/TestPackageInfo.java +++ b/test/tools/javac/processing/filer/TestPackageInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6380018 6392177 * @summary Test the ability to create and process package-info.java files * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile TestPackageInfo.java * @compile -processor TestPackageInfo -proc:only foo/bar/package-info.java TestPackageInfo.java */ @@ -49,13 +51,7 @@ import java.io.*; * 1) Visibility of package-info files from the command line * 2) Visibility of generated package-info.java source files */ -@SupportedAnnotationTypes("*") -public class TestPackageInfo extends AbstractProcessor { - private Elements eltUtils; - private Messager messager; - private Filer filer; - private Map options; - +public class TestPackageInfo extends JavacTestingAbstractProcessor { private int round = 0; public boolean process(Set annotations, @@ -64,11 +60,7 @@ public class TestPackageInfo extends AbstractProcessor { // Verify annotations are as expected Set expectedAnnotations = new HashSet(); - if (round == 1) - expectedAnnotations.add(eltUtils. - getTypeElement("javax.annotation.processing.SupportedAnnotationTypes")); - expectedAnnotations.add(eltUtils. - getTypeElement("java.lang.SuppressWarnings")); + expectedAnnotations.add(eltUtils.getTypeElement("java.lang.SuppressWarnings")); if (!roundEnv.processingOver()) { System.out.println("\nRound " + round); @@ -127,16 +119,4 @@ public class TestPackageInfo extends AbstractProcessor { } return false; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - eltUtils = processingEnv.getElementUtils(); - messager = processingEnv.getMessager(); - filer = processingEnv.getFiler(); - options = processingEnv.getOptions(); - } } diff --git a/test/tools/javac/processing/messager/6362067/T6362067.java b/test/tools/javac/processing/messager/6362067/T6362067.java index ce5bd8d0bedbba117995fd817da3ed3f7011d3fe..ef2cec88d286571c79eaa472311cbaaac78d4d38 100644 --- a/test/tools/javac/processing/messager/6362067/T6362067.java +++ b/test/tools/javac/processing/messager/6362067/T6362067.java @@ -2,39 +2,34 @@ * @test /nodynamiccopyright/ * @bug 6362067 * @summary Messager methods do not print out source position information - * @build T6362067 + * @library ../../../lib + * @build JavacTestingAbstractProcessor T6362067 * @compile -processor T6362067 -proc:only T6362067.java * @compile/ref=T6362067.out -XDrawDiagnostics -processor T6362067 -proc:only T6362067.java */ - import java.util.Set; import javax.annotation.processing.*; import javax.lang.model.element.*; import static javax.tools.Diagnostic.Kind.*; -@Deprecated // convenient test annotation -@SupportedAnnotationTypes("*") -public class T6362067 extends AbstractProcessor { +@Deprecated // convenient test annotations +@SuppressWarnings({""}) +public class T6362067 extends JavacTestingAbstractProcessor { public boolean process(Set annos, RoundEnvironment roundEnv) { - Messager msgr = processingEnv.getMessager(); + for (Element e: roundEnv.getRootElements()) { - msgr.printMessage(NOTE, "note:elem", e); + messager.printMessage(NOTE, "note:elem", e); for (AnnotationMirror a: e.getAnnotationMirrors()) { - msgr.printMessage(NOTE, "note:anno", e, a); + messager.printMessage(NOTE, "note:anno", e, a); for (AnnotationValue v: a.getElementValues().values()) { - msgr.printMessage(NOTE, "note:value", e, a, v); + messager.printMessage(NOTE, "note:value", e, a, v); } - } } + if (roundEnv.processingOver()) - msgr.printMessage(NOTE, "note:nopos"); + messager.printMessage(NOTE, "note:nopos"); return true; } - - @Override - public javax.lang.model.SourceVersion getSupportedSourceVersion() { - return javax.lang.model.SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/messager/MessagerBasics.java b/test/tools/javac/processing/messager/MessagerBasics.java index cbcbf094a42ff77b7d8bfbe59db87b80938d1929..f7980c7010926d3cb03ee2e823e66ea990ed8996 100644 --- a/test/tools/javac/processing/messager/MessagerBasics.java +++ b/test/tools/javac/processing/messager/MessagerBasics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6341173 6341072 * @summary Test presence of Messager methods * @author Joseph D. Darcy + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile MessagerBasics.java * @compile -processor MessagerBasics -proc:only MessagerBasics.java * @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java @@ -39,18 +41,16 @@ import javax.lang.model.element.*; import javax.lang.model.util.*; import static javax.tools.Diagnostic.Kind.*; -@SupportedAnnotationTypes("*") @SupportedOptions("finalError") -public class MessagerBasics extends AbstractProcessor { +public class MessagerBasics extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { - Messager m = processingEnv.getMessager(); if (roundEnv.processingOver()) { if (processingEnv.getOptions().containsKey("finalError")) - m.printMessage(ERROR, "Does not compute"); + messager.printMessage(ERROR, "Does not compute"); else { - m.printMessage(NOTE, "Post no bills"); - m.printMessage(WARNING, "Beware the ides of March!"); + messager.printMessage(NOTE, "Post no bills"); + messager.printMessage(WARNING, "Beware the ides of March!"); } } return true; diff --git a/test/tools/javac/processing/model/6194785/T6194785.java b/test/tools/javac/processing/model/6194785/T6194785.java index 8b18b48f71204d92e9c1c3895a82f67a14b2e0a8..11abd61a1d69d433e782799ad410868c99346c4a 100644 --- a/test/tools/javac/processing/model/6194785/T6194785.java +++ b/test/tools/javac/processing/model/6194785/T6194785.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6194785 * @summary ParameterDeclaration.getSimpleName does not return actual name from class files * @author Peter von der Ah\u00e9 + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile -g T6194785.java T6194785a.java * @compile -processor T6194785 foo.T6194785a T6194785.java */ @@ -36,13 +38,10 @@ import javax.lang.model.element.*; import javax.lang.model.util.*; import static javax.tools.Diagnostic.Kind.*; -@SupportedAnnotationTypes("*") -public class T6194785 extends AbstractProcessor { +public class T6194785 extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnvironment) { - final Messager log = processingEnv.getMessager(); - final Elements elements = processingEnv.getElementUtils(); class Scan extends ElementScanner7 { @Override public Void visitExecutable(ExecutableElement e, Void ignored) { diff --git a/test/tools/javac/processing/model/6341534/T6341534.java b/test/tools/javac/processing/model/6341534/T6341534.java index b374d65eb058a6fe436e6f7018ce0061b886a8dc..2950909590e9abc5de22d32d95a90f86e3cfd9be 100644 --- a/test/tools/javac/processing/model/6341534/T6341534.java +++ b/test/tools/javac/processing/model/6341534/T6341534.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,8 @@ * @summary PackageElement.getEnclosedElements results in NullPointerException from parse(JavaCompiler.java:429) * @author Steve Sides * @author Peter von der Ahe + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile T6341534.java * @compile -proc:only -processor T6341534 dir/package-info.java * @compile -processor T6341534 dir/package-info.java @@ -40,20 +42,11 @@ import java.util.*; import java.util.Set; import static javax.tools.Diagnostic.Kind.*; -@SupportedAnnotationTypes("*") -public class T6341534 extends AbstractProcessor { - Elements elements; - Messager messager; - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - messager = processingEnv.getMessager(); - } - +public class T6341534 extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment renv) { messager.printMessage(NOTE, - String.valueOf(elements.getPackageElement("no.such.package"))); - PackageElement dir = elements.getPackageElement("dir"); + String.valueOf(eltUtils.getPackageElement("no.such.package"))); + PackageElement dir = eltUtils.getPackageElement("dir"); messager.printMessage(NOTE, dir.getQualifiedName().toString()); for (Element e : dir.getEnclosedElements()) messager.printMessage(NOTE, e.toString()); diff --git a/test/tools/javac/processing/model/element/TestAnonClassNames.java b/test/tools/javac/processing/model/element/TestAnonClassNames.java index 62c7964416f1247a14ee24474043a21000509fa1..f5bddff0a4565bc0df45c0f028a63965f9bcbcfd 100644 --- a/test/tools/javac/processing/model/element/TestAnonClassNames.java +++ b/test/tools/javac/processing/model/element/TestAnonClassNames.java @@ -26,7 +26,8 @@ * @bug 6449781 * @summary Test that reported names of anonymous classes are non-null. * @author Joseph D. Darcy - * @build TestAnonSourceNames + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestAnonSourceNames * @compile -processor TestAnonSourceNames TestAnonClassNames.java * @run main TestAnonClassNames */ @@ -141,8 +142,7 @@ public class TestAnonClassNames { /** * Probe at the various kinds of names of a type element. */ -@SupportedAnnotationTypes("*") -class ClassNameProber extends AbstractProcessor { +class ClassNameProber extends JavacTestingAbstractProcessor { public ClassNameProber(){super();} private boolean classesFound=false; @@ -174,8 +174,4 @@ class ClassNameProber extends AbstractProcessor { } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/model/element/TestAnonSourceNames.java b/test/tools/javac/processing/model/element/TestAnonSourceNames.java index ff16b5df3898df6e43b7b0aea55ec0a096fb0b74..84184b304079ecd4fb1dfa3028ab40b4ca8049e9 100644 --- a/test/tools/javac/processing/model/element/TestAnonSourceNames.java +++ b/test/tools/javac/processing/model/element/TestAnonSourceNames.java @@ -36,8 +36,7 @@ import static javax.tools.Diagnostic.Kind.*; * Using the tree API, retrieve element representations of anonymous * classes and verify their names are as specified. */ -@SupportedAnnotationTypes("*") -public class TestAnonSourceNames extends AbstractProcessor { +public class TestAnonSourceNames extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { @@ -84,9 +83,4 @@ public class TestAnonSourceNames extends AbstractProcessor { return super.visitClass(node, cu); } } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/model/element/TestElement.java b/test/tools/javac/processing/model/element/TestElement.java index 8e38da4879ec731b1ccc8d8cb2bdf5987227f7ec..004a5058aa2ef16728f6214904a93ed5013b8e2b 100644 --- a/test/tools/javac/processing/model/element/TestElement.java +++ b/test/tools/javac/processing/model/element/TestElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6453386 * @summary Test basic properties of javax.lang.element.Element * @author Joseph D. Darcy - * @build TestElement + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestElement * @compile -processor TestElement -proc:only TestElement.java */ @@ -43,8 +44,7 @@ import static javax.tools.StandardLocation.*; /** * Test basic workings of javax.lang.element.Element */ -@SupportedAnnotationTypes("*") -public class TestElement extends AbstractProcessor { +public class TestElement extends JavacTestingAbstractProcessor { /** * For now, just check that constructors have a simple name of * "". @@ -66,9 +66,4 @@ public class TestElement extends AbstractProcessor { } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - } diff --git a/test/tools/javac/processing/model/element/TestNames.java b/test/tools/javac/processing/model/element/TestNames.java index fe1683115a76de2324541426b557dc8efdbaf143..1aec65ec4bfb51b31ff1ba0e847fcbaf9c6bc43b 100644 --- a/test/tools/javac/processing/model/element/TestNames.java +++ b/test/tools/javac/processing/model/element/TestNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6380016 * @summary Test that the constraints guaranteed by the Filer and maintained * @author Joseph D. Darcy - * @build TestNames + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestNames * @compile -processor TestNames -proc:only TestNames.java */ @@ -45,11 +46,8 @@ import java.io.*; /** * Basic tests of semantics of javax.lang.model.element.Name */ -@SupportedAnnotationTypes("*") -public class TestNames extends AbstractProcessor { +public class TestNames extends JavacTestingAbstractProcessor { private int round = 0; - private Filer filer; - private Elements eltUtils; String stringStringName = "java.lang.String"; Name stringName = null; @@ -106,16 +104,6 @@ public class TestNames extends AbstractProcessor { return true; } - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - filer = processingEnv.getFiler(); - eltUtils = processingEnv.getElementUtils(); - } - private static class Pseudonym implements Name { private String name; diff --git a/test/tools/javac/processing/model/element/TestPackageElement.java b/test/tools/javac/processing/model/element/TestPackageElement.java index 5b44c5ade98707b8e1fceec2da059098467534d2..4e0575be93bc6efe2a82d1924686faf19a9de7e9 100644 --- a/test/tools/javac/processing/model/element/TestPackageElement.java +++ b/test/tools/javac/processing/model/element/TestPackageElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6449798 6399404 * @summary Test basic workings of PackageElement * @author Joseph D. Darcy - * @build TestPackageElement + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestPackageElement * @compile -processor TestPackageElement -proc:only TestPackageElement.java */ @@ -43,11 +44,7 @@ import static javax.tools.StandardLocation.*; /** * Test basic workings of PackageElement. */ -@SupportedAnnotationTypes("*") -public class TestPackageElement extends AbstractProcessor { - private Filer filer; - private Elements eltUtils; - +public class TestPackageElement extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { @@ -71,15 +68,4 @@ public class TestPackageElement extends AbstractProcessor { } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - filer = processingEnv.getFiler(); - eltUtils = processingEnv.getElementUtils(); - } - } diff --git a/test/tools/javac/processing/model/element/TestResourceElement.java b/test/tools/javac/processing/model/element/TestResourceElement.java index 9bb71b829a1eaee551eaba49ec4d4dd2b444268e..a6e6de829d59452054abb2bea714481bde9cc83d 100644 --- a/test/tools/javac/processing/model/element/TestResourceElement.java +++ b/test/tools/javac/processing/model/element/TestResourceElement.java @@ -26,7 +26,8 @@ * @bug 6967842 * @summary Element not returned from tree API for ARM resource variables. * @author A. Sundararajan - * @build TestResourceElement + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestResourceElement * @compile -processor TestResourceElement -proc:only TestResourceElement.java */ @@ -37,8 +38,7 @@ import java.util.*; import com.sun.source.tree.*; import com.sun.source.util.*; -@SupportedAnnotationTypes("*") -public class TestResourceElement extends AbstractProcessor implements AutoCloseable { +public class TestResourceElement extends JavacTestingAbstractProcessor implements AutoCloseable { public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { @@ -88,9 +88,4 @@ public class TestResourceElement extends AbstractProcessor implements AutoClosea return trvElement; } } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/model/element/TestResourceVariable.java b/test/tools/javac/processing/model/element/TestResourceVariable.java index f240ba7f0ee28314339ed3bfc20a99c5562c5ae2..4b5fcd26b0ee14c6e2a076046b3b0ce85663922d 100644 --- a/test/tools/javac/processing/model/element/TestResourceVariable.java +++ b/test/tools/javac/processing/model/element/TestResourceVariable.java @@ -26,7 +26,8 @@ * @bug 6911256 6964740 6967842 * @summary Test that the resource variable kind is appropriately set * @author Joseph D. Darcy - * @build TestResourceVariable + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestResourceVariable * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java */ @@ -48,8 +49,7 @@ import static javax.tools.Diagnostic.Kind.*; * resource of an ARM block and verify their kind tags are set * appropriately. */ -@SupportedAnnotationTypes("*") -public class TestResourceVariable extends AbstractProcessor implements AutoCloseable { +public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable { int resourceVariableCount = 0; public boolean process(Set annotations, @@ -105,9 +105,4 @@ public class TestResourceVariable extends AbstractProcessor implements AutoClose return super.visitVariable(node, cu); } } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/model/element/TypeParamBounds.java b/test/tools/javac/processing/model/element/TypeParamBounds.java index 0442c96a893856687df20699d30dba2aa3b82aad..c09e12bd49be2a8d1e9b2492c7447a9162a30d3a 100644 --- a/test/tools/javac/processing/model/element/TypeParamBounds.java +++ b/test/tools/javac/processing/model/element/TypeParamBounds.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6423972 * @summary Tests TypeParameter.getBounds. * @author Scott Seligman - * @build TypeParamBounds + * @library ../../../lib + * @build JavacTestingAbstractProcessor TypeParamBounds * @compile -processor TypeParamBounds -proc:only TypeParamBounds.java */ @@ -40,18 +41,7 @@ import javax.lang.model.element.*; import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class TypeParamBounds extends AbstractProcessor { - - Elements elements; - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - +public class TypeParamBounds extends JavacTestingAbstractProcessor { public boolean process(Set annoTypes, RoundEnvironment round) { if (!round.processingOver()) @@ -59,11 +49,6 @@ public class TypeParamBounds extends AbstractProcessor { return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private void doit(Set annoTypes, RoundEnvironment round) { TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen"); @@ -91,7 +76,6 @@ public class TypeParamBounds extends AbstractProcessor { // Fodder for the processor - static class Gen { diff --git a/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java b/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java index 30ab564a71bad1b1e025d5343a74cd572f95abb1..861014f4cce08ee497a02b545553b911381fa0de 100644 --- a/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java +++ b/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6362178 * @summary MirroredType[s]Exception shouldn't be created too eagerly * @author Scott Seligman + * @library ../../../../lib + * @build JavacTestingAbstractProcessor * @compile -g OverEager.java * @compile -processor OverEager -proc:only OverEager.java */ @@ -40,17 +42,7 @@ import static javax.lang.model.util.ElementFilter.*; @SupportedAnnotationTypes("IAm") @IAm(OverEager.class) -public class OverEager extends AbstractProcessor { - - Elements elements; - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - +public class OverEager extends JavacTestingAbstractProcessor { public boolean process(Set annoTypes, RoundEnvironment round) { if (!round.processingOver()) @@ -58,11 +50,6 @@ public class OverEager extends AbstractProcessor { return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private void doit(Set annoTypes, RoundEnvironment round) { for (TypeElement t : typesIn(round.getRootElements())) { diff --git a/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java b/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java index f7b6ca6694f6235193bb4f1a62ec4167c52e854f..e01ba019c7fb344325d078a5ac6bc7a85e82ae99 100644 --- a/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java +++ b/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java @@ -25,6 +25,8 @@ * @test * @bug 6519115 * @summary Verify MirroredTypeException vs MirroredTypesException is thrown + * @library ../../../../lib + * @build JavacTestingAbstractProcessor * @compile Plurality.java * @compile -processor Plurality -proc:only Plurality.java * @author Joseph D. Darcy @@ -38,25 +40,13 @@ import javax.lang.model.element.*; import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") @P0 @P1 @P2 @S1 -public class Plurality extends AbstractProcessor { +public class Plurality extends JavacTestingAbstractProcessor { private boolean executed = false; - Elements elements; - Types types; - - @Override - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - - public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { @@ -164,11 +154,6 @@ public class Plurality extends AbstractProcessor { toStringName); } } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } @Retention(RetentionPolicy.RUNTIME) diff --git a/test/tools/javac/processing/model/type/NoTypes.java b/test/tools/javac/processing/model/type/NoTypes.java index 3e26d6fd01d3d63936dfc1a79aa421ee4c9eac9e..d67dae187c4f3e033317d6e9993bd1e997bcee42 100644 --- a/test/tools/javac/processing/model/type/NoTypes.java +++ b/test/tools/javac/processing/model/type/NoTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6418666 6423973 6453386 * @summary Test the NoTypes: VOID, PACKAGE, NONE * @author Scott Seligman + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile -g NoTypes.java * @compile -processor NoTypes -proc:only NoTypes.java */ @@ -39,18 +41,7 @@ import javax.lang.model.util.*; import static javax.lang.model.type.TypeKind.*; -@SupportedAnnotationTypes("*") -public class NoTypes extends AbstractProcessor { - - Elements elements; - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - +public class NoTypes extends JavacTestingAbstractProcessor { public boolean process(Set annoTypes, RoundEnvironment round) { if (!round.processingOver()) @@ -58,11 +49,6 @@ public class NoTypes extends AbstractProcessor { return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private void doit(Set annoTypes, RoundEnvironment round) { diff --git a/test/tools/javac/processing/model/util/BinaryName.java b/test/tools/javac/processing/model/util/BinaryName.java index ebf5612b1ebf6e296313660a61ba65b285969ac8..02445ff2bd8442f8d8eb506cb76a59afd7f680e7 100644 --- a/test/tools/javac/processing/model/util/BinaryName.java +++ b/test/tools/javac/processing/model/util/BinaryName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6346251 * @summary Test Elements.getBinaryName * @author Scott Seligman - * @build BinaryName + * @library ../../../lib + * @build JavacTestingAbstractProcessor BinaryName * @compile -processor BinaryName -proc:only BinaryName.java */ @@ -38,17 +39,8 @@ import javax.lang.model.util.*; import static javax.lang.model.util.ElementFilter.typesIn; -@SupportedAnnotationTypes("*") @HelloIm("BinaryName") -public class BinaryName extends AbstractProcessor { - - Elements elements; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - } - +public class BinaryName extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; diff --git a/test/tools/javac/processing/model/util/GetTypeElemBadArg.java b/test/tools/javac/processing/model/util/GetTypeElemBadArg.java index 92b5c088f6d8499571204f373ce7e354865029d1..01782f327a546e283c7b5ca7c019b800c79709d9 100644 --- a/test/tools/javac/processing/model/util/GetTypeElemBadArg.java +++ b/test/tools/javac/processing/model/util/GetTypeElemBadArg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6346506 6408241 * @summary getTypeElement should tolerate a type that can't be found * @author Scott Seligman - * @build GetTypeElemBadArg + * @library ../../../lib + * @build JavacTestingAbstractProcessor GetTypeElemBadArg * @compile -processor GetTypeElemBadArg -proc:only GetTypeElemBadArg.java */ @@ -37,16 +38,7 @@ import javax.lang.model.element.*; import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class GetTypeElemBadArg extends AbstractProcessor { - - Elements elements; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - } - +public class GetTypeElemBadArg extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; @@ -63,12 +55,6 @@ public class GetTypeElemBadArg extends AbstractProcessor { return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private static void tellAbout(TypeElement t) { System.out.println(t); System.out.println(t.getClass()); diff --git a/test/tools/javac/processing/model/util/NoSupers.java b/test/tools/javac/processing/model/util/NoSupers.java index 64671cc5faea609291d2f474388ead20f6c13e84..9967b405580e6778ea79906790b7905414103ada 100644 --- a/test/tools/javac/processing/model/util/NoSupers.java +++ b/test/tools/javac/processing/model/util/NoSupers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6346453 * @summary directSupertypes should return empty list if arg has no supertypes * @author Scott Seligman - * @build NoSupers + * @library ../../../lib + * @build JavacTestingAbstractProcessor NoSupers * @compile -processor NoSupers -proc:only NoSupers.java */ @@ -36,16 +37,7 @@ import javax.lang.model.element.*; import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class NoSupers extends AbstractProcessor { - - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - types = penv.getTypeUtils(); - } - +public class NoSupers extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; diff --git a/test/tools/javac/processing/model/util/OverridesSpecEx.java b/test/tools/javac/processing/model/util/OverridesSpecEx.java index e6c7916dbeba041fb5244e7b1acdbd737c00b559..887c6776fb784718a44fb17adbdc37d236520c6d 100644 --- a/test/tools/javac/processing/model/util/OverridesSpecEx.java +++ b/test/tools/javac/processing/model/util/OverridesSpecEx.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6453386 * @summary Verify that example code in Elements.overrides works as spec'ed. * @author Scott Seligman + * @library ../../../lib + * @build JavacTestingAbstractProcessor * @compile -g OverridesSpecEx.java * @compile -processor OverridesSpecEx -proc:only OverridesSpecEx.java */ @@ -39,19 +41,7 @@ import javax.lang.model.util.*; import static javax.lang.model.util.ElementFilter.*; - -@SupportedAnnotationTypes("*") -public class OverridesSpecEx extends AbstractProcessor { - - Elements elements; - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - elements = penv.getElementUtils(); - types = penv.getTypeUtils(); - } - +public class OverridesSpecEx extends JavacTestingAbstractProcessor { public boolean process(Set annoTypes, RoundEnvironment round) { if (!round.processingOver()) @@ -59,11 +49,6 @@ public class OverridesSpecEx extends AbstractProcessor { return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private void doit(Set annoTypes, RoundEnvironment round) { TypeElement string = elements.getTypeElement("java.lang.String"); @@ -113,9 +98,7 @@ public class OverridesSpecEx extends AbstractProcessor { throw new AssertionError("Bogus result"); } - // Fodder for the processor - class A { public void m() {} } diff --git a/test/tools/javac/processing/model/util/TypesBadArg.java b/test/tools/javac/processing/model/util/TypesBadArg.java index 8f13c8f7d6873a21a7adac6a84242a0c19a28ed8..6eadb5759a71a26ce3d2459913080082771d4c99 100644 --- a/test/tools/javac/processing/model/util/TypesBadArg.java +++ b/test/tools/javac/processing/model/util/TypesBadArg.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6345812 * @summary Validate argument kinds in Types utilities * @author Scott Seligman - * @build TypesBadArg + * @library ../../../lib + * @build JavacTestingAbstractProcessor TypesBadArg * @compile -processor TypesBadArg -proc:only TypesBadArg.java */ @@ -36,15 +37,9 @@ import javax.lang.model.element.*; import javax.lang.model.type.*; import javax.lang.model.util.*; -@SupportedAnnotationTypes("*") -public class TypesBadArg extends AbstractProcessor { - +public class TypesBadArg extends JavacTestingAbstractProcessor { boolean success = true; - public void init(ProcessingEnvironment penv) { - super.init(penv); - } - public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; diff --git a/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java b/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java index a7ff90ba060a12baebc5bbf4f30488b87477a8bf..ce9b2cdf92c13712a4ccc735d63f8f5a2eafa97c 100644 --- a/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java +++ b/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6392818 * @summary Tests Elements.isDeprecated(Element) * @author Joseph D. Darcy + * @library ../../../../lib + * @build JavacTestingAbstractProcessor * @compile TestDeprecation.java * @compile -processor TestDeprecation -proc:only Dep1.java * @compile Dep1.java @@ -47,8 +49,7 @@ import java.io.Writer; * getElementsAnnotatedWith is consistent with the expected results * stored in an AnnotatedElementInfo annotation. */ -@SupportedAnnotationTypes("*") -public class TestDeprecation extends AbstractProcessor { +public class TestDeprecation extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { @@ -98,9 +99,4 @@ public class TestDeprecation extends AbstractProcessor { return failure; } } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } } diff --git a/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java index b74a5dc0af80d4d9fad9bc447ed67ab6357d1261..db44b5647478e8f2ac3e160573924c5879ea7de0 100644 --- a/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java +++ b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6346973 * @summary directSupertypes(t) should not return t * @author Scott Seligman - * @build DirectSupersOfErr + * @library ../../../../lib + * @build JavacTestingAbstractProcessor DirectSupersOfErr * @compile -processor DirectSupersOfErr -proc:only C1.java */ @@ -37,16 +38,7 @@ import javax.lang.model.type.*; import javax.lang.model.util.*; import static javax.lang.model.util.ElementFilter.*; -@SupportedAnnotationTypes("*") -public class DirectSupersOfErr extends AbstractProcessor { - - Types types; - - public void init(ProcessingEnvironment penv) { - super.init(penv); - types = penv.getTypeUtils(); - } - +public class DirectSupersOfErr extends JavacTestingAbstractProcessor { public boolean process(Set tes, RoundEnvironment round) { if (round.processingOver()) return true; diff --git a/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java b/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java index 17543c6ee9a550f4bd35f1a0524d434d8f7a9a2d..355b7d93bc850c6b8973f4dea1269cd8745dc8e9 100644 --- a/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java +++ b/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6471577 6517779 * @summary Test Elements.getConstantExpression * @author Joseph D. Darcy - * @build TestGetConstantExpression + * @library ../../../../lib + * @build JavacTestingAbstractProcessor TestGetConstantExpression * @compile -processor TestGetConstantExpression Foo.java */ @@ -44,10 +45,7 @@ import java.io.*; /** * Test basic workings of Elements.getConstantExpression. */ -@SupportedAnnotationTypes("*") -public class TestGetConstantExpression extends AbstractProcessor { - private Elements eltUtils; - private Filer filer; +public class TestGetConstantExpression extends JavacTestingAbstractProcessor { private int round = 1; /** @@ -130,14 +128,4 @@ public class TestGetConstantExpression extends AbstractProcessor { return 0; } } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - eltUtils = processingEnv.getElementUtils(); - filer = processingEnv.getFiler(); - } } diff --git a/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java b/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java index 08e4702104d6d555c8a6e2b0f2b48fe6f9f1d51c..6fbc24f0cf88832e287ce07b2c4f6dd0bf25dee0 100644 --- a/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java +++ b/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ * @bug 6453386 * @summary Test Elements.getPackageOf * @author Joseph D. Darcy - * @build TestGetPackageOf + * @library ../../../../lib + * @build JavacTestingAbstractProcessor TestGetPackageOf * @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java */ @@ -43,10 +44,7 @@ import static javax.tools.StandardLocation.*; /** * Test basic workings of Elements.getPackageOf */ -@SupportedAnnotationTypes("*") -public class TestGetPackageOf extends AbstractProcessor { - private Elements eltUtils; - +public class TestGetPackageOf extends JavacTestingAbstractProcessor { /** * Check expected behavior on classes and packages. */ @@ -69,13 +67,4 @@ public class TestGetPackageOf extends AbstractProcessor { } return true; } - - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - - public void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - eltUtils = processingEnv.getElementUtils(); - } } diff --git a/test/tools/javac/processing/model/util/filter/TestIterables.java b/test/tools/javac/processing/model/util/filter/TestIterables.java index 2b906b32e7516ac4d1d6c21e26822b3d02bc46c0..cbffcda752df03e9a8ea9be58893b908c6fa4262 100644 --- a/test/tools/javac/processing/model/util/filter/TestIterables.java +++ b/test/tools/javac/processing/model/util/filter/TestIterables.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,8 @@ * @bug 6406164 * @summary Test that ElementFilter iterable methods behave properly. * @author Joseph D. Darcy + * @library ../../../../lib + * @build JavacTestingAbstractProcessor * @compile TestIterables.java * @compile -processor TestIterables -proc:only Foo1.java * @compile Foo1.java @@ -51,9 +53,8 @@ import static javax.lang.model.util.ElementFilter.*; * results. */ @SupportedAnnotationTypes("ExpectedElementCounts") -@ExpectedElementCounts(methods=3) -public class TestIterables extends AbstractProcessor { - +@ExpectedElementCounts(methods=2) +public class TestIterables extends JavacTestingAbstractProcessor { public boolean process(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { @@ -118,10 +119,4 @@ public class TestIterables extends AbstractProcessor { return count1; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - } diff --git a/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java b/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java index a89d947d7b2ecdba9d5fb745ad9b980b4e1281ee..bba89985c57bc9dafa9b04f6e87edba6f0477534 100644 --- a/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java +++ b/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ import static javax.tools.Diagnostic.Kind.*; /** * This processor returns the supported source level as indicated by - * the "SourceLevel" option. + * the "SourceLevel" option; therefore, don't use + * JavacTestingAbstractProcessor which returns the latest source level. */ @SupportedAnnotationTypes("*") @SupportedOptions("SourceVersion") diff --git a/test/tools/javac/processing/werror/WError1.java b/test/tools/javac/processing/werror/WError1.java index a247b72723e370b88469ce0cfa22f4b909fb5078..08cbe7383d7ca8fa5ecd95a816ff30d53ba46ed9 100644 --- a/test/tools/javac/processing/werror/WError1.java +++ b/test/tools/javac/processing/werror/WError1.java @@ -24,6 +24,8 @@ /* * @test 6403456 * @summary -Werror should work with annotation processing + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile WError1.java * @compile -proc:only -processor WError1 WError1.java * @compile/fail/ref=WError1.out -XDrawDiagnostics -Werror -proc:only -processor WError1 WError1.java @@ -36,22 +38,15 @@ import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class WError1 extends AbstractProcessor { +public class WError1 extends JavacTestingAbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - Messager messager = processingEnv.getMessager(); if (++round == 1) { messager.printMessage(Diagnostic.Kind.WARNING, "round 1"); } return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - int round = 0; } diff --git a/test/tools/javac/processing/werror/WErrorGen.java b/test/tools/javac/processing/werror/WErrorGen.java index 3c622f009f76df8d598c925a826a5a88793609dc..383ee791af9b1d69741ebf039d3588a0357c2211 100644 --- a/test/tools/javac/processing/werror/WErrorGen.java +++ b/test/tools/javac/processing/werror/WErrorGen.java @@ -24,6 +24,8 @@ /* * @test 6403456 * @summary -Werror should work with annotation processing + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile WErrorGen.java * @compile -proc:only -processor WErrorGen WErrorGen.java * @compile/fail/ref=WErrorGen.out -XDrawDiagnostics -Werror -Xlint:rawtypes -processor WErrorGen WErrorGen.java @@ -36,12 +38,10 @@ import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class WErrorGen extends AbstractProcessor { +public class WErrorGen extends JavacTestingAbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - Filer filer = processingEnv.getFiler(); if (++round == 1) { try { JavaFileObject fo = filer.createSourceFile("Gen"); @@ -54,10 +54,5 @@ public class WErrorGen extends AbstractProcessor { return true; } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - int round = 0; } diff --git a/test/tools/javac/processing/werror/WErrorLast.java b/test/tools/javac/processing/werror/WErrorLast.java index e2ba67f5c9e07414103135d494c91fc480afd23a..33578c84846608e5600225b282341311beb56819 100644 --- a/test/tools/javac/processing/werror/WErrorLast.java +++ b/test/tools/javac/processing/werror/WErrorLast.java @@ -24,6 +24,8 @@ /* * @test 6403456 * @summary -Werror should work with annotation processing + * @library ../../lib + * @build JavacTestingAbstractProcessor * @compile WErrorLast.java * @compile -proc:only -processor WErrorLast WErrorLast.java * @compile/fail/ref=WErrorLast.out -XDrawDiagnostics -Werror -proc:only -processor WErrorLast WErrorLast.java @@ -36,20 +38,13 @@ import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; -@SupportedAnnotationTypes("*") -public class WErrorLast extends AbstractProcessor { +public class WErrorLast extends JavacTestingAbstractProcessor { @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { - Messager messager = processingEnv.getMessager(); if (roundEnv.processingOver()) { messager.printMessage(Diagnostic.Kind.WARNING, "last round"); } return true; } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } }