test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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.
@@ -23,10 +23,13 @@
/*
* @test
* @bug 6877202 6986246
* @summary Elements.getDocComment() is not getting JavaDocComments
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor TestDocComments
+ * @run main TestDocComments
*/
import com.sun.source.tree.*;
import com.sun.source.util.*;
import java.io.*;
@@ -47,12 +50,11 @@
* command line and JSR 199 invocation, the test covers both ways of invoking the
* compiler.
*/
@SupportedOptions("scan")
-@SupportedAnnotationTypes("*")
-public class TestDocComments extends AbstractProcessor {
+public class TestDocComments extends JavacTestingAbstractProcessor {
enum CompileKind { API, CMD };
enum ScanKind { TREE, ELEMENT };
// ----- Main test driver: invoke compiler for the various test cases ------
@@ -70,11 +72,11 @@
if (errors > 0)
throw new Exception(errors + " errors occurred");
}
static void test(CompileKind ck, ScanKind sk) throws IOException {
- String testClasses = System.getProperty("test.classes");
+ String testClasses = System.getProperty("test.class.path");
String testSrc = System.getProperty("test.src");
File testDir = new File("test." + ck + "." + sk);
testDir.mkdirs();
String[] opts = {
"-d", testDir.getPath(),
@@ -134,30 +136,19 @@
static int errors;
// ----- Annotation processor: scan for elements and check doc comments ----
Map<String,String> options;
- Filer filer;
- Messager messager;
- Elements elements;
Trees trees;
ScanKind skind;
int round = 0;
@Override
- public SourceVersion getSupportedSourceVersion() {
- return SourceVersion.latest();
- }
-
- @Override
public void init(ProcessingEnvironment pEnv) {
super.init(pEnv);
options = pEnv.getOptions();
- filer = pEnv.getFiler();
- messager = pEnv.getMessager();
- elements = pEnv.getElementUtils();
trees = Trees.instance(processingEnv);
skind = ScanKind.valueOf(options.get("scan"));
}
@Override
@@ -269,11 +260,11 @@
}
}
// ----- Scanners to find elements -----------------------------------------
- class TestElementScanner extends ElementScanner7<Void, Void> {
+ class TestElementScanner extends ElementScanner<Void, Void> {
@Override
public Void visitExecutable(ExecutableElement e, Void _) {
check(e);
return super.visitExecutable(e, _);
}
@@ -304,7 +295,6 @@
public Void visitVariable(VariableTree tree, Trees trees) {
check(trees.getElement(getCurrentPath()));
return super.visitVariable(tree, trees);
}
}
-
}