--- a/langtools/make/Makefile Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/make/Makefile Tue Feb 23 10:17:51 2010 -0800
@@ -70,7 +70,7 @@
endif
ifdef VERBOSE
- ANT_OPTIONS += -verbose -diagnostics
+ ANT_OPTIONS += -verbose -debug
endif
ifdef JDK_VERSION
--- a/langtools/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java Tue Feb 23 10:17:51 2010 -0800
@@ -101,7 +101,11 @@
}
@SuppressWarnings("cast")
private int compareEqualPosition(Declaration d1, Declaration d2) {
- assert d1.getPosition() == d2.getPosition();
+ assert
+ (d1.getPosition() == d2.getPosition()) || // Handles two null positions.
+ (d1.getPosition().file().compareTo(d2.getPosition().file()) == 0 &&
+ d1.getPosition().line() == d2.getPosition().line() &&
+ d1.getPosition().column() == d2.getPosition().column());
DeclPartialOrder dpo1 = new DeclPartialOrder();
DeclPartialOrder dpo2 = new DeclPartialOrder();
--- a/langtools/src/share/classes/com/sun/tools/apt/comp/Apt.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/src/share/classes/com/sun/tools/apt/comp/Apt.java Tue Feb 23 10:17:51 2010 -0800
@@ -496,57 +496,12 @@
* won't match anything.
*/
Pattern importStringToPattern(String s) {
- if (s.equals("*")) {
- return allMatches;
+ if (com.sun.tools.javac.processing.JavacProcessingEnvironment.isValidImportString(s)) {
+ return com.sun.tools.javac.processing.JavacProcessingEnvironment.validImportStringToPattern(s);
} else {
- String t = s;
- boolean star = false;
-
- /*
- * Validate string from factory is legal. If the string
- * has more than one asterisks or the asterisks does not
- * appear as the last character (preceded by a period),
- * the string is not legal.
- */
-
- boolean valid = true;
- int index = t.indexOf('*');
- if (index != -1) {
- // '*' must be last character...
- if (index == t.length() -1) {
- // ... and preceeding character must be '.'
- if ( index-1 >= 0 ) {
- valid = t.charAt(index-1) == '.';
- // Strip off ".*$" for identifier checks
- t = t.substring(0, t.length()-2);
- }
- } else
- valid = false;
- }
-
- // Verify string is off the form (javaId \.)+ or javaId
- if (valid) {
- String[] javaIds = t.split("\\.", t.length()+2);
- for(String javaId: javaIds)
- valid &= isJavaIdentifier(javaId);
- }
-
- if (!valid) {
- Bark bark = Bark.instance(context);
- bark.aptWarning("MalformedSupportedString", s);
- return noMatches; // won't match any valid identifier
- }
-
- String s_prime = s.replaceAll("\\.", "\\\\.");
-
- if (s_prime.endsWith("*")) {
- s_prime = s_prime.substring(0, s_prime.length() - 1) + ".+";
- }
-
- return Pattern.compile(s_prime);
+ Bark bark = Bark.instance(context);
+ bark.aptWarning("MalformedSupportedString", s);
+ return com.sun.tools.javac.processing.JavacProcessingEnvironment.noMatches;
}
}
-
- private static final Pattern allMatches = Pattern.compile(".*");
- private static final Pattern noMatches = Pattern.compile("(\\P{all})+");
}
--- a/langtools/src/share/classes/com/sun/tools/apt/main/Main.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/src/share/classes/com/sun/tools/apt/main/Main.java Tue Feb 23 10:17:51 2010 -0800
@@ -56,6 +56,8 @@
import com.sun.tools.apt.util.Bark;
import com.sun.mirror.apt.AnnotationProcessorFactory;
+import static com.sun.tools.javac.file.Paths.pathToURLs;
+
/** This class provides a commandline interface to the apt build-time
* tool.
*
@@ -1276,59 +1278,4 @@
}
}
}
-
- // Borrowed from DocletInvoker
- /**
- * Utility method for converting a search path string to an array
- * of directory and JAR file URLs.
- *
- * @param path the search path string
- * @return the resulting array of directory and JAR file URLs
- */
- static URL[] pathToURLs(String path) {
- StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
- URL[] urls = new URL[st.countTokens()];
- int count = 0;
- while (st.hasMoreTokens()) {
- URL url = fileToURL(new File(st.nextToken()));
- if (url != null) {
- urls[count++] = url;
- }
- }
- if (urls.length != count) {
- URL[] tmp = new URL[count];
- System.arraycopy(urls, 0, tmp, 0, count);
- urls = tmp;
- }
- return urls;
- }
-
- /**
- * Returns the directory or JAR file URL corresponding to the specified
- * local file name.
- *
- * @param file the File object
- * @return the resulting directory or JAR file URL, or null if unknown
- */
- static URL fileToURL(File file) {
- String name;
- try {
- name = file.getCanonicalPath();
- } catch (IOException e) {
- name = file.getAbsolutePath();
- }
- name = name.replace(File.separatorChar, '/');
- if (!name.startsWith("/")) {
- name = "/" + name;
- }
- // If the file does not exist, then assume that it's a directory
- if (!file.isFile()) {
- name = name + "/";
- }
- try {
- return new URL("file", "", name);
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException("file");
- }
- }
}
--- a/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java Tue Feb 23 10:17:51 2010 -0800
@@ -27,6 +27,8 @@
import java.io.File;
import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -34,6 +36,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
+import java.util.StringTokenizer;
import java.util.zip.ZipFile;
import javax.tools.JavaFileManager.Location;
@@ -449,4 +452,60 @@
return fsInfo.isFile(file)
&& (n.endsWith(".jar") || n.endsWith(".zip"));
}
+
+ /**
+ * Utility method for converting a search path string to an array
+ * of directory and JAR file URLs.
+ *
+ * Note that this method is called by apt and the DocletInvoker.
+ *
+ * @param path the search path string
+ * @return the resulting array of directory and JAR file URLs
+ */
+ public static URL[] pathToURLs(String path) {
+ StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
+ URL[] urls = new URL[st.countTokens()];
+ int count = 0;
+ while (st.hasMoreTokens()) {
+ URL url = fileToURL(new File(st.nextToken()));
+ if (url != null) {
+ urls[count++] = url;
+ }
+ }
+ if (urls.length != count) {
+ URL[] tmp = new URL[count];
+ System.arraycopy(urls, 0, tmp, 0, count);
+ urls = tmp;
+ }
+ return urls;
+ }
+
+ /**
+ * Returns the directory or JAR file URL corresponding to the specified
+ * local file name.
+ *
+ * @param file the File object
+ * @return the resulting directory or JAR file URL, or null if unknown
+ */
+ private static URL fileToURL(File file) {
+ String name;
+ try {
+ name = file.getCanonicalPath();
+ } catch (IOException e) {
+ name = file.getAbsolutePath();
+ }
+ name = name.replace(File.separatorChar, '/');
+ if (!name.startsWith("/")) {
+ name = "/" + name;
+ }
+ // If the file does not exist, then assume that it's a directory
+ if (!file.isFile()) {
+ name = name + "/";
+ }
+ try {
+ return new URL("file", "", name);
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(file.toString());
+ }
+ }
}
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Feb 23 10:17:51 2010 -0800
@@ -25,7 +25,6 @@
package com.sun.tools.javac.processing;
-
import java.lang.reflect.*;
import java.util.*;
import java.util.regex.*;
@@ -874,20 +873,9 @@
JavaFileManager fileManager = currentContext.get(JavaFileManager.class);
- List<JavaFileObject> fileObjects = List.nil();
- for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) {
- fileObjects = fileObjects.prepend(jfo);
- }
-
-
compiler = JavaCompiler.instance(currentContext);
- List<JCCompilationUnit> parsedFiles = compiler.parseFiles(fileObjects);
- roots = cleanTrees(roots).reverse();
-
-
- for (JCCompilationUnit unit : parsedFiles)
- roots = roots.prepend(unit);
- roots = roots.reverse();
+ List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler);
+ roots = cleanTrees(roots).appendList(parsedFiles);
// Check for errors after parsing
if (compiler.parseErrors()) {
@@ -921,11 +909,16 @@
break runAround; // No new files
}
}
- runLastRound(xout, roundNumber, errorStatus, taskListener);
+ roots = runLastRound(xout, roundNumber, errorStatus, compiler, roots, taskListener);
+ // Set error status for any files compiled and generated in
+ // the last round
+ if (compiler.parseErrors())
+ errorStatus = true;
compiler.close(false);
currentContext = contextForNextRound(currentContext, true);
compiler = JavaCompiler.instance(currentContext);
+
filer.newRound(currentContext, true);
filer.warnIfUnclosedFiles();
warnIfUnmatchedOptions();
@@ -979,10 +972,22 @@
return compiler;
}
+ private List<JCCompilationUnit> sourcesToParsedFiles(JavaCompiler compiler)
+ throws IOException {
+ List<JavaFileObject> fileObjects = List.nil();
+ for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) {
+ fileObjects = fileObjects.prepend(jfo);
+ }
+
+ return compiler.parseFiles(fileObjects);
+ }
+
// Call the last round of annotation processing
- private void runLastRound(PrintWriter xout,
- int roundNumber,
- boolean errorStatus,
+ private List<JCCompilationUnit> runLastRound(PrintWriter xout,
+ int roundNumber,
+ boolean errorStatus,
+ JavaCompiler compiler,
+ List<JCCompilationUnit> roots,
TaskListener taskListener) throws IOException {
roundNumber++;
List<ClassSymbol> noTopLevelClasses = List.nil();
@@ -1003,6 +1008,15 @@
if (taskListener != null)
taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
}
+
+ // Add any sources generated during the last round to the set
+ // of files to be compiled.
+ if (moreToDo()) {
+ List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler);
+ roots = cleanTrees(roots).appendList(parsedFiles);
+ }
+
+ return roots;
}
private void updateProcessingState(Context currentContext, boolean lastRound) {
@@ -1340,115 +1354,62 @@
return specifiedPackages;
}
- // Borrowed from DocletInvoker and apt
- // TODO: remove from apt's Main
+ private static final Pattern allMatches = Pattern.compile(".*");
+ public static final Pattern noMatches = Pattern.compile("(\\P{all})+");
+
/**
- * Utility method for converting a search path string to an array
- * of directory and JAR file URLs.
- *
- * @param path the search path string
- * @return the resulting array of directory and JAR file URLs
+ * Convert import-style string for supported annotations into a
+ * regex matching that string. If the string is a valid
+ * import-style string, return a regex that won't match anything.
*/
- public static URL[] pathToURLs(String path) {
- StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
- URL[] urls = new URL[st.countTokens()];
- int count = 0;
- while (st.hasMoreTokens()) {
- URL url = fileToURL(new File(st.nextToken()));
- if (url != null) {
- urls[count++] = url;
- }
+ private static Pattern importStringToPattern(String s, Processor p, Log log) {
+ if (isValidImportString(s)) {
+ return validImportStringToPattern(s);
+ } else {
+ log.warning("proc.malformed.supported.string", s, p.getClass().getName());
+ return noMatches; // won't match any valid identifier
}
- if (urls.length != count) {
- URL[] tmp = new URL[count];
- System.arraycopy(urls, 0, tmp, 0, count);
- urls = tmp;
- }
- return urls;
}
/**
- * Returns the directory or JAR file URL corresponding to the specified
- * local file name.
- *
- * @param file the File object
- * @return the resulting directory or JAR file URL, or null if unknown
+ * Return true if the argument string is a valid import-style
+ * string specifying claimed annotations; return false otherwise.
*/
- private static URL fileToURL(File file) {
- String name;
- try {
- name = file.getCanonicalPath();
- } catch (IOException e) {
- name = file.getAbsolutePath();
+ public static boolean isValidImportString(String s) {
+ if (s.equals("*"))
+ return true;
+
+ boolean valid = true;
+ String t = s;
+ int index = t.indexOf('*');
+
+ if (index != -1) {
+ // '*' must be last character...
+ if (index == t.length() -1) {
+ // ... any and preceding character must be '.'
+ if ( index-1 >= 0 ) {
+ valid = t.charAt(index-1) == '.';
+ // Strip off ".*$" for identifier checks
+ t = t.substring(0, t.length()-2);
+ }
+ } else
+ return false;
}
- name = name.replace(File.separatorChar, '/');
- if (!name.startsWith("/")) {
- name = "/" + name;
+
+ // Verify string is off the form (javaId \.)+ or javaId
+ if (valid) {
+ String[] javaIds = t.split("\\.", t.length()+2);
+ for(String javaId: javaIds)
+ valid &= SourceVersion.isIdentifier(javaId);
}
- // If the file does not exist, then assume that it's a directory
- if (!file.isFile()) {
- name = name + "/";
- }
- try {
- return new URL("file", "", name);
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException("file");
- }
+ return valid;
}
-
-
- private static final Pattern allMatches = Pattern.compile(".*");
-
- private static final Pattern noMatches = Pattern.compile("(\\P{all})+");
- /**
- * Convert import-style string to regex matching that string. If
- * the string is a valid import-style string, return a regex that
- * won't match anything.
- */
- // TODO: remove version in Apt.java
- public static Pattern importStringToPattern(String s, Processor p, Log log) {
+ public static Pattern validImportStringToPattern(String s) {
if (s.equals("*")) {
return allMatches;
} else {
- String t = s;
- boolean star = false;
-
- /*
- * Validate string from factory is legal. If the string
- * has more than one asterisks or the asterisks does not
- * appear as the last character (preceded by a period),
- * the string is not legal.
- */
-
- boolean valid = true;
- int index = t.indexOf('*');
- if (index != -1) {
- // '*' must be last character...
- if (index == t.length() -1) {
- // ... and preceeding character must be '.'
- if ( index-1 >= 0 ) {
- valid = t.charAt(index-1) == '.';
- // Strip off ".*$" for identifier checks
- t = t.substring(0, t.length()-2);
- }
- } else
- valid = false;
- }
-
- // Verify string is off the form (javaId \.)+ or javaId
- if (valid) {
- String[] javaIds = t.split("\\.", t.length()+2);
- for(String javaId: javaIds)
- valid &= SourceVersion.isIdentifier(javaId);
- }
-
- if (!valid) {
- log.warning("proc.malformed.supported.string", s, p.getClass().getName());
- return noMatches; // won't match any valid identifier
- }
-
- String s_prime = s.replaceAll("\\.", "\\\\.");
+ String s_prime = s.replace(".", "\\.");
if (s_prime.endsWith("*")) {
s_prime = s_prime.substring(0, s_prime.length() - 1) + ".+";
--- a/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java Tue Feb 23 10:17:51 2010 -0800
@@ -81,7 +81,7 @@
cpString = appendPath(System.getProperty("env.class.path"), cpString);
cpString = appendPath(System.getProperty("java.class.path"), cpString);
cpString = appendPath(docletPath, cpString);
- URL[] urls = pathToURLs(cpString);
+ URL[] urls = com.sun.tools.javac.file.Paths.pathToURLs(cpString);
if (docletParentClassLoader == null)
appClassLoader = new URLClassLoader(urls, getDelegationClassLoader(docletClassName));
else
@@ -313,58 +313,4 @@
Thread.currentThread().setContextClassLoader(savedCCL);
}
}
-
- /**
- * Utility method for converting a search path string to an array
- * of directory and JAR file URLs.
- *
- * @param path the search path string
- * @return the resulting array of directory and JAR file URLs
- */
- static URL[] pathToURLs(String path) {
- StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
- URL[] urls = new URL[st.countTokens()];
- int count = 0;
- while (st.hasMoreTokens()) {
- URL url = fileToURL(new File(st.nextToken()));
- if (url != null) {
- urls[count++] = url;
- }
- }
- if (urls.length != count) {
- URL[] tmp = new URL[count];
- System.arraycopy(urls, 0, tmp, 0, count);
- urls = tmp;
- }
- return urls;
- }
-
- /**
- * Returns the directory or JAR file URL corresponding to the specified
- * local file name.
- *
- * @param file the File object
- * @return the resulting directory or JAR file URL, or null if unknown
- */
- static URL fileToURL(File file) {
- String name;
- try {
- name = file.getCanonicalPath();
- } catch (IOException e) {
- name = file.getAbsolutePath();
- }
- name = name.replace(File.separatorChar, '/');
- if (!name.startsWith("/")) {
- name = "/" + name;
- }
- // If the file does not exist, then assume that it's a directory
- if (!file.isFile()) {
- name = name + "/";
- }
- try {
- return new URL("file", "", name);
- } catch (MalformedURLException e) {
- throw new IllegalArgumentException("file");
- }
- }
}
--- a/langtools/test/tools/javac/6341866/Anno.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/6341866/Anno.java Tue Feb 23 10:17:51 2010 -0800
@@ -27,7 +27,6 @@
import javax.lang.model.element.*;
@SupportedAnnotationTypes("*")
- @SupportedSourceVersion(SourceVersion.RELEASE_7)
public class Anno extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
@@ -35,4 +34,9 @@
// System.err.println("annotation processing");
return true;
}
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
--- a/langtools/test/tools/javac/EarlyAssert.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/EarlyAssert.java Tue Feb 23 10:17:51 2010 -0800
@@ -27,6 +27,8 @@
* @summary Verify that assertions are enabled before the class is initialized
* and not thereafter
* @author gafter
+ * @build EarlyAssert EarlyAssertWrapper
+ * @run main EarlyAssertWrapper
*/
/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/EarlyAssertWrapper.java Tue Feb 23 10:17:51 2010 -0800
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.io.*;
+import java.util.*;
+
+/*
+ * Wrapper for the EarlyAssert test to run the test in a JVM without assertions
+ * enabled.
+ */
+public class EarlyAssertWrapper {
+ public static void main(String... args) throws Exception {
+ EarlyAssertWrapper w = new EarlyAssertWrapper();
+ w.run();
+ }
+
+ void run() throws Exception {
+ List<String> cmd = new ArrayList<String>();
+ File java_home = new File(System.getProperty("java.home"));
+ if (java_home.getName().equals("jre"))
+ java_home = java_home.getParentFile();
+ cmd.add(new File(new File(java_home, "bin"), "java").getPath());
+
+ // ensure we run with the same bootclasspath as this test,
+ // in case this test is being run with -Xbootclasspath
+ cmd.add("-Xbootclasspath:" + System.getProperty("sun.boot.class.path"));
+
+ // propogate classpath
+ cmd.add("-classpath");
+ cmd.add(System.getProperty("java.class.path"));
+
+ // ensure all assertions disabled in target VM
+ cmd.add("-da");
+ cmd.add("-dsa");
+
+ cmd.add("EarlyAssert");
+
+ System.err.println("Running command: " + cmd);
+
+ ProcessBuilder pb = new ProcessBuilder(cmd);
+ pb.redirectErrorStream(true);
+ Process p = pb.start();
+ p.getOutputStream().close();
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ String line;
+ DataInputStream in = new DataInputStream(p.getInputStream());
+ try {
+ while ((line = in.readLine()) != null)
+ pw.println(line);
+ } finally {
+ in.close();
+ }
+ pw.close();
+
+ String out = sw.toString();
+ int rc = p.waitFor();
+ if (rc != 0 || out.length() > 0)
+ throw new Error("failed: rc=" + rc + (out.length() > 0 ? ": " + out : ""));
+ }
+}
--- a/langtools/test/tools/javac/T6403466.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/T6403466.java Tue Feb 23 10:17:51 2010 -0800
@@ -41,7 +41,6 @@
@Wrap
@SupportedAnnotationTypes("Wrap")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class T6403466 extends AbstractProcessor {
static final String testSrcDir = System.getProperty("test.src");
@@ -73,24 +72,31 @@
}
public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
- Filer filer = processingEnv.getFiler();
- for (TypeElement anno: annos) {
- Set<? extends Element> elts = rEnv.getElementsAnnotatedWith(anno);
- System.err.println("anno: " + anno);
- System.err.println("elts: " + elts);
- for (TypeElement te: ElementFilter.typesIn(elts)) {
- try {
- Writer out = filer.createSourceFile(te.getSimpleName() + "Wrapper").openWriter();
- out.write("class " + te.getSimpleName() + "Wrapper { }");
- out.close();
- } catch (IOException ex) {
- ex.printStackTrace();
+ if (!rEnv.processingOver()) {
+ Filer filer = processingEnv.getFiler();
+ for (TypeElement anno: annos) {
+ Set<? extends Element> elts = rEnv.getElementsAnnotatedWith(anno);
+ System.err.println("anno: " + anno);
+ System.err.println("elts: " + elts);
+ for (TypeElement te: ElementFilter.typesIn(elts)) {
+ try {
+ Writer out = filer.createSourceFile(te.getSimpleName() + "Wrapper").openWriter();
+ out.write("class " + te.getSimpleName() + "Wrapper { }");
+ out.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
}
+
}
-
}
return true;
}
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
@Retention(RetentionPolicy.SOURCE)
--- a/langtools/test/tools/javac/T6406771.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/T6406771.java Tue Feb 23 10:17:51 2010 -0800
@@ -17,7 +17,7 @@
import com.sun.source.util.*;
import com.sun.tools.javac.tree.JCTree;
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
+
@SupportedAnnotationTypes("*")
public class T6406771 extends AbstractProcessor {
String[] tests = {
@@ -95,4 +95,8 @@
return true;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
--- a/langtools/test/tools/javac/T6411379.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/T6411379.java Tue Feb 23 10:17:51 2010 -0800
@@ -37,7 +37,6 @@
import com.sun.source.util.*;
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class T6411379 extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annoElems,
@@ -58,6 +57,11 @@
return true;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
public void checkNull(Object o) {
if (o != null)
throw new AssertionError("expected null");
--- a/langtools/test/tools/javac/T6423583.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/T6423583.java Tue Feb 23 10:17:51 2010 -0800
@@ -37,7 +37,6 @@
import com.sun.source.util.*;
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class T6423583 extends AbstractProcessor {
boolean b1 = true;
boolean b2 = false;
@@ -59,6 +58,10 @@
return true;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
private static class Test extends TreeScanner<Void,Void> {
--- a/langtools/test/tools/javac/T6855236.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/T6855236.java Tue Feb 23 10:17:51 2010 -0800
@@ -38,7 +38,6 @@
import com.sun.source.tree.*;
import com.sun.source.util.*;
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
public class T6855236 extends AbstractProcessor {
@@ -63,6 +62,11 @@
return true;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
class CodeVisitor extends TreePathScanner<Object, Trees> {
@Override
--- a/langtools/test/tools/javac/api/6421111/T6421111.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/api/6421111/T6421111.java Tue Feb 23 10:17:51 2010 -0800
@@ -76,7 +76,6 @@
throw new AssertionError("Annotation processor failed");
}
@SupportedAnnotationTypes("*")
- @SupportedSourceVersion(SourceVersion.RELEASE_6)
static class MyProcessor extends AbstractProcessor {
void test(TypeElement element, boolean fbound) {
TypeParameterElement tpe = element.getTypeParameters().iterator().next();
@@ -96,6 +95,10 @@
test(processingEnv.getElementUtils().getTypeElement("Test2"), true);
return false;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
public static void main(String... args) {
new T6421111().test(args);
--- a/langtools/test/tools/javac/api/6468404/T6468404.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/api/6468404/T6468404.java Tue Feb 23 10:17:51 2010 -0800
@@ -105,7 +105,6 @@
}
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
class P extends AbstractProcessor {
boolean ran = false;
@@ -145,4 +144,9 @@
}
return true;
}
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
--- a/langtools/test/tools/javac/api/T6412669.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/api/T6412669.java Tue Feb 23 10:17:51 2010 -0800
@@ -38,7 +38,6 @@
import com.sun.tools.javac.api.*;
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class T6412669 extends AbstractProcessor {
public static void main(String... args) throws IOException {
String testSrc = System.getProperty("test.src", ".");
@@ -72,4 +71,9 @@
}
return true;
}
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
--- a/langtools/test/tools/javac/enum/6424358/T6424358.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/enum/6424358/T6424358.java Tue Feb 23 10:17:51 2010 -0800
@@ -34,13 +34,12 @@
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import javax.lang.model.util.*;
+import javax.lang.model.SourceVersion;
import static javax.tools.Diagnostic.Kind.*;
-import static javax.lang.model.SourceVersion.RELEASE_6;
@interface TestMe {}
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(RELEASE_6)
public class T6424358 extends AbstractProcessor {
@TestMe enum Test { FOO; }
@@ -66,4 +65,9 @@
scan.scan(e);
return true;
}
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
--- a/langtools/test/tools/javac/processing/6348499/A.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/6348499/A.java Tue Feb 23 10:17:51 2010 -0800
@@ -28,7 +28,6 @@
import javax.lang.model.element.*;
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_7)
public class A extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
Filer filer = processingEnv.getFiler();
@@ -40,4 +39,8 @@
}
return true;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
--- a/langtools/test/tools/javac/processing/6414633/A.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/6414633/A.java Tue Feb 23 10:17:51 2010 -0800
@@ -30,7 +30,6 @@
import javax.tools.*;
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_7)
public class A extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
@@ -42,4 +41,9 @@
}
return true;
}
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
--- a/langtools/test/tools/javac/processing/6430209/T6430209.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/6430209/T6430209.java Tue Feb 23 10:17:51 2010 -0800
@@ -63,7 +63,6 @@
new File(testSrc, "test0.java"), new File(testSrc, "test1.java")));
Iterable<String> opts = Arrays.asList("-proc:only",
"-processor", "b6341534",
- "-source", "1.6",
"-processorpath", testClasses);
StringWriter out = new StringWriter();
JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
--- a/langtools/test/tools/javac/processing/6430209/b6341534.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/6430209/b6341534.java Tue Feb 23 10:17:51 2010 -0800
@@ -22,6 +22,7 @@
*/
import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
import javax.lang.model.element.*;
import javax.lang.model.util.*;
import static javax.lang.model.util.ElementFilter.*;
@@ -30,7 +31,6 @@
import java.util.Set;
@SupportedAnnotationTypes({"*"})
-@SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_7)
public class b6341534 extends AbstractProcessor {
static int r = 0;
static Elements E = null;
@@ -62,4 +62,9 @@
if( renv.errorRaised() ) { msgr.printMessage(ERROR, "FAILED");}
return true;
}
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/6634138/Dummy.java Tue Feb 23 10:17:51 2010 -0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * A dummy class to be compiled.
+ */
+public class Dummy {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/6634138/ExerciseDependency.java Tue Feb 23 10:17:51 2010 -0800
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * Class to exercise dependencies on the two source files generated by
+ * T6634138.java, foo.WrittenAfterProcessing.java and
+ * foo.package-info.java.
+ */
+public class ExerciseDependency {
+ public static void main(String... args) {
+ foo.WrittenAfterProcessing wap = new foo.WrittenAfterProcessing();
+ java.lang.Package pkg = wap.getClass().getPackage();
+ Deprecated d = pkg.getAnnotation(Deprecated.class);
+ if (d == null)
+ throw new RuntimeException();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/6634138/T6634138.java Tue Feb 23 10:17:51 2010 -0800
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6634138
+ * @author Joseph D. Darcy
+ * @summary Verify source files output after processing is over are compiled
+ * @compile T6634138.java
+ * @compile -processor T6634138 Dummy.java
+ * @run main ExerciseDependency
+ */
+
+import java.lang.annotation.Annotation;
+import java.io.*;
+import java.util.Collections;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+
+@SupportedAnnotationTypes("*")
+public class T6634138 extends AbstractProcessor {
+ private Filer filer;
+
+ public boolean process(Set<? extends TypeElement> annotations,
+ RoundEnvironment roundEnvironment) {
+ // Write out files *after* processing is over.
+ if (roundEnvironment.processingOver()) {
+ System.out.println("Writing out source files.");
+ try {
+ PrintWriter pw = new PrintWriter(filer.createSourceFile("foo.WrittenAfterProcessing").openWriter());
+ try {
+ pw.println("package foo;");
+ pw.println("public class WrittenAfterProcessing {");
+ pw.println(" public WrittenAfterProcessing() {super();}");
+ pw.println("}");
+ } finally {
+ pw.close();
+ }
+
+ pw = new PrintWriter(filer.createSourceFile("foo.package-info").openWriter());
+ try {
+ pw.println("@Deprecated");
+ pw.println("package foo;");
+ } finally {
+ pw.close();
+ }
+ } catch(IOException io) {
+ throw new RuntimeException(io);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
+ public void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ filer = processingEnv.getFiler();
+ }
+}
+
+
+
--- a/langtools/test/tools/javac/processing/T6439826.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/T6439826.java Tue Feb 23 10:17:51 2010 -0800
@@ -39,7 +39,6 @@
@SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_7 )
public class T6439826 extends AbstractProcessor {
public static void main(String... args) {
String testSrc = System.getProperty("test.src", ".");
@@ -76,6 +75,11 @@
return false;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
private void writeBadFile() {
Filer filer = processingEnv.getFiler();
Messager messager = processingEnv.getMessager();
--- a/langtools/test/tools/javac/processing/model/element/TypeParamBounds.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/model/element/TypeParamBounds.java Tue Feb 23 10:17:51 2010 -0800
@@ -40,7 +40,6 @@
import javax.lang.model.type.*;
import javax.lang.model.util.*;
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
public class TypeParamBounds extends AbstractProcessor {
@@ -60,6 +59,11 @@
return true;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen");
--- a/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java Tue Feb 23 10:17:51 2010 -0800
@@ -38,7 +38,6 @@
import javax.lang.model.util.*;
import static javax.lang.model.util.ElementFilter.*;
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("IAm")
@IAm(OverEager.class)
public class OverEager extends AbstractProcessor {
@@ -59,6 +58,11 @@
return true;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
for (TypeElement t : typesIn(round.getRootElements())) {
--- a/langtools/test/tools/javac/processing/model/type/NoTypes.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/model/type/NoTypes.java Tue Feb 23 10:17:51 2010 -0800
@@ -39,8 +39,6 @@
import static javax.lang.model.type.TypeKind.*;
-
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
public class NoTypes extends AbstractProcessor {
@@ -60,6 +58,11 @@
return true;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
--- a/langtools/test/tools/javac/processing/model/util/GetTypeElemBadArg.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/model/util/GetTypeElemBadArg.java Tue Feb 23 10:17:51 2010 -0800
@@ -37,7 +37,6 @@
import javax.lang.model.type.*;
import javax.lang.model.util.*;
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
public class GetTypeElemBadArg extends AbstractProcessor {
@@ -64,6 +63,12 @@
return true;
}
+
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
private static void tellAbout(TypeElement t) {
System.out.println(t);
System.out.println(t.getClass());
--- a/langtools/test/tools/javac/processing/model/util/OverridesSpecEx.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/processing/model/util/OverridesSpecEx.java Tue Feb 23 10:17:51 2010 -0800
@@ -40,7 +40,6 @@
import static javax.lang.model.util.ElementFilter.*;
-@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedAnnotationTypes("*")
public class OverridesSpecEx extends AbstractProcessor {
@@ -60,6 +59,11 @@
return true;
}
+ @Override
+ public SourceVersion getSupportedSourceVersion() {
+ return SourceVersion.latest();
+ }
+
private void doit(Set<? extends TypeElement> annoTypes,
RoundEnvironment round) {
TypeElement string = elements.getTypeElement("java.lang.String");
--- a/langtools/test/tools/javac/treepostests/TreePosTest.java Thu Feb 18 13:31:57 2010 -0800
+++ b/langtools/test/tools/javac/treepostests/TreePosTest.java Tue Feb 23 10:17:51 2010 -0800
@@ -98,7 +98,7 @@
* @test
* @bug 6919889
* @summary assorted position errors in compiler syntax trees
- * @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations .
+ * @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations -et ANNOTATED_TYPE .
*/
public class TreePosTest {
/**
@@ -150,6 +150,8 @@
tags.add(args[++i]);
else if (arg.equals("-ef") && i + 1 < args.length)
excludeFiles.add(new File(baseDir, args[++i]));
+ else if (arg.equals("-et") && i + 1 < args.length)
+ excludeTags.add(args[++i]);
else if (arg.equals("-r")) {
if (excludeFiles.size() > 0)
throw new Error("-r must be used before -ef");
@@ -199,6 +201,7 @@
out.println("-t tag Limit checks to tree nodes with this tag");
out.println(" Can be repeated if desired");
out.println("-ef file Exclude file or directory");
+ out.println("-et tag Exclude tree nodes with given tag name");
out.println("");
out.println("files may be directories or files");
out.println("directories will be scanned recursively");
@@ -304,6 +307,8 @@
Set<String> tags = new HashSet<String>();
/** Set of files and directories to be excluded from analysis. */
Set<File> excludeFiles = new HashSet<File>();
+ /** Set of tag names to be excluded from analysis. */
+ Set<String> excludeTags = new HashSet<String>();
/** Table of printable names for tree tag values. */
TagNames tagNames = new TagNames();
@@ -324,7 +329,7 @@
return;
Info self = new Info(tree, endPosTable);
- if (check(self)) {
+ if (check(encl, self)) {
// Modifiers nodes are present throughout the tree even where
// there is no corresponding source text.
// Redundant semicolons in a class definition can cause empty
@@ -392,8 +397,13 @@
super.visitVarDef(tree);
}
- boolean check(Info x) {
- return tags.size() == 0 || tags.contains(tagNames.get(x.tag));
+ boolean check(Info encl, Info self) {
+ if (excludeTags.size() > 0) {
+ if (encl != null && excludeTags.contains(tagNames.get(encl.tag))
+ || excludeTags.contains(tagNames.get(self.tag)))
+ return false;
+ }
+ return tags.size() == 0 || tags.contains(tagNames.get(self.tag));
}
void check(String label, Info encl, Info self, boolean ok) {