提交 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -27,10 +27,8 @@ import javax.annotation.processing.*; ...@@ -27,10 +27,8 @@ import javax.annotation.processing.*;
import javax.lang.model.*; import javax.lang.model.*;
import javax.lang.model.element.*; import javax.lang.model.element.*;
@SupportedAnnotationTypes("*") public class A extends JavacTestingAbstractProcessor {
public class A extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) { public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
Filer filer = processingEnv.getFiler();
try { try {
OutputStream out = filer.createClassFile(getClass().getName()+"_0").openOutputStream(); OutputStream out = filer.createClassFile(getClass().getName()+"_0").openOutputStream();
out.close(); out.close();
...@@ -39,8 +37,4 @@ public class A extends AbstractProcessor { ...@@ -39,8 +37,4 @@ public class A extends AbstractProcessor {
} }
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
* @test * @test
* @bug 6441871 * @bug 6441871
* @summary javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile * @summary javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile
* @build A * @library ../../lib
* @build JavacTestingAbstractProcessor A
* @run main T6348499 * @run main T6348499
*/ */
...@@ -54,7 +55,6 @@ public class T6348499 { ...@@ -54,7 +55,6 @@ public class T6348499 {
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java"))); fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
Iterable<String> opts = Arrays.asList("-proc:only", Iterable<String> opts = Arrays.asList("-proc:only",
"-processor", "A", "-processor", "A",
"-source", "1.6",
"-processorpath", testClasses); "-processorpath", testClasses);
StringWriter out = new StringWriter(); StringWriter out = new StringWriter();
JavacTask task = tool.getTask(out, fm, dl, opts, null, files); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6359313 * @bug 6359313
* @summary error compiling annotated package * @summary error compiling annotated package
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile T6359313.java * @compile T6359313.java
* @compile -processor T6359313 package-info.java Foo.java * @compile -processor T6359313 package-info.java Foo.java
*/ */
...@@ -37,7 +39,7 @@ import javax.annotation.processing.SupportedAnnotationTypes; ...@@ -37,7 +39,7 @@ import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
@SupportedAnnotationTypes("Foo") @SupportedAnnotationTypes("Foo")
public class T6359313 extends AbstractProcessor { public class T6359313 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,13 +31,11 @@ import static javax.tools.Diagnostic.Kind.*; ...@@ -31,13 +31,11 @@ import static javax.tools.Diagnostic.Kind.*;
/** /**
* Second of several processors to run. * Second of several processors to run.
*/ */
@SupportedAnnotationTypes("*") public class ProcBar extends JavacTestingAbstractProcessor {
public class ProcBar extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver()) if (!roundEnvironment.processingOver())
processingEnv.getMessager().printMessage(NOTE, messager.printMessage(NOTE, "Hello from ProcBar");
"Hello from ProcBar");
return false; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,13 +31,11 @@ import static javax.tools.Diagnostic.Kind.*; ...@@ -31,13 +31,11 @@ import static javax.tools.Diagnostic.Kind.*;
/** /**
* First of several processors to run. * First of several processors to run.
*/ */
@SupportedAnnotationTypes("*") public class ProcFoo extends JavacTestingAbstractProcessor {
public class ProcFoo extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver()) if (!roundEnvironment.processingOver())
processingEnv.getMessager().printMessage(NOTE, messager.printMessage(NOTE, "Hello from ProcFoo");
"Hello from ProcFoo");
return false; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6365040 6358129 * @bug 6365040 6358129
* @summary Test -processor foo,bar,baz * @summary Test -processor foo,bar,baz
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile ProcFoo.java * @compile ProcFoo.java
* @compile ProcBar.java * @compile ProcBar.java
* @compile T6365040.java * @compile T6365040.java
...@@ -43,13 +45,11 @@ import javax.annotation.processing.SupportedAnnotationTypes; ...@@ -43,13 +45,11 @@ import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import static javax.tools.Diagnostic.Kind.*; import static javax.tools.Diagnostic.Kind.*;
@SupportedAnnotationTypes("*") public class T6365040 extends JavacTestingAbstractProcessor {
public class T6365040 extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver()) if (!roundEnvironment.processingOver())
processingEnv.getMessager().printMessage(NOTE, messager.printMessage(NOTE, "Hello from T6365040");
"Hello from T6365040");
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6413690 6380018 * @bug 6413690 6380018
* @summary JavacProcessingEnvironment does not enter trees from preceding rounds * @summary JavacProcessingEnvironment does not enter trees from preceding rounds
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile T6413690.java * @compile T6413690.java
* @compile -XDfatalEnterError -verbose -processor T6413690 src/Super.java TestMe.java * @compile -XDfatalEnterError -verbose -processor T6413690 src/Super.java TestMe.java
*/ */
...@@ -42,11 +44,9 @@ import javax.lang.model.element.TypeElement; ...@@ -42,11 +44,9 @@ import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements; import javax.lang.model.util.Elements;
@SupportedAnnotationTypes("TestMe") @SupportedAnnotationTypes("TestMe")
public class T6413690 extends AbstractProcessor { public class T6413690 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
Elements elements = processingEnv.getElementUtils();
Filer filer = processingEnv.getFiler();
TypeElement testMe = elements.getTypeElement(TestMe.class.getName()); TypeElement testMe = elements.getTypeElement(TestMe.class.getName());
Set<? extends Element> supers = roundEnvironment.getElementsAnnotatedWith(testMe); Set<? extends Element> supers = roundEnvironment.getElementsAnnotatedWith(testMe);
try { 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -29,9 +29,8 @@ import javax.lang.model.*; ...@@ -29,9 +29,8 @@ import javax.lang.model.*;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.tools.*; import javax.tools.*;
@SupportedAnnotationTypes("*") @SuppressWarnings("")
public class A extends AbstractProcessor { public class A extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
Messager m = processingEnv.getMessager(); Messager m = processingEnv.getMessager();
for (TypeElement anno: annotations) { for (TypeElement anno: annotations) {
...@@ -42,8 +41,6 @@ public class A extends AbstractProcessor { ...@@ -42,8 +41,6 @@ public class A extends AbstractProcessor {
return true; return true;
} }
@Override @SuppressWarnings("")
public SourceVersion getSupportedSourceVersion() { private void foo() {}
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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
* @test * @test
* @bug 6414633 6440109 * @bug 6414633 6440109
* @summary Only the first processor message at a source location is reported * @summary Only the first processor message at a source location is reported
* @build A T6414633 * @library ../../lib
* @build JavacTestingAbstractProcessor A T6414633
* @run main T6414633 * @run main T6414633
*/ */
...@@ -55,8 +56,7 @@ public class T6414633 { ...@@ -55,8 +56,7 @@ public class T6414633 {
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java"))); fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java")));
String[] opts = { "-proc:only", String[] opts = { "-proc:only",
"-processor", A.class.getName(), "-processor", A.class.getName(),
"-source", "1.6", "-classpath", testClasses + System.getProperty("path.separator") + "../../lib" };
"-classpath", testClasses };
JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files); JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files);
task.call(); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
* @test * @test
* @bug 6441871 * @bug 6441871
* @summary spurious compiler error elicited by packageElement.getEnclosedElements() * @summary spurious compiler error elicited by packageElement.getEnclosedElements()
* @build b6341534 * @library ../../lib
* @build JavacTestingAbstractProcessor b6341534
* @run main T6430209 * @run main T6430209
*/ */
...@@ -54,7 +55,7 @@ public class T6430209 { ...@@ -54,7 +55,7 @@ public class T6430209 {
// run annotation processor b6341534 so we can check diagnostics // run annotation processor b6341534 so we can check diagnostics
// -proc:only -processor b6341534 -cp . ./src/*.java // -proc:only -processor b6341534 -cp . ./src/*.java
String testSrc = System.getProperty("test.src", "."); 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(); JavacTool tool = JavacTool.create();
MyDiagListener dl = new MyDiagListener(); MyDiagListener dl = new MyDiagListener();
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -30,16 +30,9 @@ import static javax.tools.Diagnostic.Kind.*; ...@@ -30,16 +30,9 @@ import static javax.tools.Diagnostic.Kind.*;
import java.util.*; import java.util.*;
import java.util.Set; import java.util.Set;
@SupportedAnnotationTypes({"*"}) public class b6341534 extends JavacTestingAbstractProcessor {
public class b6341534 extends AbstractProcessor {
static int r = 0; 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 //Create directory 'dir1' and a test class in dir1
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv)
{ {
...@@ -49,13 +42,13 @@ public class b6341534 extends AbstractProcessor { ...@@ -49,13 +42,13 @@ public class b6341534 extends AbstractProcessor {
System.out.println("Round"+r+ ": " + t.toString()); System.out.println("Round"+r+ ": " + t.toString());
try { try {
PackageElement PE = E.getPackageElement("dir1"); PackageElement PE = eltUtils.getPackageElement("dir1");
List<? extends Element> LEE = PE.getEnclosedElements(); /* <=This line elicits the error message. */ List<? extends Element> LEE = PE.getEnclosedElements(); /* <=This line elicits the error message. */
for(Element e : LEE) for(Element e : LEE)
System.out.println("found " + e.toString() + " in dir1."); System.out.println("found " + e.toString() + " in dir1.");
} }
catch(NullPointerException npe) { catch(NullPointerException npe) {
msgr.printMessage(ERROR,npe.toString()); messager.printMessage(ERROR,npe.toString());
//npe.printStackTrace(); //npe.printStackTrace();
return false; return false;
} }
...@@ -63,13 +56,8 @@ public class b6341534 extends AbstractProcessor { ...@@ -63,13 +56,8 @@ public class b6341534 extends AbstractProcessor {
// on round 1, expect errorRaised == false && processingOver == false // on round 1, expect errorRaised == false && processingOver == false
// on round 2, expect errorRaised == true && processingOver == true // on round 2, expect errorRaised == true && processingOver == true
if( renv.errorRaised() != renv.processingOver()) { if( renv.errorRaised() != renv.processingOver()) {
msgr.printMessage(ERROR, "FAILED"); messager.printMessage(ERROR, "FAILED");
} }
return true; return true;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
} }
...@@ -32,20 +32,17 @@ import javax.tools.Diagnostic.Kind; ...@@ -32,20 +32,17 @@ import javax.tools.Diagnostic.Kind;
* @test * @test
* @bug 6499119 * @bug 6499119
* @summary Created package-info class file modeled improperly * @summary Created package-info class file modeled improperly
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile ClassProcessor.java package-info.java * @compile ClassProcessor.java package-info.java
* @compile/process -cp . -processor ClassProcessor -Akind=java java.lang.Object * @compile/process -cp . -processor ClassProcessor -Akind=java java.lang.Object
* @compile/process -cp . -processor ClassProcessor -Akind=class java.lang.Object * @compile/process -cp . -processor ClassProcessor -Akind=class java.lang.Object
*/ */
@SupportedOptions({ "gen", "expect" }) @SupportedOptions({ "gen", "expect" })
@SupportedAnnotationTypes({"*"}) public class ClassProcessor extends JavacTestingAbstractProcessor {
public class ClassProcessor extends AbstractProcessor {
int round = 1; int round = 1;
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (round == 1) { if (round == 1) {
System.out.println("-- Round 1 --"); System.out.println("-- Round 1 --");
...@@ -71,8 +68,6 @@ public class ClassProcessor extends AbstractProcessor { ...@@ -71,8 +68,6 @@ public class ClassProcessor extends AbstractProcessor {
} }
private void createPackageFile() { private void createPackageFile() {
Filer filer = processingEnv.getFiler();
String kind = processingEnv.getOptions().get("kind"); String kind = processingEnv.getOptions().get("kind");
File pkgInfo; File pkgInfo;
...@@ -125,7 +120,6 @@ public class ClassProcessor extends AbstractProcessor { ...@@ -125,7 +120,6 @@ public class ClassProcessor extends AbstractProcessor {
} }
private void error(String msg) { private void error(String msg) {
Messager messager = processingEnv.getMessager();
messager.printMessage(Kind.ERROR, msg); messager.printMessage(Kind.ERROR, msg);
} }
} }
......
...@@ -26,15 +26,10 @@ import javax.lang.model.*; ...@@ -26,15 +26,10 @@ import javax.lang.model.*;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import java.util.Set; import java.util.Set;
@SupportedAnnotationTypes("*") public class DummyProcessor extends JavacTestingAbstractProcessor {
public class DummyProcessor extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
return true; return true;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
} }
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6511613 * @bug 6511613
* @summary javac unexpectedly doesn't fail in some cases if an annotation processor specified * @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 clss41701.java
* @compile/fail -processor DummyProcessor 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,8 +26,9 @@ ...@@ -26,8 +26,9 @@
* @bug 6512707 * @bug 6512707
* @summary "incompatible types" after (unrelated) annotation processing * @summary "incompatible types" after (unrelated) annotation processing
* @author Peter Runge * @author Peter Runge
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile T6512707.java * @compile T6512707.java
*
* @compile -processor T6512707 TestAnnotation.java * @compile -processor T6512707 TestAnnotation.java
*/ */
...@@ -41,16 +42,10 @@ import javax.lang.model.util.*; ...@@ -41,16 +42,10 @@ import javax.lang.model.util.*;
* Dummy processor to force bug 6512707 to show - it does not matter what * Dummy processor to force bug 6512707 to show - it does not matter what
* the annotation processor does for this bug. * the annotation processor does for this bug.
*/ */
@SupportedAnnotationTypes("*") public class T6512707 extends JavacTestingAbstractProcessor {
public class T6512707 extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
return(false); return false;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
} }
} }
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6634138 * @bug 6634138
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @summary Verify source files output after processing is over are compiled * @summary Verify source files output after processing is over are compiled
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile T6634138.java * @compile T6634138.java
* @compile -processor T6634138 Dummy.java * @compile -processor T6634138 Dummy.java
* @run main ExerciseDependency * @run main ExerciseDependency
...@@ -44,10 +46,7 @@ import javax.lang.model.SourceVersion; ...@@ -44,10 +46,7 @@ import javax.lang.model.SourceVersion;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.lang.model.util.*; import javax.lang.model.util.*;
@SupportedAnnotationTypes("*") public class T6634138 extends JavacTestingAbstractProcessor {
public class T6634138 extends AbstractProcessor {
private Filer filer;
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
// Write out files *after* processing is over. // Write out files *after* processing is over.
...@@ -77,16 +76,6 @@ public class T6634138 extends AbstractProcessor { ...@@ -77,16 +76,6 @@ public class T6634138 extends AbstractProcessor {
} }
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -48,8 +48,7 @@ public class T6439826 extends AbstractProcessor { ...@@ -48,8 +48,7 @@ public class T6439826 extends AbstractProcessor {
StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null); StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
Iterable<? extends JavaFileObject> files = Iterable<? extends JavaFileObject> files =
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java"))); fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java")));
Iterable<String> opts = Arrays.asList("-source","1.6", Iterable<String> opts = Arrays.asList("-proc:only",
"-proc:only",
"-processor", "T6439826", "-processor", "T6439826",
"-processorpath", testClasses); "-processorpath", testClasses);
StringWriter out = new StringWriter(); StringWriter out = new StringWriter();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* @test * @test
* @bug 6920317 * @bug 6920317
* @summary package-info.java file has to be specified on the javac cmdline, else it will not be avail * @summary package-info.java file has to be specified on the javac cmdline, else it will not be avail
* @library ../lib
*/ */
import java.io.*; import java.io.*;
...@@ -349,12 +350,7 @@ public class T6920317 { ...@@ -349,12 +350,7 @@ public class T6920317 {
/** Annotation processor used to verify the expected value for the /** Annotation processor used to verify the expected value for the
package annotations found by javac. */ package annotations found by javac. */
@SupportedOptions({ "gen", "expect" }) @SupportedOptions({ "gen", "expect" })
@SupportedAnnotationTypes({"*"}) public static class Processor extends JavacTestingAbstractProcessor {
public static class Processor extends AbstractProcessor {
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
public boolean process(Set<? extends TypeElement> annots, RoundEnvironment renv) { public boolean process(Set<? extends TypeElement> annots, RoundEnvironment renv) {
round++; round++;
System.err.println("Round " + round + " annots:" + annots + " rootElems:" + renv.getRootElements()); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6402506 * @bug 6402506
* @summary Test that getSourceVersion works properly * @summary Test that getSourceVersion works properly
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile TestSourceVersion.java * @compile TestSourceVersion.java
* @compile -processor TestSourceVersion -proc:only -source 1.2 -AExpectedVersion=RELEASE_2 HelloWorld.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 * @compile -processor TestSourceVersion -proc:only -source 1.3 -AExpectedVersion=RELEASE_3 HelloWorld.java
...@@ -52,9 +54,8 @@ import static javax.tools.Diagnostic.Kind.*; ...@@ -52,9 +54,8 @@ import static javax.tools.Diagnostic.Kind.*;
* This processor checks that ProcessingEnvironment.getSourceVersion() * This processor checks that ProcessingEnvironment.getSourceVersion()
* is consistent with the setting of the -source option. * is consistent with the setting of the -source option.
*/ */
@SupportedAnnotationTypes("*")
@SupportedOptions("ExpectedVersion") @SupportedOptions("ExpectedVersion")
public class TestSourceVersion extends AbstractProcessor { public class TestSourceVersion extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
...@@ -68,9 +69,4 @@ public class TestSourceVersion extends AbstractProcessor { ...@@ -68,9 +69,4 @@ public class TestSourceVersion extends AbstractProcessor {
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854 * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854
* @summary Tests that getElementsAnnotatedWith works properly. * @summary Tests that getElementsAnnotatedWith works properly.
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../../lib
* @build JavacTestingAbstractProcessor
* @compile TestElementsAnnotatedWith.java * @compile TestElementsAnnotatedWith.java
* @compile InheritedAnnotation.java * @compile InheritedAnnotation.java
* @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
...@@ -57,16 +59,13 @@ import static javax.lang.model.util.ElementFilter.*; ...@@ -57,16 +59,13 @@ import static javax.lang.model.util.ElementFilter.*;
* getElementsAnnotatedWith is consistent with the expected results * getElementsAnnotatedWith is consistent with the expected results
* stored in an AnnotatedElementInfo annotation. * stored in an AnnotatedElementInfo annotation.
*/ */
@SupportedAnnotationTypes("*")
@AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", expectedSize=0, names={}) @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, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
Elements elementUtils = processingEnv.getElementUtils();
TypeElement annotatedElementInfoElement = TypeElement annotatedElementInfoElement =
elementUtils.getTypeElement("AnnotatedElementInfo"); elements.getTypeElement("AnnotatedElementInfo");
Set<? extends Element> resultsMeta = Collections.emptySet(); Set<? extends Element> resultsMeta = Collections.emptySet();
Set<? extends Element> resultsBase = Collections.emptySet(); Set<? extends Element> resultsBase = Collections.emptySet();
...@@ -93,9 +92,7 @@ public class TestElementsAnnotatedWith extends AbstractProcessor { ...@@ -93,9 +92,7 @@ public class TestElementsAnnotatedWith extends AbstractProcessor {
resultsMeta = resultsMeta =
roundEnvironment. roundEnvironment.
getElementsAnnotatedWith(elementUtils. getElementsAnnotatedWith(elements.getTypeElement(annotatedElementInfo.annotationName()));
getTypeElement(annotatedElementInfo.
annotationName())) ;
System.err.println("Results: " + resultsMeta); System.err.println("Results: " + resultsMeta);
...@@ -167,9 +164,4 @@ public class TestElementsAnnotatedWith extends AbstractProcessor { ...@@ -167,9 +164,4 @@ public class TestElementsAnnotatedWith extends AbstractProcessor {
throw new RuntimeException("Illegal argument exception not thrown"); throw new RuntimeException("Illegal argument exception not thrown");
} catch(IllegalArgumentException iae) {} } 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
* @bug 6403459 * @bug 6403459
* @summary Test that generating programs with syntax errors is a fatal condition * @summary Test that generating programs with syntax errors is a fatal condition
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile TestReturnCode.java
* @compile TestFatalityOfParseErrors.java * @compile TestFatalityOfParseErrors.java
* @compile/fail -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java * @compile/fail -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java
*/ */
...@@ -45,11 +48,8 @@ import java.io.IOException; ...@@ -45,11 +48,8 @@ import java.io.IOException;
* Write out an incomplete source file and observe that the next round * Write out an incomplete source file and observe that the next round
* is marked as an error. * is marked as an error.
*/ */
@SupportedAnnotationTypes("*") public class TestFatalityOfParseErrors extends JavacTestingAbstractProcessor {
public class TestFatalityOfParseErrors extends AbstractProcessor {
int round = 0; int round = 0;
Messager messager;
Filer filer;
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
...@@ -87,14 +87,4 @@ public class TestFatalityOfParseErrors extends AbstractProcessor { ...@@ -87,14 +87,4 @@ public class TestFatalityOfParseErrors extends AbstractProcessor {
} }
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6406212 * @bug 6406212
* @summary Test that annotation processor options with illegal syntax are rejected * @summary Test that annotation processor options with illegal syntax are rejected
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile TestOptionSyntaxErrors.java * @compile TestOptionSyntaxErrors.java
* @compile/fail -A TestOptionSyntaxErrors.java * @compile/fail -A TestOptionSyntaxErrors.java
* @compile/fail -A8adOption TestOptionSyntaxErrors.java * @compile/fail -A8adOption TestOptionSyntaxErrors.java
...@@ -46,14 +48,9 @@ import static javax.tools.Diagnostic.Kind.*; ...@@ -46,14 +48,9 @@ import static javax.tools.Diagnostic.Kind.*;
/** /**
* No-op processor; should not be run. * No-op processor; should not be run.
*/ */
@SupportedAnnotationTypes("*") public class TestOptionSyntaxErrors extends JavacTestingAbstractProcessor {
public class TestOptionSyntaxErrors extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) { RoundEnvironment roundEnvironment) {
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6403468 * @bug 6403468
* @summary Test that an erroneous return code results from raising an error. * @summary Test that an erroneous return code results from raising an error.
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile TestReturnCode.java * @compile TestReturnCode.java
* *
* @compile -processor TestReturnCode -proc:only Foo.java * @compile -processor TestReturnCode -proc:only Foo.java
...@@ -60,20 +62,17 @@ import static javax.tools.Diagnostic.Kind.*; ...@@ -60,20 +62,17 @@ import static javax.tools.Diagnostic.Kind.*;
* This processor raises errors or throws exceptions on different * This processor raises errors or throws exceptions on different
* rounds to allow the return code to be test. * rounds to allow the return code to be test.
*/ */
@SupportedAnnotationTypes("*")
@SupportedOptions({"ErrorOnFirst", @SupportedOptions({"ErrorOnFirst",
"ErrorOnLast", "ErrorOnLast",
"ExceptionOnFirst", "ExceptionOnFirst",
"ExceptionOnLast"}) "ExceptionOnLast"})
public class TestReturnCode extends AbstractProcessor { public class TestReturnCode extends JavacTestingAbstractProcessor {
private boolean errorOnFirst; private boolean errorOnFirst;
private boolean errorOnLast; private boolean errorOnLast;
private boolean exceptionOnFirst; private boolean exceptionOnFirst;
private boolean exceptionOnLast; private boolean exceptionOnLast;
private Messager messager;
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) { if (!roundEnv.processingOver()) {
...@@ -103,11 +102,5 @@ public class TestReturnCode extends AbstractProcessor { ...@@ -103,11 +102,5 @@ public class TestReturnCode extends AbstractProcessor {
errorOnLast = keySet.contains("ErrorOnLast"); errorOnLast = keySet.contains("ErrorOnLast");
exceptionOnFirst = keySet.contains("ExceptionOnFirst"); exceptionOnFirst = keySet.contains("ExceptionOnFirst");
exceptionOnLast = keySet.contains("ExceptionOnLast"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
* @bug 6380018 6453386 6457283 * @bug 6380018 6453386 6457283
* @summary Test that the constraints guaranteed by the Filer and maintained * @summary Test that the constraints guaranteed by the Filer and maintained
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../lib
* @build TestFilerConstraints * @build TestFilerConstraints
* @compile -encoding iso-8859-1 -processor TestFilerConstraints -proc:only TestFilerConstraints.java * @compile -encoding iso-8859-1 -processor TestFilerConstraints -proc:only TestFilerConstraints.java
*/ */
...@@ -69,11 +70,8 @@ import java.nio.charset.Charset; ...@@ -69,11 +70,8 @@ import java.nio.charset.Charset;
* *
* </ul> * </ul>
*/ */
@SupportedAnnotationTypes("*") public class TestFilerConstraints extends JavacTestingAbstractProcessor {
public class TestFilerConstraints extends AbstractProcessor {
private int round = 0; private int round = 0;
private Messager messager;
private Filer filer;
private PrintWriter pw_src1 = null; private PrintWriter pw_src1 = null;
private PrintWriter pw_src2 = null; private PrintWriter pw_src2 = null;
...@@ -167,17 +165,6 @@ public class TestFilerConstraints extends AbstractProcessor { ...@@ -167,17 +165,6 @@ public class TestFilerConstraints extends AbstractProcessor {
return true; 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 * Test that the single expected expected type, name, is the root
* element. * 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6380018 6449798 * @bug 6380018 6449798
* @summary Test Filer.getResource * @summary Test Filer.getResource
* @author Joseph D. Darcy * @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=write TestGetResource.java
* @compile -processor TestGetResource -proc:only -Aphase=read TestGetResource.java * @compile -processor TestGetResource -proc:only -Aphase=read TestGetResource.java
*/ */
...@@ -49,13 +50,8 @@ import java.io.PrintWriter; ...@@ -49,13 +50,8 @@ import java.io.PrintWriter;
* first run of the annotation processor, write out a resource file * first run of the annotation processor, write out a resource file
* and on the second run read it in. * and on the second run read it in.
*/ */
@SupportedAnnotationTypes("*")
@SupportedOptions("phase") @SupportedOptions("phase")
public class TestGetResource extends AbstractProcessor { public class TestGetResource extends JavacTestingAbstractProcessor {
private Messager messager;
private Filer filer;
private Map<String,String> options;
private static String CONTENTS = "Hello World."; private static String CONTENTS = "Hello World.";
private static String PKG = ""; private static String PKG = "";
private static String RESOURCE_NAME = "Resource1"; private static String RESOURCE_NAME = "Resource1";
...@@ -92,15 +88,4 @@ public class TestGetResource extends AbstractProcessor { ...@@ -92,15 +88,4 @@ public class TestGetResource extends AbstractProcessor {
} }
return false; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* @test /* @test
* @bug 6929404 * @bug 6929404
* @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry * @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry
* @library ../../lib
*/ */
import java.io.*; import java.io.*;
...@@ -114,8 +115,7 @@ public class TestGetResource2 { ...@@ -114,8 +115,7 @@ public class TestGetResource2 {
throw new Exception(errors + " errors occurred"); throw new Exception(errors + " errors occurred");
} }
@SupportedAnnotationTypes("*") static class AnnoProc extends JavacTestingAbstractProcessor {
static class AnnoProc extends AbstractProcessor {
public @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { public @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) { if (roundEnv.processingOver()) {
...@@ -123,27 +123,23 @@ public class TestGetResource2 { ...@@ -123,27 +123,23 @@ public class TestGetResource2 {
} }
try { try {
FileObject resource = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt"); FileObject resource = filer.getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt");
try { try {
resource.openInputStream().close(); resource.openInputStream().close();
processingEnv.getMessager().printMessage(Kind.NOTE, "found: " + resource.toUri()); messager.printMessage(Kind.NOTE, "found: " + resource.toUri());
return true; return true;
} catch (IOException x) { } catch (IOException x) {
processingEnv.getMessager().printMessage(Kind.ERROR, "could not read: " + resource.toUri()); messager.printMessage(Kind.ERROR, "could not read: " + resource.toUri());
x.printStackTrace(); x.printStackTrace();
} }
} catch (IOException x) { } catch (IOException x) {
processingEnv.getMessager().printMessage(Kind.ERROR, "did not find resource"); messager.printMessage(Kind.ERROR, "did not find resource");
x.printStackTrace(); x.printStackTrace();
} }
return false; return false;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
} }
private File write(File dir, String path, String contents) throws IOException { private File write(File dir, String path, String contents) throws IOException {
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
* @test * @test
* @bug 6502392 * @bug 6502392
* @summary Invalid relative names for Filer.createResource and Filer.getResource * @summary Invalid relative names for Filer.createResource and Filer.getResource
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile TestInvalidRelativeNames.java * @compile TestInvalidRelativeNames.java
* @compile/process -processor TestInvalidRelativeNames java.lang.Object * @compile/process -processor TestInvalidRelativeNames java.lang.Object
*/ */
...@@ -37,30 +39,13 @@ import javax.lang.model.element.*; ...@@ -37,30 +39,13 @@ import javax.lang.model.element.*;
import javax.tools.Diagnostic; import javax.tools.Diagnostic;
import javax.tools.StandardLocation; import javax.tools.StandardLocation;
public class TestInvalidRelativeNames extends JavacTestingAbstractProcessor {
@SupportedAnnotationTypes("*")
public class TestInvalidRelativeNames extends AbstractProcessor {
enum Kind { CREATE_WRITER, GET_READER, CREATE_OUTPUT_STREAM, GET_INPUT_STREAM }; enum Kind { CREATE_WRITER, GET_READER, CREATE_OUTPUT_STREAM, GET_INPUT_STREAM };
static final String[] invalidRelativeNames = { static final String[] invalidRelativeNames = {
"/boo", "goo/../hoo", "./ioo", "" "/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) { public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) { if (roundEnv.processingOver()) {
for (String relative: invalidRelativeNames) { for (String relative: invalidRelativeNames) {
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
/* /*
* @test 6966604 * @test 6966604
* @summary JavacFiler not correctly notified of lastRound * @summary JavacFiler not correctly notified of lastRound
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile TestLastRound.java * @compile TestLastRound.java
* @compile/fail/ref=TestLastRound.out -XDrawDiagnostics -Werror -proc:only -processor TestLastRound TestLastRound.java * @compile/fail/ref=TestLastRound.out -XDrawDiagnostics -Werror -proc:only -processor TestLastRound TestLastRound.java
*/ */
...@@ -35,12 +37,10 @@ import javax.lang.model.*; ...@@ -35,12 +37,10 @@ import javax.lang.model.*;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.tools.*; import javax.tools.*;
@SupportedAnnotationTypes("*") public class TestLastRound extends JavacTestingAbstractProcessor {
public class TestLastRound extends AbstractProcessor {
@Override @Override
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
Filer filer = processingEnv.getFiler();
if (roundEnv.processingOver()) { if (roundEnv.processingOver()) {
try { try {
JavaFileObject fo = filer.createSourceFile("LastRound.java"); JavaFileObject fo = filer.createSourceFile("LastRound.java");
...@@ -52,9 +52,4 @@ public class TestLastRound extends AbstractProcessor { ...@@ -52,9 +52,4 @@ public class TestLastRound extends AbstractProcessor {
} }
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6380018 6392177 * @bug 6380018 6392177
* @summary Test the ability to create and process package-info.java files * @summary Test the ability to create and process package-info.java files
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile TestPackageInfo.java * @compile TestPackageInfo.java
* @compile -processor TestPackageInfo -proc:only foo/bar/package-info.java TestPackageInfo.java * @compile -processor TestPackageInfo -proc:only foo/bar/package-info.java TestPackageInfo.java
*/ */
...@@ -49,13 +51,7 @@ import java.io.*; ...@@ -49,13 +51,7 @@ import java.io.*;
* 1) Visibility of package-info files from the command line * 1) Visibility of package-info files from the command line
* 2) Visibility of generated package-info.java source files * 2) Visibility of generated package-info.java source files
*/ */
@SupportedAnnotationTypes("*") public class TestPackageInfo extends JavacTestingAbstractProcessor {
public class TestPackageInfo extends AbstractProcessor {
private Elements eltUtils;
private Messager messager;
private Filer filer;
private Map<String,String> options;
private int round = 0; private int round = 0;
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
...@@ -64,11 +60,7 @@ public class TestPackageInfo extends AbstractProcessor { ...@@ -64,11 +60,7 @@ public class TestPackageInfo extends AbstractProcessor {
// Verify annotations are as expected // Verify annotations are as expected
Set<TypeElement> expectedAnnotations = new HashSet<TypeElement>(); Set<TypeElement> expectedAnnotations = new HashSet<TypeElement>();
if (round == 1) expectedAnnotations.add(eltUtils.getTypeElement("java.lang.SuppressWarnings"));
expectedAnnotations.add(eltUtils.
getTypeElement("javax.annotation.processing.SupportedAnnotationTypes"));
expectedAnnotations.add(eltUtils.
getTypeElement("java.lang.SuppressWarnings"));
if (!roundEnv.processingOver()) { if (!roundEnv.processingOver()) {
System.out.println("\nRound " + round); System.out.println("\nRound " + round);
...@@ -127,16 +119,4 @@ public class TestPackageInfo extends AbstractProcessor { ...@@ -127,16 +119,4 @@ public class TestPackageInfo extends AbstractProcessor {
} }
return false; 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 @@ ...@@ -2,39 +2,34 @@
* @test /nodynamiccopyright/ * @test /nodynamiccopyright/
* @bug 6362067 * @bug 6362067
* @summary Messager methods do not print out source position information * @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 -processor T6362067 -proc:only T6362067.java
* @compile/ref=T6362067.out -XDrawDiagnostics -processor T6362067 -proc:only T6362067.java * @compile/ref=T6362067.out -XDrawDiagnostics -processor T6362067 -proc:only T6362067.java
*/ */
import java.util.Set; import java.util.Set;
import javax.annotation.processing.*; import javax.annotation.processing.*;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import static javax.tools.Diagnostic.Kind.*; import static javax.tools.Diagnostic.Kind.*;
@Deprecated // convenient test annotation @Deprecated // convenient test annotations
@SupportedAnnotationTypes("*") @SuppressWarnings({""})
public class T6362067 extends AbstractProcessor { public class T6362067 extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annos, public boolean process(Set<? extends TypeElement> annos,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
Messager msgr = processingEnv.getMessager();
for (Element e: roundEnv.getRootElements()) { for (Element e: roundEnv.getRootElements()) {
msgr.printMessage(NOTE, "note:elem", e); messager.printMessage(NOTE, "note:elem", e);
for (AnnotationMirror a: e.getAnnotationMirrors()) { 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()) { 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()) if (roundEnv.processingOver())
msgr.printMessage(NOTE, "note:nopos"); messager.printMessage(NOTE, "note:nopos");
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6341173 6341072 * @bug 6341173 6341072
* @summary Test presence of Messager methods * @summary Test presence of Messager methods
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile MessagerBasics.java * @compile MessagerBasics.java
* @compile -processor MessagerBasics -proc:only MessagerBasics.java * @compile -processor MessagerBasics -proc:only MessagerBasics.java
* @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java * @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java
...@@ -39,18 +41,16 @@ import javax.lang.model.element.*; ...@@ -39,18 +41,16 @@ import javax.lang.model.element.*;
import javax.lang.model.util.*; import javax.lang.model.util.*;
import static javax.tools.Diagnostic.Kind.*; import static javax.tools.Diagnostic.Kind.*;
@SupportedAnnotationTypes("*")
@SupportedOptions("finalError") @SupportedOptions("finalError")
public class MessagerBasics extends AbstractProcessor { public class MessagerBasics extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
Messager m = processingEnv.getMessager();
if (roundEnv.processingOver()) { if (roundEnv.processingOver()) {
if (processingEnv.getOptions().containsKey("finalError")) if (processingEnv.getOptions().containsKey("finalError"))
m.printMessage(ERROR, "Does not compute"); messager.printMessage(ERROR, "Does not compute");
else { else {
m.printMessage(NOTE, "Post no bills"); messager.printMessage(NOTE, "Post no bills");
m.printMessage(WARNING, "Beware the ides of March!"); messager.printMessage(WARNING, "Beware the ides of March!");
} }
} }
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6194785 * @bug 6194785
* @summary ParameterDeclaration.getSimpleName does not return actual name from class files * @summary ParameterDeclaration.getSimpleName does not return actual name from class files
* @author Peter von der Ah\u00e9 * @author Peter von der Ah\u00e9
* @library ../../../lib
* @build JavacTestingAbstractProcessor
* @compile -g T6194785.java T6194785a.java * @compile -g T6194785.java T6194785a.java
* @compile -processor T6194785 foo.T6194785a T6194785.java * @compile -processor T6194785 foo.T6194785a T6194785.java
*/ */
...@@ -36,13 +38,10 @@ import javax.lang.model.element.*; ...@@ -36,13 +38,10 @@ import javax.lang.model.element.*;
import javax.lang.model.util.*; import javax.lang.model.util.*;
import static javax.tools.Diagnostic.Kind.*; import static javax.tools.Diagnostic.Kind.*;
@SupportedAnnotationTypes("*") public class T6194785 extends JavacTestingAbstractProcessor {
public class T6194785 extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment) RoundEnvironment roundEnvironment)
{ {
final Messager log = processingEnv.getMessager();
final Elements elements = processingEnv.getElementUtils();
class Scan extends ElementScanner7<Void,Void> { class Scan extends ElementScanner7<Void,Void> {
@Override @Override
public Void visitExecutable(ExecutableElement e, Void ignored) { 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
* @summary PackageElement.getEnclosedElements results in NullPointerException from parse(JavaCompiler.java:429) * @summary PackageElement.getEnclosedElements results in NullPointerException from parse(JavaCompiler.java:429)
* @author Steve Sides * @author Steve Sides
* @author Peter von der Ahe * @author Peter von der Ahe
* @library ../../../lib
* @build JavacTestingAbstractProcessor
* @compile T6341534.java * @compile T6341534.java
* @compile -proc:only -processor T6341534 dir/package-info.java * @compile -proc:only -processor T6341534 dir/package-info.java
* @compile -processor T6341534 dir/package-info.java * @compile -processor T6341534 dir/package-info.java
...@@ -40,20 +42,11 @@ import java.util.*; ...@@ -40,20 +42,11 @@ import java.util.*;
import java.util.Set; import java.util.Set;
import static javax.tools.Diagnostic.Kind.*; import static javax.tools.Diagnostic.Kind.*;
@SupportedAnnotationTypes("*") public class T6341534 extends JavacTestingAbstractProcessor {
public class T6341534 extends AbstractProcessor {
Elements elements;
Messager messager;
public void init(ProcessingEnvironment penv) {
super.init(penv);
elements = penv.getElementUtils();
messager = processingEnv.getMessager();
}
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) { public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
messager.printMessage(NOTE, messager.printMessage(NOTE,
String.valueOf(elements.getPackageElement("no.such.package"))); String.valueOf(eltUtils.getPackageElement("no.such.package")));
PackageElement dir = elements.getPackageElement("dir"); PackageElement dir = eltUtils.getPackageElement("dir");
messager.printMessage(NOTE, dir.getQualifiedName().toString()); messager.printMessage(NOTE, dir.getQualifiedName().toString());
for (Element e : dir.getEnclosedElements()) for (Element e : dir.getEnclosedElements())
messager.printMessage(NOTE, e.toString()); messager.printMessage(NOTE, e.toString());
......
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6449781 * @bug 6449781
* @summary Test that reported names of anonymous classes are non-null. * @summary Test that reported names of anonymous classes are non-null.
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @build TestAnonSourceNames * @library ../../../lib
* @build JavacTestingAbstractProcessor TestAnonSourceNames
* @compile -processor TestAnonSourceNames TestAnonClassNames.java * @compile -processor TestAnonSourceNames TestAnonClassNames.java
* @run main TestAnonClassNames * @run main TestAnonClassNames
*/ */
...@@ -141,8 +142,7 @@ public class TestAnonClassNames { ...@@ -141,8 +142,7 @@ public class TestAnonClassNames {
/** /**
* Probe at the various kinds of names of a type element. * Probe at the various kinds of names of a type element.
*/ */
@SupportedAnnotationTypes("*") class ClassNameProber extends JavacTestingAbstractProcessor {
class ClassNameProber extends AbstractProcessor {
public ClassNameProber(){super();} public ClassNameProber(){super();}
private boolean classesFound=false; private boolean classesFound=false;
...@@ -174,8 +174,4 @@ class ClassNameProber extends AbstractProcessor { ...@@ -174,8 +174,4 @@ class ClassNameProber extends AbstractProcessor {
} }
return true; return true;
} }
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
} }
...@@ -36,8 +36,7 @@ import static javax.tools.Diagnostic.Kind.*; ...@@ -36,8 +36,7 @@ import static javax.tools.Diagnostic.Kind.*;
* Using the tree API, retrieve element representations of anonymous * Using the tree API, retrieve element representations of anonymous
* classes and verify their names are as specified. * classes and verify their names are as specified.
*/ */
@SupportedAnnotationTypes("*") public class TestAnonSourceNames extends JavacTestingAbstractProcessor {
public class TestAnonSourceNames extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
...@@ -84,9 +83,4 @@ public class TestAnonSourceNames extends AbstractProcessor { ...@@ -84,9 +83,4 @@ public class TestAnonSourceNames extends AbstractProcessor {
return super.visitClass(node, cu); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6453386 * @bug 6453386
* @summary Test basic properties of javax.lang.element.Element * @summary Test basic properties of javax.lang.element.Element
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @build TestElement * @library ../../../lib
* @build JavacTestingAbstractProcessor TestElement
* @compile -processor TestElement -proc:only TestElement.java * @compile -processor TestElement -proc:only TestElement.java
*/ */
...@@ -43,8 +44,7 @@ import static javax.tools.StandardLocation.*; ...@@ -43,8 +44,7 @@ import static javax.tools.StandardLocation.*;
/** /**
* Test basic workings of javax.lang.element.Element * Test basic workings of javax.lang.element.Element
*/ */
@SupportedAnnotationTypes("*") public class TestElement extends JavacTestingAbstractProcessor {
public class TestElement extends AbstractProcessor {
/** /**
* For now, just check that constructors have a simple name of * For now, just check that constructors have a simple name of
* "<init>". * "<init>".
...@@ -66,9 +66,4 @@ public class TestElement extends AbstractProcessor { ...@@ -66,9 +66,4 @@ public class TestElement extends AbstractProcessor {
} }
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6380016 * @bug 6380016
* @summary Test that the constraints guaranteed by the Filer and maintained * @summary Test that the constraints guaranteed by the Filer and maintained
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @build TestNames * @library ../../../lib
* @build JavacTestingAbstractProcessor TestNames
* @compile -processor TestNames -proc:only TestNames.java * @compile -processor TestNames -proc:only TestNames.java
*/ */
...@@ -45,11 +46,8 @@ import java.io.*; ...@@ -45,11 +46,8 @@ import java.io.*;
/** /**
* Basic tests of semantics of javax.lang.model.element.Name * Basic tests of semantics of javax.lang.model.element.Name
*/ */
@SupportedAnnotationTypes("*") public class TestNames extends JavacTestingAbstractProcessor {
public class TestNames extends AbstractProcessor {
private int round = 0; private int round = 0;
private Filer filer;
private Elements eltUtils;
String stringStringName = "java.lang.String"; String stringStringName = "java.lang.String";
Name stringName = null; Name stringName = null;
...@@ -106,16 +104,6 @@ public class TestNames extends AbstractProcessor { ...@@ -106,16 +104,6 @@ public class TestNames extends AbstractProcessor {
return true; 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 static class Pseudonym implements Name {
private String 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6449798 6399404 * @bug 6449798 6399404
* @summary Test basic workings of PackageElement * @summary Test basic workings of PackageElement
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @build TestPackageElement * @library ../../../lib
* @build JavacTestingAbstractProcessor TestPackageElement
* @compile -processor TestPackageElement -proc:only TestPackageElement.java * @compile -processor TestPackageElement -proc:only TestPackageElement.java
*/ */
...@@ -43,11 +44,7 @@ import static javax.tools.StandardLocation.*; ...@@ -43,11 +44,7 @@ import static javax.tools.StandardLocation.*;
/** /**
* Test basic workings of PackageElement. * Test basic workings of PackageElement.
*/ */
@SupportedAnnotationTypes("*") public class TestPackageElement extends JavacTestingAbstractProcessor {
public class TestPackageElement extends AbstractProcessor {
private Filer filer;
private Elements eltUtils;
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) { if (!roundEnv.processingOver()) {
...@@ -71,15 +68,4 @@ public class TestPackageElement extends AbstractProcessor { ...@@ -71,15 +68,4 @@ public class TestPackageElement extends AbstractProcessor {
} }
return true; 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 @@ ...@@ -26,7 +26,8 @@
* @bug 6967842 * @bug 6967842
* @summary Element not returned from tree API for ARM resource variables. * @summary Element not returned from tree API for ARM resource variables.
* @author A. Sundararajan * @author A. Sundararajan
* @build TestResourceElement * @library ../../../lib
* @build JavacTestingAbstractProcessor TestResourceElement
* @compile -processor TestResourceElement -proc:only TestResourceElement.java * @compile -processor TestResourceElement -proc:only TestResourceElement.java
*/ */
...@@ -37,8 +38,7 @@ import java.util.*; ...@@ -37,8 +38,7 @@ import java.util.*;
import com.sun.source.tree.*; import com.sun.source.tree.*;
import com.sun.source.util.*; import com.sun.source.util.*;
@SupportedAnnotationTypes("*") public class TestResourceElement extends JavacTestingAbstractProcessor implements AutoCloseable {
public class TestResourceElement extends AbstractProcessor implements AutoCloseable {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) { if (!roundEnv.processingOver()) {
...@@ -88,9 +88,4 @@ public class TestResourceElement extends AbstractProcessor implements AutoClosea ...@@ -88,9 +88,4 @@ public class TestResourceElement extends AbstractProcessor implements AutoClosea
return trvElement; return trvElement;
} }
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
} }
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6911256 6964740 6967842 * @bug 6911256 6964740 6967842
* @summary Test that the resource variable kind is appropriately set * @summary Test that the resource variable kind is appropriately set
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @build TestResourceVariable * @library ../../../lib
* @build JavacTestingAbstractProcessor TestResourceVariable
* @compile -processor TestResourceVariable -proc:only TestResourceVariable.java * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java
*/ */
...@@ -48,8 +49,7 @@ import static javax.tools.Diagnostic.Kind.*; ...@@ -48,8 +49,7 @@ import static javax.tools.Diagnostic.Kind.*;
* resource of an ARM block and verify their kind tags are set * resource of an ARM block and verify their kind tags are set
* appropriately. * appropriately.
*/ */
@SupportedAnnotationTypes("*") public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable {
public class TestResourceVariable extends AbstractProcessor implements AutoCloseable {
int resourceVariableCount = 0; int resourceVariableCount = 0;
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
...@@ -105,9 +105,4 @@ public class TestResourceVariable extends AbstractProcessor implements AutoClose ...@@ -105,9 +105,4 @@ public class TestResourceVariable extends AbstractProcessor implements AutoClose
return super.visitVariable(node, cu); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6423972 * @bug 6423972
* @summary Tests TypeParameter.getBounds. * @summary Tests TypeParameter.getBounds.
* @author Scott Seligman * @author Scott Seligman
* @build TypeParamBounds * @library ../../../lib
* @build JavacTestingAbstractProcessor TypeParamBounds
* @compile -processor TypeParamBounds -proc:only TypeParamBounds.java * @compile -processor TypeParamBounds -proc:only TypeParamBounds.java
*/ */
...@@ -40,18 +41,7 @@ import javax.lang.model.element.*; ...@@ -40,18 +41,7 @@ import javax.lang.model.element.*;
import javax.lang.model.type.*; import javax.lang.model.type.*;
import javax.lang.model.util.*; import javax.lang.model.util.*;
@SupportedAnnotationTypes("*") public class TypeParamBounds extends JavacTestingAbstractProcessor {
public class TypeParamBounds extends AbstractProcessor {
Elements elements;
Types types;
public void init(ProcessingEnvironment penv) {
super.init(penv);
elements = penv.getElementUtils();
types = penv.getTypeUtils();
}
public boolean process(Set<? extends TypeElement> annoTypes, public boolean process(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) { RoundEnvironment round) {
if (!round.processingOver()) if (!round.processingOver())
...@@ -59,11 +49,6 @@ public class TypeParamBounds extends AbstractProcessor { ...@@ -59,11 +49,6 @@ public class TypeParamBounds extends AbstractProcessor {
return true; return true;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
private void doit(Set<? extends TypeElement> annoTypes, private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) { RoundEnvironment round) {
TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen"); TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen");
...@@ -91,7 +76,6 @@ public class TypeParamBounds extends AbstractProcessor { ...@@ -91,7 +76,6 @@ public class TypeParamBounds extends AbstractProcessor {
// Fodder for the processor // Fodder for the processor
static class Gen<T, U extends Object, V extends Number, W extends U, static class Gen<T, U extends Object, V extends Number, W extends U,
X extends Runnable, Y extends CharSequence & Runnable, X extends Runnable, Y extends CharSequence & Runnable,
Z extends Object & 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6362178 * @bug 6362178
* @summary MirroredType[s]Exception shouldn't be created too eagerly * @summary MirroredType[s]Exception shouldn't be created too eagerly
* @author Scott Seligman * @author Scott Seligman
* @library ../../../../lib
* @build JavacTestingAbstractProcessor
* @compile -g OverEager.java * @compile -g OverEager.java
* @compile -processor OverEager -proc:only OverEager.java * @compile -processor OverEager -proc:only OverEager.java
*/ */
...@@ -40,17 +42,7 @@ import static javax.lang.model.util.ElementFilter.*; ...@@ -40,17 +42,7 @@ import static javax.lang.model.util.ElementFilter.*;
@SupportedAnnotationTypes("IAm") @SupportedAnnotationTypes("IAm")
@IAm(OverEager.class) @IAm(OverEager.class)
public class OverEager extends AbstractProcessor { public class OverEager extends JavacTestingAbstractProcessor {
Elements elements;
Types types;
public void init(ProcessingEnvironment penv) {
super.init(penv);
elements = penv.getElementUtils();
types = penv.getTypeUtils();
}
public boolean process(Set<? extends TypeElement> annoTypes, public boolean process(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) { RoundEnvironment round) {
if (!round.processingOver()) if (!round.processingOver())
...@@ -58,11 +50,6 @@ public class OverEager extends AbstractProcessor { ...@@ -58,11 +50,6 @@ public class OverEager extends AbstractProcessor {
return true; return true;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
private void doit(Set<? extends TypeElement> annoTypes, private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) { RoundEnvironment round) {
for (TypeElement t : typesIn(round.getRootElements())) { for (TypeElement t : typesIn(round.getRootElements())) {
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
* @test * @test
* @bug 6519115 * @bug 6519115
* @summary Verify MirroredTypeException vs MirroredTypesException is thrown * @summary Verify MirroredTypeException vs MirroredTypesException is thrown
* @library ../../../../lib
* @build JavacTestingAbstractProcessor
* @compile Plurality.java * @compile Plurality.java
* @compile -processor Plurality -proc:only Plurality.java * @compile -processor Plurality -proc:only Plurality.java
* @author Joseph D. Darcy * @author Joseph D. Darcy
...@@ -38,25 +40,13 @@ import javax.lang.model.element.*; ...@@ -38,25 +40,13 @@ import javax.lang.model.element.*;
import javax.lang.model.type.*; import javax.lang.model.type.*;
import javax.lang.model.util.*; import javax.lang.model.util.*;
@SupportedAnnotationTypes("*")
@P0 @P0
@P1 @P1
@P2 @P2
@S1 @S1
public class Plurality extends AbstractProcessor { public class Plurality extends JavacTestingAbstractProcessor {
private boolean executed = false; 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, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) { if (!roundEnv.processingOver()) {
...@@ -164,11 +154,6 @@ public class Plurality extends AbstractProcessor { ...@@ -164,11 +154,6 @@ public class Plurality extends AbstractProcessor {
toStringName); toStringName);
} }
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
} }
@Retention(RetentionPolicy.RUNTIME) @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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6418666 6423973 6453386 * @bug 6418666 6423973 6453386
* @summary Test the NoTypes: VOID, PACKAGE, NONE * @summary Test the NoTypes: VOID, PACKAGE, NONE
* @author Scott Seligman * @author Scott Seligman
* @library ../../../lib
* @build JavacTestingAbstractProcessor
* @compile -g NoTypes.java * @compile -g NoTypes.java
* @compile -processor NoTypes -proc:only NoTypes.java * @compile -processor NoTypes -proc:only NoTypes.java
*/ */
...@@ -39,18 +41,7 @@ import javax.lang.model.util.*; ...@@ -39,18 +41,7 @@ import javax.lang.model.util.*;
import static javax.lang.model.type.TypeKind.*; import static javax.lang.model.type.TypeKind.*;
@SupportedAnnotationTypes("*") public class NoTypes extends JavacTestingAbstractProcessor {
public class NoTypes extends AbstractProcessor {
Elements elements;
Types types;
public void init(ProcessingEnvironment penv) {
super.init(penv);
elements = penv.getElementUtils();
types = penv.getTypeUtils();
}
public boolean process(Set<? extends TypeElement> annoTypes, public boolean process(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) { RoundEnvironment round) {
if (!round.processingOver()) if (!round.processingOver())
...@@ -58,11 +49,6 @@ public class NoTypes extends AbstractProcessor { ...@@ -58,11 +49,6 @@ public class NoTypes extends AbstractProcessor {
return true; return true;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
private void doit(Set<? extends TypeElement> annoTypes, private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) { 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6346251 * @bug 6346251
* @summary Test Elements.getBinaryName * @summary Test Elements.getBinaryName
* @author Scott Seligman * @author Scott Seligman
* @build BinaryName * @library ../../../lib
* @build JavacTestingAbstractProcessor BinaryName
* @compile -processor BinaryName -proc:only BinaryName.java * @compile -processor BinaryName -proc:only BinaryName.java
*/ */
...@@ -38,17 +39,8 @@ import javax.lang.model.util.*; ...@@ -38,17 +39,8 @@ import javax.lang.model.util.*;
import static javax.lang.model.util.ElementFilter.typesIn; import static javax.lang.model.util.ElementFilter.typesIn;
@SupportedAnnotationTypes("*")
@HelloIm("BinaryName") @HelloIm("BinaryName")
public class BinaryName extends AbstractProcessor { public class BinaryName extends JavacTestingAbstractProcessor {
Elements elements;
public void init(ProcessingEnvironment penv) {
super.init(penv);
elements = penv.getElementUtils();
}
public boolean process(Set<? extends TypeElement> tes, public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) { RoundEnvironment round) {
if (round.processingOver()) return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6346506 6408241 * @bug 6346506 6408241
* @summary getTypeElement should tolerate a type that can't be found * @summary getTypeElement should tolerate a type that can't be found
* @author Scott Seligman * @author Scott Seligman
* @build GetTypeElemBadArg * @library ../../../lib
* @build JavacTestingAbstractProcessor GetTypeElemBadArg
* @compile -processor GetTypeElemBadArg -proc:only GetTypeElemBadArg.java * @compile -processor GetTypeElemBadArg -proc:only GetTypeElemBadArg.java
*/ */
...@@ -37,16 +38,7 @@ import javax.lang.model.element.*; ...@@ -37,16 +38,7 @@ import javax.lang.model.element.*;
import javax.lang.model.type.*; import javax.lang.model.type.*;
import javax.lang.model.util.*; import javax.lang.model.util.*;
@SupportedAnnotationTypes("*") public class GetTypeElemBadArg extends JavacTestingAbstractProcessor {
public class GetTypeElemBadArg extends AbstractProcessor {
Elements elements;
public void init(ProcessingEnvironment penv) {
super.init(penv);
elements = penv.getElementUtils();
}
public boolean process(Set<? extends TypeElement> tes, public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) { RoundEnvironment round) {
if (round.processingOver()) return true; if (round.processingOver()) return true;
...@@ -63,12 +55,6 @@ public class GetTypeElemBadArg extends AbstractProcessor { ...@@ -63,12 +55,6 @@ public class GetTypeElemBadArg extends AbstractProcessor {
return true; return true;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
private static void tellAbout(TypeElement t) { private static void tellAbout(TypeElement t) {
System.out.println(t); System.out.println(t);
System.out.println(t.getClass()); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6346453 * @bug 6346453
* @summary directSupertypes should return empty list if arg has no supertypes * @summary directSupertypes should return empty list if arg has no supertypes
* @author Scott Seligman * @author Scott Seligman
* @build NoSupers * @library ../../../lib
* @build JavacTestingAbstractProcessor NoSupers
* @compile -processor NoSupers -proc:only NoSupers.java * @compile -processor NoSupers -proc:only NoSupers.java
*/ */
...@@ -36,16 +37,7 @@ import javax.lang.model.element.*; ...@@ -36,16 +37,7 @@ import javax.lang.model.element.*;
import javax.lang.model.type.*; import javax.lang.model.type.*;
import javax.lang.model.util.*; import javax.lang.model.util.*;
@SupportedAnnotationTypes("*") public class NoSupers extends JavacTestingAbstractProcessor {
public class NoSupers extends AbstractProcessor {
Types types;
public void init(ProcessingEnvironment penv) {
super.init(penv);
types = penv.getTypeUtils();
}
public boolean process(Set<? extends TypeElement> tes, public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) { RoundEnvironment round) {
if (round.processingOver()) return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6453386 * @bug 6453386
* @summary Verify that example code in Elements.overrides works as spec'ed. * @summary Verify that example code in Elements.overrides works as spec'ed.
* @author Scott Seligman * @author Scott Seligman
* @library ../../../lib
* @build JavacTestingAbstractProcessor
* @compile -g OverridesSpecEx.java * @compile -g OverridesSpecEx.java
* @compile -processor OverridesSpecEx -proc:only OverridesSpecEx.java * @compile -processor OverridesSpecEx -proc:only OverridesSpecEx.java
*/ */
...@@ -39,19 +41,7 @@ import javax.lang.model.util.*; ...@@ -39,19 +41,7 @@ import javax.lang.model.util.*;
import static javax.lang.model.util.ElementFilter.*; import static javax.lang.model.util.ElementFilter.*;
public class OverridesSpecEx extends JavacTestingAbstractProcessor {
@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 boolean process(Set<? extends TypeElement> annoTypes, public boolean process(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) { RoundEnvironment round) {
if (!round.processingOver()) if (!round.processingOver())
...@@ -59,11 +49,6 @@ public class OverridesSpecEx extends AbstractProcessor { ...@@ -59,11 +49,6 @@ public class OverridesSpecEx extends AbstractProcessor {
return true; return true;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
private void doit(Set<? extends TypeElement> annoTypes, private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) { RoundEnvironment round) {
TypeElement string = elements.getTypeElement("java.lang.String"); TypeElement string = elements.getTypeElement("java.lang.String");
...@@ -113,9 +98,7 @@ public class OverridesSpecEx extends AbstractProcessor { ...@@ -113,9 +98,7 @@ public class OverridesSpecEx extends AbstractProcessor {
throw new AssertionError("Bogus result"); throw new AssertionError("Bogus result");
} }
// Fodder for the processor // Fodder for the processor
class A { class A {
public void m() {} 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6345812 * @bug 6345812
* @summary Validate argument kinds in Types utilities * @summary Validate argument kinds in Types utilities
* @author Scott Seligman * @author Scott Seligman
* @build TypesBadArg * @library ../../../lib
* @build JavacTestingAbstractProcessor TypesBadArg
* @compile -processor TypesBadArg -proc:only TypesBadArg.java * @compile -processor TypesBadArg -proc:only TypesBadArg.java
*/ */
...@@ -36,15 +37,9 @@ import javax.lang.model.element.*; ...@@ -36,15 +37,9 @@ import javax.lang.model.element.*;
import javax.lang.model.type.*; import javax.lang.model.type.*;
import javax.lang.model.util.*; import javax.lang.model.util.*;
@SupportedAnnotationTypes("*") public class TypesBadArg extends JavacTestingAbstractProcessor {
public class TypesBadArg extends AbstractProcessor {
boolean success = true; boolean success = true;
public void init(ProcessingEnvironment penv) {
super.init(penv);
}
public boolean process(Set<? extends TypeElement> tes, public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) { RoundEnvironment round) {
if (round.processingOver()) return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6392818 * @bug 6392818
* @summary Tests Elements.isDeprecated(Element) * @summary Tests Elements.isDeprecated(Element)
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../../../lib
* @build JavacTestingAbstractProcessor
* @compile TestDeprecation.java * @compile TestDeprecation.java
* @compile -processor TestDeprecation -proc:only Dep1.java * @compile -processor TestDeprecation -proc:only Dep1.java
* @compile Dep1.java * @compile Dep1.java
...@@ -47,8 +49,7 @@ import java.io.Writer; ...@@ -47,8 +49,7 @@ import java.io.Writer;
* getElementsAnnotatedWith is consistent with the expected results * getElementsAnnotatedWith is consistent with the expected results
* stored in an AnnotatedElementInfo annotation. * stored in an AnnotatedElementInfo annotation.
*/ */
@SupportedAnnotationTypes("*") public class TestDeprecation extends JavacTestingAbstractProcessor {
public class TestDeprecation extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
...@@ -98,9 +99,4 @@ public class TestDeprecation extends AbstractProcessor { ...@@ -98,9 +99,4 @@ public class TestDeprecation extends AbstractProcessor {
return failure; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6346973 * @bug 6346973
* @summary directSupertypes(t) should not return t * @summary directSupertypes(t) should not return t
* @author Scott Seligman * @author Scott Seligman
* @build DirectSupersOfErr * @library ../../../../lib
* @build JavacTestingAbstractProcessor DirectSupersOfErr
* @compile -processor DirectSupersOfErr -proc:only C1.java * @compile -processor DirectSupersOfErr -proc:only C1.java
*/ */
...@@ -37,16 +38,7 @@ import javax.lang.model.type.*; ...@@ -37,16 +38,7 @@ import javax.lang.model.type.*;
import javax.lang.model.util.*; import javax.lang.model.util.*;
import static javax.lang.model.util.ElementFilter.*; import static javax.lang.model.util.ElementFilter.*;
@SupportedAnnotationTypes("*") public class DirectSupersOfErr extends JavacTestingAbstractProcessor {
public class DirectSupersOfErr extends AbstractProcessor {
Types types;
public void init(ProcessingEnvironment penv) {
super.init(penv);
types = penv.getTypeUtils();
}
public boolean process(Set<? extends TypeElement> tes, public boolean process(Set<? extends TypeElement> tes,
RoundEnvironment round) { RoundEnvironment round) {
if (round.processingOver()) return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6471577 6517779 * @bug 6471577 6517779
* @summary Test Elements.getConstantExpression * @summary Test Elements.getConstantExpression
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @build TestGetConstantExpression * @library ../../../../lib
* @build JavacTestingAbstractProcessor TestGetConstantExpression
* @compile -processor TestGetConstantExpression Foo.java * @compile -processor TestGetConstantExpression Foo.java
*/ */
...@@ -44,10 +45,7 @@ import java.io.*; ...@@ -44,10 +45,7 @@ import java.io.*;
/** /**
* Test basic workings of Elements.getConstantExpression. * Test basic workings of Elements.getConstantExpression.
*/ */
@SupportedAnnotationTypes("*") public class TestGetConstantExpression extends JavacTestingAbstractProcessor {
public class TestGetConstantExpression extends AbstractProcessor {
private Elements eltUtils;
private Filer filer;
private int round = 1; private int round = 1;
/** /**
...@@ -130,14 +128,4 @@ public class TestGetConstantExpression extends AbstractProcessor { ...@@ -130,14 +128,4 @@ public class TestGetConstantExpression extends AbstractProcessor {
return 0; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* @bug 6453386 * @bug 6453386
* @summary Test Elements.getPackageOf * @summary Test Elements.getPackageOf
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @build TestGetPackageOf * @library ../../../../lib
* @build JavacTestingAbstractProcessor TestGetPackageOf
* @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java * @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java
*/ */
...@@ -43,10 +44,7 @@ import static javax.tools.StandardLocation.*; ...@@ -43,10 +44,7 @@ import static javax.tools.StandardLocation.*;
/** /**
* Test basic workings of Elements.getPackageOf * Test basic workings of Elements.getPackageOf
*/ */
@SupportedAnnotationTypes("*") public class TestGetPackageOf extends JavacTestingAbstractProcessor {
public class TestGetPackageOf extends AbstractProcessor {
private Elements eltUtils;
/** /**
* Check expected behavior on classes and packages. * Check expected behavior on classes and packages.
*/ */
...@@ -69,13 +67,4 @@ public class TestGetPackageOf extends AbstractProcessor { ...@@ -69,13 +67,4 @@ public class TestGetPackageOf extends AbstractProcessor {
} }
return true; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* @bug 6406164 * @bug 6406164
* @summary Test that ElementFilter iterable methods behave properly. * @summary Test that ElementFilter iterable methods behave properly.
* @author Joseph D. Darcy * @author Joseph D. Darcy
* @library ../../../../lib
* @build JavacTestingAbstractProcessor
* @compile TestIterables.java * @compile TestIterables.java
* @compile -processor TestIterables -proc:only Foo1.java * @compile -processor TestIterables -proc:only Foo1.java
* @compile Foo1.java * @compile Foo1.java
...@@ -51,9 +53,8 @@ import static javax.lang.model.util.ElementFilter.*; ...@@ -51,9 +53,8 @@ import static javax.lang.model.util.ElementFilter.*;
* results. * results.
*/ */
@SupportedAnnotationTypes("ExpectedElementCounts") @SupportedAnnotationTypes("ExpectedElementCounts")
@ExpectedElementCounts(methods=3) @ExpectedElementCounts(methods=2)
public class TestIterables extends AbstractProcessor { public class TestIterables extends JavacTestingAbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) { if (!roundEnv.processingOver()) {
...@@ -118,10 +119,4 @@ public class TestIterables extends AbstractProcessor { ...@@ -118,10 +119,4 @@ public class TestIterables extends AbstractProcessor {
return count1; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -50,7 +50,8 @@ import static javax.tools.Diagnostic.Kind.*; ...@@ -50,7 +50,8 @@ import static javax.tools.Diagnostic.Kind.*;
/** /**
* This processor returns the supported source level as indicated by * 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("*") @SupportedAnnotationTypes("*")
@SupportedOptions("SourceVersion") @SupportedOptions("SourceVersion")
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
/* /*
* @test 6403456 * @test 6403456
* @summary -Werror should work with annotation processing * @summary -Werror should work with annotation processing
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile WError1.java * @compile WError1.java
* @compile -proc:only -processor WError1 WError1.java * @compile -proc:only -processor WError1 WError1.java
* @compile/fail/ref=WError1.out -XDrawDiagnostics -Werror -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.*; ...@@ -36,22 +38,15 @@ import javax.lang.model.*;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.tools.*; import javax.tools.*;
@SupportedAnnotationTypes("*") public class WError1 extends JavacTestingAbstractProcessor {
public class WError1 extends AbstractProcessor {
@Override @Override
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
Messager messager = processingEnv.getMessager();
if (++round == 1) { if (++round == 1) {
messager.printMessage(Diagnostic.Kind.WARNING, "round 1"); messager.printMessage(Diagnostic.Kind.WARNING, "round 1");
} }
return true; return true;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
int round = 0; int round = 0;
} }
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
/* /*
* @test 6403456 * @test 6403456
* @summary -Werror should work with annotation processing * @summary -Werror should work with annotation processing
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile WErrorGen.java * @compile WErrorGen.java
* @compile -proc:only -processor WErrorGen WErrorGen.java * @compile -proc:only -processor WErrorGen WErrorGen.java
* @compile/fail/ref=WErrorGen.out -XDrawDiagnostics -Werror -Xlint:rawtypes -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.*; ...@@ -36,12 +38,10 @@ import javax.lang.model.*;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.tools.*; import javax.tools.*;
@SupportedAnnotationTypes("*") public class WErrorGen extends JavacTestingAbstractProcessor {
public class WErrorGen extends AbstractProcessor {
@Override @Override
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
Filer filer = processingEnv.getFiler();
if (++round == 1) { if (++round == 1) {
try { try {
JavaFileObject fo = filer.createSourceFile("Gen"); JavaFileObject fo = filer.createSourceFile("Gen");
...@@ -54,10 +54,5 @@ public class WErrorGen extends AbstractProcessor { ...@@ -54,10 +54,5 @@ public class WErrorGen extends AbstractProcessor {
return true; return true;
} }
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
int round = 0; int round = 0;
} }
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
/* /*
* @test 6403456 * @test 6403456
* @summary -Werror should work with annotation processing * @summary -Werror should work with annotation processing
* @library ../../lib
* @build JavacTestingAbstractProcessor
* @compile WErrorLast.java * @compile WErrorLast.java
* @compile -proc:only -processor WErrorLast WErrorLast.java * @compile -proc:only -processor WErrorLast WErrorLast.java
* @compile/fail/ref=WErrorLast.out -XDrawDiagnostics -Werror -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.*; ...@@ -36,20 +38,13 @@ import javax.lang.model.*;
import javax.lang.model.element.*; import javax.lang.model.element.*;
import javax.tools.*; import javax.tools.*;
@SupportedAnnotationTypes("*") public class WErrorLast extends JavacTestingAbstractProcessor {
public class WErrorLast extends AbstractProcessor {
@Override @Override
public boolean process(Set<? extends TypeElement> annotations, public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) { RoundEnvironment roundEnv) {
Messager messager = processingEnv.getMessager();
if (roundEnv.processingOver()) { if (roundEnv.processingOver()) {
messager.printMessage(Diagnostic.Kind.WARNING, "last round"); messager.printMessage(Diagnostic.Kind.WARNING, "last round");
} }
return true; 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.
先完成此消息的编辑!
想要评论请 注册