提交 2e08419d 编写于 作者: D darcy

6983738: Use a JavacTestingAbstractProcessor

Reviewed-by: jjg
上级 73c315be
/*
* 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<String> allAnnotations;
static {
Set<String> 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<String, String> 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<String> 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();
}
}
/*
* 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<? extends TypeElement> 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();
}
}
/*
* 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<String> 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);
......
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
return true;
......
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver())
processingEnv.getMessager().printMessage(NOTE,
"Hello from ProcBar");
messager.printMessage(NOTE, "Hello from ProcBar");
return false;
}
}
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver())
processingEnv.getMessager().printMessage(NOTE,
"Hello from ProcFoo");
messager.printMessage(NOTE, "Hello from ProcFoo");
return false;
}
}
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver())
processingEnv.getMessager().printMessage(NOTE,
"Hello from T6365040");
messager.printMessage(NOTE, "Hello from T6365040");
return true;
}
}
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
Elements elements = processingEnv.getElementUtils();
Filer filer = processingEnv.getFiler();
TypeElement testMe = elements.getTypeElement(TestMe.class.getName());
Set<? extends Element> supers = roundEnvironment.getElementsAnnotatedWith(testMe);
try {
......
/*
* 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<? extends TypeElement> 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() {}
}
/*
* 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();
......
/*
* 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);
......
/*
* 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<? extends TypeElement> 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<? extends Element> 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();
}
}
......@@ -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<? extends TypeElement> 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);
}
}
......
......@@ -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<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
return true;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
......@@ -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
*/
......
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
return(false);
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
return false;
}
}
......@@ -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<? extends TypeElement> 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();
}
}
......
/*
* 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<? extends JavaFileObject> files =
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java")));
Iterable<String> opts = Arrays.asList("-source","1.6",
"-proc:only",
Iterable<String> opts = Arrays.asList("-proc:only",
"-processor", "T6439826",
"-processorpath", testClasses);
StringWriter out = new StringWriter();
......
......@@ -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<? extends TypeElement> annots, RoundEnvironment renv) {
round++;
System.err.println("Round " + round + " annots:" + annots + " rootElems:" + renv.getRootElements());
......
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
......@@ -68,9 +69,4 @@ public class TestSourceVersion extends AbstractProcessor {
return true;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
Elements elementUtils = processingEnv.getElementUtils();
TypeElement annotatedElementInfoElement =
elementUtils.getTypeElement("AnnotatedElementInfo");
elements.getTypeElement("AnnotatedElementInfo");
Set<? extends Element> resultsMeta = Collections.emptySet();
Set<? extends Element> 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();
}
}
/*
* 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<? extends TypeElement> 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();
}
}
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) {
return true;
}
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
/*
* 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<? extends TypeElement> 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();
}
}
/*
* 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;
*
* </ul>
*/
@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.
......
/*
* 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<String,String> 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();
}
}
/*
* 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<? extends TypeElement> 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 {
......
......@@ -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<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
for (String relative: invalidRelativeNames) {
......
......@@ -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<? extends TypeElement> 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();
}
}
/*
* 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<String,String> options;
public class TestPackageInfo extends JavacTestingAbstractProcessor {
private int round = 0;
public boolean process(Set<? extends TypeElement> annotations,
......@@ -64,11 +60,7 @@ public class TestPackageInfo extends AbstractProcessor {
// Verify annotations are as expected
Set<TypeElement> expectedAnnotations = new HashSet<TypeElement>();
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();
}
}
......@@ -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<? extends TypeElement> 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();
}
}
/*
* 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<? extends TypeElement> 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;
......
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment)
{
final Messager log = processingEnv.getMessager();
final Elements elements = processingEnv.getElementUtils();
class Scan extends ElementScanner7<Void,Void> {
@Override
public Void visitExecutable(ExecutableElement e, Void ignored) {
......
/*
* 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<? extends TypeElement> 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());
......
......@@ -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();
}
}
......@@ -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<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
......@@ -84,9 +83,4 @@ public class TestAnonSourceNames extends AbstractProcessor {
return super.visitClass(node, cu);
}
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
/*
* 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
* "<init>".
......@@ -66,9 +66,4 @@ public class TestElement extends AbstractProcessor {
}
return true;
}
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
/*
* 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;
......
/*
* 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<? extends TypeElement> 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();
}
}
......@@ -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<? extends TypeElement> 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();
}
}
......@@ -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<? extends TypeElement> annotations,
......@@ -105,9 +105,4 @@ public class TestResourceVariable extends AbstractProcessor implements AutoClose
return super.visitVariable(node, cu);
}
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
/*
* 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<? extends TypeElement> 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<? extends TypeElement> 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<T, U extends Object, V extends Number, W extends U,
X extends Runnable, Y extends CharSequence & Runnable,
Z extends Object & Runnable> {
......
/*
* 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<? extends TypeElement> 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<? extends TypeElement> annoTypes,
RoundEnvironment round) {
for (TypeElement t : typesIn(round.getRootElements())) {
......
......@@ -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<? extends TypeElement> 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)
......
/*
* 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<? extends TypeElement> 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<? extends TypeElement> annoTypes,
RoundEnvironment round) {
......
/*
* 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<? extends TypeElement> tes,
RoundEnvironment round) {
if (round.processingOver()) return true;
......
/*
* 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<? extends TypeElement> 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());
......
/*
* 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<? extends TypeElement> tes,
RoundEnvironment round) {
if (round.processingOver()) return true;
......
/*
* 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<? extends TypeElement> 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<? extends TypeElement> 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() {}
}
......
/*
* 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<? extends TypeElement> tes,
RoundEnvironment round) {
if (round.processingOver()) return true;
......
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
......@@ -98,9 +99,4 @@ public class TestDeprecation extends AbstractProcessor {
return failure;
}
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
/*
* 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<? extends TypeElement> tes,
RoundEnvironment round) {
if (round.processingOver()) return true;
......
/*
* 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();
}
}
/*
* 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();
}
}
/*
* 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<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
......@@ -118,10 +119,4 @@ public class TestIterables extends AbstractProcessor {
return count1;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
/*
* 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")
......
......@@ -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<? extends TypeElement> 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;
}
......@@ -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<? extends TypeElement> 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;
}
......@@ -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<? extends TypeElement> 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();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册