Merge jdk7-b85

Tue, 23 Feb 2010 10:17:51 -0800

author
lana
date
Tue, 23 Feb 2010 10:17:51 -0800
changeset 502
136bfc679462
parent 492
75d5bd12eb86
parent 501
f25efdb55c99
child 503
b816baf594e3
child 518
c55733ceed61

Merge

     1.1 --- a/make/Makefile	Thu Feb 18 13:31:57 2010 -0800
     1.2 +++ b/make/Makefile	Tue Feb 23 10:17:51 2010 -0800
     1.3 @@ -70,7 +70,7 @@
     1.4  endif
     1.5  
     1.6  ifdef VERBOSE
     1.7 -  ANT_OPTIONS += -verbose -diagnostics
     1.8 +  ANT_OPTIONS += -verbose -debug
     1.9  endif
    1.10  
    1.11  ifdef JDK_VERSION
     2.1 --- a/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java	Thu Feb 18 13:31:57 2010 -0800
     2.2 +++ b/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java	Tue Feb 23 10:17:51 2010 -0800
     2.3 @@ -101,7 +101,11 @@
     2.4          }
     2.5          @SuppressWarnings("cast")
     2.6          private int compareEqualPosition(Declaration d1, Declaration d2) {
     2.7 -            assert d1.getPosition() == d2.getPosition();
     2.8 +            assert
     2.9 +                (d1.getPosition() == d2.getPosition()) || // Handles two null positions.
    2.10 +                (d1.getPosition().file().compareTo(d2.getPosition().file()) == 0 &&
    2.11 +                 d1.getPosition().line()   == d2.getPosition().line() &&
    2.12 +                 d1.getPosition().column() == d2.getPosition().column());
    2.13  
    2.14              DeclPartialOrder dpo1 = new DeclPartialOrder();
    2.15              DeclPartialOrder dpo2 = new DeclPartialOrder();
     3.1 --- a/src/share/classes/com/sun/tools/apt/comp/Apt.java	Thu Feb 18 13:31:57 2010 -0800
     3.2 +++ b/src/share/classes/com/sun/tools/apt/comp/Apt.java	Tue Feb 23 10:17:51 2010 -0800
     3.3 @@ -496,57 +496,12 @@
     3.4       * won't match anything.
     3.5       */
     3.6      Pattern importStringToPattern(String s) {
     3.7 -        if (s.equals("*")) {
     3.8 -            return allMatches;
     3.9 +        if (com.sun.tools.javac.processing.JavacProcessingEnvironment.isValidImportString(s)) {
    3.10 +            return com.sun.tools.javac.processing.JavacProcessingEnvironment.validImportStringToPattern(s);
    3.11          } else {
    3.12 -            String t = s;
    3.13 -            boolean star = false;
    3.14 -
    3.15 -            /*
    3.16 -             * Validate string from factory is legal.  If the string
    3.17 -             * has more than one asterisks or the asterisks does not
    3.18 -             * appear as the last character (preceded by a period),
    3.19 -             * the string is not legal.
    3.20 -             */
    3.21 -
    3.22 -            boolean valid = true;
    3.23 -            int index = t.indexOf('*');
    3.24 -            if (index != -1) {
    3.25 -                // '*' must be last character...
    3.26 -                if (index == t.length() -1) {
    3.27 -                     // ... and preceeding character must be '.'
    3.28 -                    if ( index-1 >= 0 ) {
    3.29 -                        valid = t.charAt(index-1) == '.';
    3.30 -                        // Strip off ".*$" for identifier checks
    3.31 -                        t = t.substring(0, t.length()-2);
    3.32 -                    }
    3.33 -                } else
    3.34 -                    valid = false;
    3.35 -            }
    3.36 -
    3.37 -            // Verify string is off the form (javaId \.)+ or javaId
    3.38 -            if (valid) {
    3.39 -                String[] javaIds = t.split("\\.", t.length()+2);
    3.40 -                for(String javaId: javaIds)
    3.41 -                    valid &= isJavaIdentifier(javaId);
    3.42 -            }
    3.43 -
    3.44 -            if (!valid) {
    3.45 -                Bark bark = Bark.instance(context);
    3.46 -                bark.aptWarning("MalformedSupportedString", s);
    3.47 -                return noMatches; // won't match any valid identifier
    3.48 -            }
    3.49 -
    3.50 -            String s_prime = s.replaceAll("\\.", "\\\\.");
    3.51 -
    3.52 -            if (s_prime.endsWith("*")) {
    3.53 -                s_prime =  s_prime.substring(0, s_prime.length() - 1) + ".+";
    3.54 -            }
    3.55 -
    3.56 -            return Pattern.compile(s_prime);
    3.57 +            Bark bark = Bark.instance(context);
    3.58 +            bark.aptWarning("MalformedSupportedString", s);
    3.59 +            return com.sun.tools.javac.processing.JavacProcessingEnvironment.noMatches;
    3.60          }
    3.61      }
    3.62 -
    3.63 -    private static final Pattern allMatches = Pattern.compile(".*");
    3.64 -    private static final Pattern noMatches  = Pattern.compile("(\\P{all})+");
    3.65  }
     4.1 --- a/src/share/classes/com/sun/tools/apt/main/Main.java	Thu Feb 18 13:31:57 2010 -0800
     4.2 +++ b/src/share/classes/com/sun/tools/apt/main/Main.java	Tue Feb 23 10:17:51 2010 -0800
     4.3 @@ -56,6 +56,8 @@
     4.4  import com.sun.tools.apt.util.Bark;
     4.5  import com.sun.mirror.apt.AnnotationProcessorFactory;
     4.6  
     4.7 +import static com.sun.tools.javac.file.Paths.pathToURLs;
     4.8 +
     4.9  /** This class provides a commandline interface to the apt build-time
    4.10   *  tool.
    4.11   *
    4.12 @@ -1276,59 +1278,4 @@
    4.13              }
    4.14          }
    4.15      }
    4.16 -
    4.17 -    // Borrowed from DocletInvoker
    4.18 -    /**
    4.19 -     * Utility method for converting a search path string to an array
    4.20 -     * of directory and JAR file URLs.
    4.21 -     *
    4.22 -     * @param path the search path string
    4.23 -     * @return the resulting array of directory and JAR file URLs
    4.24 -     */
    4.25 -    static URL[] pathToURLs(String path) {
    4.26 -        StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
    4.27 -        URL[] urls = new URL[st.countTokens()];
    4.28 -        int count = 0;
    4.29 -        while (st.hasMoreTokens()) {
    4.30 -            URL url = fileToURL(new File(st.nextToken()));
    4.31 -            if (url != null) {
    4.32 -                urls[count++] = url;
    4.33 -            }
    4.34 -        }
    4.35 -        if (urls.length != count) {
    4.36 -            URL[] tmp = new URL[count];
    4.37 -            System.arraycopy(urls, 0, tmp, 0, count);
    4.38 -            urls = tmp;
    4.39 -        }
    4.40 -        return urls;
    4.41 -    }
    4.42 -
    4.43 -    /**
    4.44 -     * Returns the directory or JAR file URL corresponding to the specified
    4.45 -     * local file name.
    4.46 -     *
    4.47 -     * @param file the File object
    4.48 -     * @return the resulting directory or JAR file URL, or null if unknown
    4.49 -     */
    4.50 -    static URL fileToURL(File file) {
    4.51 -        String name;
    4.52 -        try {
    4.53 -            name = file.getCanonicalPath();
    4.54 -        } catch (IOException e) {
    4.55 -            name = file.getAbsolutePath();
    4.56 -        }
    4.57 -        name = name.replace(File.separatorChar, '/');
    4.58 -        if (!name.startsWith("/")) {
    4.59 -            name = "/" + name;
    4.60 -        }
    4.61 -        // If the file does not exist, then assume that it's a directory
    4.62 -        if (!file.isFile()) {
    4.63 -            name = name + "/";
    4.64 -        }
    4.65 -        try {
    4.66 -            return new URL("file", "", name);
    4.67 -        } catch (MalformedURLException e) {
    4.68 -            throw new IllegalArgumentException("file");
    4.69 -        }
    4.70 -    }
    4.71  }
     5.1 --- a/src/share/classes/com/sun/tools/javac/file/Paths.java	Thu Feb 18 13:31:57 2010 -0800
     5.2 +++ b/src/share/classes/com/sun/tools/javac/file/Paths.java	Tue Feb 23 10:17:51 2010 -0800
     5.3 @@ -27,6 +27,8 @@
     5.4  
     5.5  import java.io.File;
     5.6  import java.io.IOException;
     5.7 +import java.net.MalformedURLException;
     5.8 +import java.net.URL;
     5.9  import java.util.HashMap;
    5.10  import java.util.HashSet;
    5.11  import java.util.Map;
    5.12 @@ -34,6 +36,7 @@
    5.13  import java.util.Collection;
    5.14  import java.util.Collections;
    5.15  import java.util.LinkedHashSet;
    5.16 +import java.util.StringTokenizer;
    5.17  import java.util.zip.ZipFile;
    5.18  import javax.tools.JavaFileManager.Location;
    5.19  
    5.20 @@ -449,4 +452,60 @@
    5.21          return fsInfo.isFile(file)
    5.22              && (n.endsWith(".jar") || n.endsWith(".zip"));
    5.23      }
    5.24 +
    5.25 +    /**
    5.26 +     * Utility method for converting a search path string to an array
    5.27 +     * of directory and JAR file URLs.
    5.28 +     *
    5.29 +     * Note that this method is called by apt and the DocletInvoker.
    5.30 +     *
    5.31 +     * @param path the search path string
    5.32 +     * @return the resulting array of directory and JAR file URLs
    5.33 +     */
    5.34 +    public static URL[] pathToURLs(String path) {
    5.35 +        StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
    5.36 +        URL[] urls = new URL[st.countTokens()];
    5.37 +        int count = 0;
    5.38 +        while (st.hasMoreTokens()) {
    5.39 +            URL url = fileToURL(new File(st.nextToken()));
    5.40 +            if (url != null) {
    5.41 +                urls[count++] = url;
    5.42 +            }
    5.43 +        }
    5.44 +        if (urls.length != count) {
    5.45 +            URL[] tmp = new URL[count];
    5.46 +            System.arraycopy(urls, 0, tmp, 0, count);
    5.47 +            urls = tmp;
    5.48 +        }
    5.49 +        return urls;
    5.50 +    }
    5.51 +
    5.52 +    /**
    5.53 +     * Returns the directory or JAR file URL corresponding to the specified
    5.54 +     * local file name.
    5.55 +     *
    5.56 +     * @param file the File object
    5.57 +     * @return the resulting directory or JAR file URL, or null if unknown
    5.58 +     */
    5.59 +    private static URL fileToURL(File file) {
    5.60 +        String name;
    5.61 +        try {
    5.62 +            name = file.getCanonicalPath();
    5.63 +        } catch (IOException e) {
    5.64 +            name = file.getAbsolutePath();
    5.65 +        }
    5.66 +        name = name.replace(File.separatorChar, '/');
    5.67 +        if (!name.startsWith("/")) {
    5.68 +            name = "/" + name;
    5.69 +        }
    5.70 +        // If the file does not exist, then assume that it's a directory
    5.71 +        if (!file.isFile()) {
    5.72 +            name = name + "/";
    5.73 +        }
    5.74 +        try {
    5.75 +            return new URL("file", "", name);
    5.76 +        } catch (MalformedURLException e) {
    5.77 +            throw new IllegalArgumentException(file.toString());
    5.78 +        }
    5.79 +    }
    5.80  }
     6.1 --- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Feb 18 13:31:57 2010 -0800
     6.2 +++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Tue Feb 23 10:17:51 2010 -0800
     6.3 @@ -25,7 +25,6 @@
     6.4  
     6.5  package com.sun.tools.javac.processing;
     6.6  
     6.7 -
     6.8  import java.lang.reflect.*;
     6.9  import java.util.*;
    6.10  import java.util.regex.*;
    6.11 @@ -874,20 +873,9 @@
    6.12  
    6.13                      JavaFileManager fileManager = currentContext.get(JavaFileManager.class);
    6.14  
    6.15 -                    List<JavaFileObject> fileObjects = List.nil();
    6.16 -                    for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) {
    6.17 -                        fileObjects = fileObjects.prepend(jfo);
    6.18 -                    }
    6.19 -
    6.20 -
    6.21                      compiler = JavaCompiler.instance(currentContext);
    6.22 -                    List<JCCompilationUnit> parsedFiles = compiler.parseFiles(fileObjects);
    6.23 -                    roots = cleanTrees(roots).reverse();
    6.24 -
    6.25 -
    6.26 -                    for (JCCompilationUnit unit : parsedFiles)
    6.27 -                        roots = roots.prepend(unit);
    6.28 -                    roots = roots.reverse();
    6.29 +                    List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler);
    6.30 +                    roots = cleanTrees(roots).appendList(parsedFiles);
    6.31  
    6.32                      // Check for errors after parsing
    6.33                      if (compiler.parseErrors()) {
    6.34 @@ -921,11 +909,16 @@
    6.35                      break runAround; // No new files
    6.36              }
    6.37          }
    6.38 -        runLastRound(xout, roundNumber, errorStatus, taskListener);
    6.39 +        roots = runLastRound(xout, roundNumber, errorStatus, compiler, roots, taskListener);
    6.40 +        // Set error status for any files compiled and generated in
    6.41 +        // the last round
    6.42 +        if (compiler.parseErrors())
    6.43 +            errorStatus = true;
    6.44  
    6.45          compiler.close(false);
    6.46          currentContext = contextForNextRound(currentContext, true);
    6.47          compiler = JavaCompiler.instance(currentContext);
    6.48 +
    6.49          filer.newRound(currentContext, true);
    6.50          filer.warnIfUnclosedFiles();
    6.51          warnIfUnmatchedOptions();
    6.52 @@ -979,10 +972,22 @@
    6.53          return compiler;
    6.54      }
    6.55  
    6.56 +    private List<JCCompilationUnit> sourcesToParsedFiles(JavaCompiler compiler)
    6.57 +        throws IOException {
    6.58 +        List<JavaFileObject> fileObjects = List.nil();
    6.59 +        for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) {
    6.60 +            fileObjects = fileObjects.prepend(jfo);
    6.61 +        }
    6.62 +
    6.63 +       return compiler.parseFiles(fileObjects);
    6.64 +    }
    6.65 +
    6.66      // Call the last round of annotation processing
    6.67 -    private void runLastRound(PrintWriter xout,
    6.68 -                              int roundNumber,
    6.69 -                              boolean errorStatus,
    6.70 +    private List<JCCompilationUnit> runLastRound(PrintWriter xout,
    6.71 +                                                 int roundNumber,
    6.72 +                                                 boolean errorStatus,
    6.73 +                                                 JavaCompiler compiler,
    6.74 +                                                 List<JCCompilationUnit> roots,
    6.75                                TaskListener taskListener) throws IOException {
    6.76          roundNumber++;
    6.77          List<ClassSymbol> noTopLevelClasses = List.nil();
    6.78 @@ -1003,6 +1008,15 @@
    6.79              if (taskListener != null)
    6.80                  taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
    6.81          }
    6.82 +
    6.83 +        // Add any sources generated during the last round to the set
    6.84 +        // of files to be compiled.
    6.85 +        if (moreToDo()) {
    6.86 +            List<JCCompilationUnit> parsedFiles = sourcesToParsedFiles(compiler);
    6.87 +            roots = cleanTrees(roots).appendList(parsedFiles);
    6.88 +        }
    6.89 +
    6.90 +        return roots;
    6.91      }
    6.92  
    6.93      private void updateProcessingState(Context currentContext, boolean lastRound) {
    6.94 @@ -1340,115 +1354,62 @@
    6.95          return specifiedPackages;
    6.96      }
    6.97  
    6.98 -    // Borrowed from DocletInvoker and apt
    6.99 -    // TODO: remove from apt's Main
   6.100 +    private static final Pattern allMatches = Pattern.compile(".*");
   6.101 +    public static final Pattern noMatches  = Pattern.compile("(\\P{all})+");
   6.102 +
   6.103      /**
   6.104 -     * Utility method for converting a search path string to an array
   6.105 -     * of directory and JAR file URLs.
   6.106 -     *
   6.107 -     * @param path the search path string
   6.108 -     * @return the resulting array of directory and JAR file URLs
   6.109 +     * Convert import-style string for supported annotations into a
   6.110 +     * regex matching that string.  If the string is a valid
   6.111 +     * import-style string, return a regex that won't match anything.
   6.112       */
   6.113 -    public static URL[] pathToURLs(String path) {
   6.114 -        StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
   6.115 -        URL[] urls = new URL[st.countTokens()];
   6.116 -        int count = 0;
   6.117 -        while (st.hasMoreTokens()) {
   6.118 -            URL url = fileToURL(new File(st.nextToken()));
   6.119 -            if (url != null) {
   6.120 -                urls[count++] = url;
   6.121 -            }
   6.122 +    private static Pattern importStringToPattern(String s, Processor p, Log log) {
   6.123 +        if (isValidImportString(s)) {
   6.124 +            return validImportStringToPattern(s);
   6.125 +        } else {
   6.126 +            log.warning("proc.malformed.supported.string", s, p.getClass().getName());
   6.127 +            return noMatches; // won't match any valid identifier
   6.128          }
   6.129 -        if (urls.length != count) {
   6.130 -            URL[] tmp = new URL[count];
   6.131 -            System.arraycopy(urls, 0, tmp, 0, count);
   6.132 -            urls = tmp;
   6.133 -        }
   6.134 -        return urls;
   6.135      }
   6.136  
   6.137      /**
   6.138 -     * Returns the directory or JAR file URL corresponding to the specified
   6.139 -     * local file name.
   6.140 -     *
   6.141 -     * @param file the File object
   6.142 -     * @return the resulting directory or JAR file URL, or null if unknown
   6.143 +     * Return true if the argument string is a valid import-style
   6.144 +     * string specifying claimed annotations; return false otherwise.
   6.145       */
   6.146 -    private static URL fileToURL(File file) {
   6.147 -        String name;
   6.148 -        try {
   6.149 -            name = file.getCanonicalPath();
   6.150 -        } catch (IOException e) {
   6.151 -            name = file.getAbsolutePath();
   6.152 +    public static boolean isValidImportString(String s) {
   6.153 +        if (s.equals("*"))
   6.154 +            return true;
   6.155 +
   6.156 +        boolean valid = true;
   6.157 +        String t = s;
   6.158 +        int index = t.indexOf('*');
   6.159 +
   6.160 +        if (index != -1) {
   6.161 +            // '*' must be last character...
   6.162 +            if (index == t.length() -1) {
   6.163 +                // ... any and preceding character must be '.'
   6.164 +                if ( index-1 >= 0 ) {
   6.165 +                    valid = t.charAt(index-1) == '.';
   6.166 +                    // Strip off ".*$" for identifier checks
   6.167 +                    t = t.substring(0, t.length()-2);
   6.168 +                }
   6.169 +            } else
   6.170 +                return false;
   6.171          }
   6.172 -        name = name.replace(File.separatorChar, '/');
   6.173 -        if (!name.startsWith("/")) {
   6.174 -            name = "/" + name;
   6.175 +
   6.176 +        // Verify string is off the form (javaId \.)+ or javaId
   6.177 +        if (valid) {
   6.178 +            String[] javaIds = t.split("\\.", t.length()+2);
   6.179 +            for(String javaId: javaIds)
   6.180 +                valid &= SourceVersion.isIdentifier(javaId);
   6.181          }
   6.182 -        // If the file does not exist, then assume that it's a directory
   6.183 -        if (!file.isFile()) {
   6.184 -            name = name + "/";
   6.185 -        }
   6.186 -        try {
   6.187 -            return new URL("file", "", name);
   6.188 -        } catch (MalformedURLException e) {
   6.189 -            throw new IllegalArgumentException("file");
   6.190 -        }
   6.191 +        return valid;
   6.192      }
   6.193  
   6.194 -
   6.195 -
   6.196 -    private static final Pattern allMatches = Pattern.compile(".*");
   6.197 -
   6.198 -    private static final Pattern noMatches  = Pattern.compile("(\\P{all})+");
   6.199 -    /**
   6.200 -     * Convert import-style string to regex matching that string.  If
   6.201 -     * the string is a valid import-style string, return a regex that
   6.202 -     * won't match anything.
   6.203 -     */
   6.204 -    // TODO: remove version in Apt.java
   6.205 -    public static Pattern importStringToPattern(String s, Processor p, Log log) {
   6.206 +    public static Pattern validImportStringToPattern(String s) {
   6.207          if (s.equals("*")) {
   6.208              return allMatches;
   6.209          } else {
   6.210 -            String t = s;
   6.211 -            boolean star = false;
   6.212 -
   6.213 -            /*
   6.214 -             * Validate string from factory is legal.  If the string
   6.215 -             * has more than one asterisks or the asterisks does not
   6.216 -             * appear as the last character (preceded by a period),
   6.217 -             * the string is not legal.
   6.218 -             */
   6.219 -
   6.220 -            boolean valid = true;
   6.221 -            int index = t.indexOf('*');
   6.222 -            if (index != -1) {
   6.223 -                // '*' must be last character...
   6.224 -                if (index == t.length() -1) {
   6.225 -                     // ... and preceeding character must be '.'
   6.226 -                    if ( index-1 >= 0 ) {
   6.227 -                        valid = t.charAt(index-1) == '.';
   6.228 -                        // Strip off ".*$" for identifier checks
   6.229 -                        t = t.substring(0, t.length()-2);
   6.230 -                    }
   6.231 -                } else
   6.232 -                    valid = false;
   6.233 -            }
   6.234 -
   6.235 -            // Verify string is off the form (javaId \.)+ or javaId
   6.236 -            if (valid) {
   6.237 -                String[] javaIds = t.split("\\.", t.length()+2);
   6.238 -                for(String javaId: javaIds)
   6.239 -                    valid &= SourceVersion.isIdentifier(javaId);
   6.240 -            }
   6.241 -
   6.242 -            if (!valid) {
   6.243 -                log.warning("proc.malformed.supported.string", s, p.getClass().getName());
   6.244 -                return noMatches; // won't match any valid identifier
   6.245 -            }
   6.246 -
   6.247 -            String s_prime = s.replaceAll("\\.", "\\\\.");
   6.248 +            String s_prime = s.replace(".", "\\.");
   6.249  
   6.250              if (s_prime.endsWith("*")) {
   6.251                  s_prime =  s_prime.substring(0, s_prime.length() - 1) + ".+";
     7.1 --- a/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Thu Feb 18 13:31:57 2010 -0800
     7.2 +++ b/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Tue Feb 23 10:17:51 2010 -0800
     7.3 @@ -81,7 +81,7 @@
     7.4          cpString = appendPath(System.getProperty("env.class.path"), cpString);
     7.5          cpString = appendPath(System.getProperty("java.class.path"), cpString);
     7.6          cpString = appendPath(docletPath, cpString);
     7.7 -        URL[] urls = pathToURLs(cpString);
     7.8 +        URL[] urls = com.sun.tools.javac.file.Paths.pathToURLs(cpString);
     7.9          if (docletParentClassLoader == null)
    7.10              appClassLoader = new URLClassLoader(urls, getDelegationClassLoader(docletClassName));
    7.11          else
    7.12 @@ -313,58 +313,4 @@
    7.13                  Thread.currentThread().setContextClassLoader(savedCCL);
    7.14              }
    7.15      }
    7.16 -
    7.17 -    /**
    7.18 -     * Utility method for converting a search path string to an array
    7.19 -     * of directory and JAR file URLs.
    7.20 -     *
    7.21 -     * @param path the search path string
    7.22 -     * @return the resulting array of directory and JAR file URLs
    7.23 -     */
    7.24 -    static URL[] pathToURLs(String path) {
    7.25 -        StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
    7.26 -        URL[] urls = new URL[st.countTokens()];
    7.27 -        int count = 0;
    7.28 -        while (st.hasMoreTokens()) {
    7.29 -            URL url = fileToURL(new File(st.nextToken()));
    7.30 -            if (url != null) {
    7.31 -                urls[count++] = url;
    7.32 -            }
    7.33 -        }
    7.34 -        if (urls.length != count) {
    7.35 -            URL[] tmp = new URL[count];
    7.36 -            System.arraycopy(urls, 0, tmp, 0, count);
    7.37 -            urls = tmp;
    7.38 -        }
    7.39 -        return urls;
    7.40 -    }
    7.41 -
    7.42 -    /**
    7.43 -     * Returns the directory or JAR file URL corresponding to the specified
    7.44 -     * local file name.
    7.45 -     *
    7.46 -     * @param file the File object
    7.47 -     * @return the resulting directory or JAR file URL, or null if unknown
    7.48 -     */
    7.49 -    static URL fileToURL(File file) {
    7.50 -        String name;
    7.51 -        try {
    7.52 -            name = file.getCanonicalPath();
    7.53 -        } catch (IOException e) {
    7.54 -            name = file.getAbsolutePath();
    7.55 -        }
    7.56 -        name = name.replace(File.separatorChar, '/');
    7.57 -        if (!name.startsWith("/")) {
    7.58 -            name = "/" + name;
    7.59 -        }
    7.60 -        // If the file does not exist, then assume that it's a directory
    7.61 -        if (!file.isFile()) {
    7.62 -            name = name + "/";
    7.63 -        }
    7.64 -        try {
    7.65 -            return new URL("file", "", name);
    7.66 -        } catch (MalformedURLException e) {
    7.67 -            throw new IllegalArgumentException("file");
    7.68 -        }
    7.69 -    }
    7.70  }
     8.1 --- a/test/tools/javac/6341866/Anno.java	Thu Feb 18 13:31:57 2010 -0800
     8.2 +++ b/test/tools/javac/6341866/Anno.java	Tue Feb 23 10:17:51 2010 -0800
     8.3 @@ -27,7 +27,6 @@
     8.4  import javax.lang.model.element.*;
     8.5  
     8.6  @SupportedAnnotationTypes("*")
     8.7 -    @SupportedSourceVersion(SourceVersion.RELEASE_7)
     8.8  public class Anno extends AbstractProcessor {
     8.9      public boolean process(Set<? extends TypeElement> annotations,
    8.10                                      RoundEnvironment roundEnv) {
    8.11 @@ -35,4 +34,9 @@
    8.12          //    System.err.println("annotation processing");
    8.13          return true;
    8.14      }
    8.15 +
    8.16 +    @Override
    8.17 +    public SourceVersion getSupportedSourceVersion() {
    8.18 +        return SourceVersion.latest();
    8.19 +    }
    8.20  }
     9.1 --- a/test/tools/javac/EarlyAssert.java	Thu Feb 18 13:31:57 2010 -0800
     9.2 +++ b/test/tools/javac/EarlyAssert.java	Tue Feb 23 10:17:51 2010 -0800
     9.3 @@ -27,6 +27,8 @@
     9.4   * @summary Verify that assertions are enabled before the class is initialized
     9.5   * and not thereafter
     9.6   * @author gafter
     9.7 + * @build EarlyAssert EarlyAssertWrapper
     9.8 + * @run main EarlyAssertWrapper
     9.9   */
    9.10  
    9.11  /*
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/tools/javac/EarlyAssertWrapper.java	Tue Feb 23 10:17:51 2010 -0800
    10.3 @@ -0,0 +1,83 @@
    10.4 +/*
    10.5 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
    10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 + *
    10.8 + * This code is free software; you can redistribute it and/or modify it
    10.9 + * under the terms of the GNU General Public License version 2 only, as
   10.10 + * published by the Free Software Foundation.
   10.11 + *
   10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.15 + * version 2 for more details (a copy is included in the LICENSE file that
   10.16 + * accompanied this code).
   10.17 + *
   10.18 + * You should have received a copy of the GNU General Public License version
   10.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.21 + *
   10.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   10.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   10.24 + * have any questions.
   10.25 + */
   10.26 +
   10.27 +import java.io.*;
   10.28 +import java.util.*;
   10.29 +
   10.30 +/*
   10.31 + * Wrapper for the EarlyAssert test to run the test in a JVM without assertions
   10.32 + * enabled.
   10.33 + */
   10.34 +public class EarlyAssertWrapper {
   10.35 +    public static void main(String... args) throws Exception {
   10.36 +        EarlyAssertWrapper w = new EarlyAssertWrapper();
   10.37 +        w.run();
   10.38 +    }
   10.39 +
   10.40 +    void run() throws Exception {
   10.41 +        List<String> cmd = new ArrayList<String>();
   10.42 +        File java_home = new File(System.getProperty("java.home"));
   10.43 +        if (java_home.getName().equals("jre"))
   10.44 +            java_home = java_home.getParentFile();
   10.45 +        cmd.add(new File(new File(java_home, "bin"), "java").getPath());
   10.46 +
   10.47 +        // ensure we run with the same bootclasspath as this test,
   10.48 +        // in case this test is being run with -Xbootclasspath
   10.49 +        cmd.add("-Xbootclasspath:" + System.getProperty("sun.boot.class.path"));
   10.50 +
   10.51 +        // propogate classpath
   10.52 +        cmd.add("-classpath");
   10.53 +        cmd.add(System.getProperty("java.class.path"));
   10.54 +
   10.55 +        // ensure all assertions disabled in target VM
   10.56 +        cmd.add("-da");
   10.57 +        cmd.add("-dsa");
   10.58 +
   10.59 +        cmd.add("EarlyAssert");
   10.60 +
   10.61 +        System.err.println("Running command: " + cmd);
   10.62 +
   10.63 +        ProcessBuilder pb = new ProcessBuilder(cmd);
   10.64 +        pb.redirectErrorStream(true);
   10.65 +        Process p = pb.start();
   10.66 +        p.getOutputStream().close();
   10.67 +
   10.68 +        StringWriter sw = new StringWriter();
   10.69 +        PrintWriter pw = new PrintWriter(sw);
   10.70 +
   10.71 +        String line;
   10.72 +        DataInputStream in = new DataInputStream(p.getInputStream());
   10.73 +        try {
   10.74 +        while ((line = in.readLine()) != null)
   10.75 +            pw.println(line);
   10.76 +        } finally {
   10.77 +            in.close();
   10.78 +        }
   10.79 +        pw.close();
   10.80 +
   10.81 +        String out = sw.toString();
   10.82 +        int rc = p.waitFor();
   10.83 +        if (rc != 0 || out.length() > 0)
   10.84 +            throw new Error("failed: rc=" + rc + (out.length() > 0 ? ": " + out : ""));
   10.85 +    }
   10.86 +}
    11.1 --- a/test/tools/javac/T6403466.java	Thu Feb 18 13:31:57 2010 -0800
    11.2 +++ b/test/tools/javac/T6403466.java	Tue Feb 23 10:17:51 2010 -0800
    11.3 @@ -41,7 +41,6 @@
    11.4  
    11.5  @Wrap
    11.6  @SupportedAnnotationTypes("Wrap")
    11.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    11.8  public class T6403466 extends AbstractProcessor {
    11.9  
   11.10      static final String testSrcDir = System.getProperty("test.src");
   11.11 @@ -73,24 +72,31 @@
   11.12      }
   11.13  
   11.14      public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
   11.15 -        Filer filer = processingEnv.getFiler();
   11.16 -        for (TypeElement anno: annos) {
   11.17 -            Set<? extends Element> elts = rEnv.getElementsAnnotatedWith(anno);
   11.18 -            System.err.println("anno: " + anno);
   11.19 -            System.err.println("elts: " + elts);
   11.20 -            for (TypeElement te: ElementFilter.typesIn(elts)) {
   11.21 -                try {
   11.22 -                    Writer out = filer.createSourceFile(te.getSimpleName() + "Wrapper").openWriter();
   11.23 -                    out.write("class " + te.getSimpleName() + "Wrapper { }");
   11.24 -                    out.close();
   11.25 -                } catch (IOException ex) {
   11.26 -                    ex.printStackTrace();
   11.27 +        if (!rEnv.processingOver()) {
   11.28 +            Filer filer = processingEnv.getFiler();
   11.29 +            for (TypeElement anno: annos) {
   11.30 +                Set<? extends Element> elts = rEnv.getElementsAnnotatedWith(anno);
   11.31 +                System.err.println("anno: " + anno);
   11.32 +                System.err.println("elts: " + elts);
   11.33 +                for (TypeElement te: ElementFilter.typesIn(elts)) {
   11.34 +                    try {
   11.35 +                        Writer out = filer.createSourceFile(te.getSimpleName() + "Wrapper").openWriter();
   11.36 +                        out.write("class " + te.getSimpleName() + "Wrapper { }");
   11.37 +                        out.close();
   11.38 +                    } catch (IOException ex) {
   11.39 +                        ex.printStackTrace();
   11.40 +                    }
   11.41                  }
   11.42 +
   11.43              }
   11.44 -
   11.45          }
   11.46          return true;
   11.47      }
   11.48 +
   11.49 +    @Override
   11.50 +    public SourceVersion getSupportedSourceVersion() {
   11.51 +        return SourceVersion.latest();
   11.52 +    }
   11.53  }
   11.54  
   11.55  @Retention(RetentionPolicy.SOURCE)
    12.1 --- a/test/tools/javac/T6406771.java	Thu Feb 18 13:31:57 2010 -0800
    12.2 +++ b/test/tools/javac/T6406771.java	Tue Feb 23 10:17:51 2010 -0800
    12.3 @@ -17,7 +17,7 @@
    12.4  import com.sun.source.util.*;
    12.5  import com.sun.tools.javac.tree.JCTree;
    12.6  
    12.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    12.8 +
    12.9  @SupportedAnnotationTypes("*")
   12.10  public class T6406771 extends AbstractProcessor {
   12.11      String[] tests = {
   12.12 @@ -95,4 +95,8 @@
   12.13          return true;
   12.14      }
   12.15  
   12.16 +    @Override
   12.17 +    public SourceVersion getSupportedSourceVersion() {
   12.18 +        return SourceVersion.latest();
   12.19 +    }
   12.20  }
    13.1 --- a/test/tools/javac/T6411379.java	Thu Feb 18 13:31:57 2010 -0800
    13.2 +++ b/test/tools/javac/T6411379.java	Tue Feb 23 10:17:51 2010 -0800
    13.3 @@ -37,7 +37,6 @@
    13.4  import com.sun.source.util.*;
    13.5  
    13.6  @SupportedAnnotationTypes("*")
    13.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    13.8  public class T6411379 extends AbstractProcessor {
    13.9  
   13.10      public boolean process(Set<? extends TypeElement> annoElems,
   13.11 @@ -58,6 +57,11 @@
   13.12          return true;
   13.13      }
   13.14  
   13.15 +    @Override
   13.16 +    public SourceVersion getSupportedSourceVersion() {
   13.17 +        return SourceVersion.latest();
   13.18 +    }
   13.19 +
   13.20      public void checkNull(Object o) {
   13.21          if (o != null)
   13.22              throw new AssertionError("expected null");
    14.1 --- a/test/tools/javac/T6423583.java	Thu Feb 18 13:31:57 2010 -0800
    14.2 +++ b/test/tools/javac/T6423583.java	Tue Feb 23 10:17:51 2010 -0800
    14.3 @@ -37,7 +37,6 @@
    14.4  import com.sun.source.util.*;
    14.5  
    14.6  @SupportedAnnotationTypes("*")
    14.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    14.8  public class T6423583 extends AbstractProcessor {
    14.9      boolean b1 = true;
   14.10      boolean b2 = false;
   14.11 @@ -59,6 +58,10 @@
   14.12          return true;
   14.13      }
   14.14  
   14.15 +    @Override
   14.16 +    public SourceVersion getSupportedSourceVersion() {
   14.17 +        return SourceVersion.latest();
   14.18 +    }
   14.19  
   14.20      private static class Test extends TreeScanner<Void,Void> {
   14.21  
    15.1 --- a/test/tools/javac/T6855236.java	Thu Feb 18 13:31:57 2010 -0800
    15.2 +++ b/test/tools/javac/T6855236.java	Tue Feb 23 10:17:51 2010 -0800
    15.3 @@ -38,7 +38,6 @@
    15.4  import com.sun.source.tree.*;
    15.5  import com.sun.source.util.*;
    15.6  
    15.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    15.8  @SupportedAnnotationTypes("*")
    15.9  public class T6855236 extends AbstractProcessor {
   15.10  
   15.11 @@ -63,6 +62,11 @@
   15.12          return true;
   15.13      }
   15.14  
   15.15 +    @Override
   15.16 +    public SourceVersion getSupportedSourceVersion() {
   15.17 +        return SourceVersion.latest();
   15.18 +    }
   15.19 +
   15.20      class CodeVisitor extends TreePathScanner<Object, Trees> {
   15.21  
   15.22          @Override
    16.1 --- a/test/tools/javac/api/6421111/T6421111.java	Thu Feb 18 13:31:57 2010 -0800
    16.2 +++ b/test/tools/javac/api/6421111/T6421111.java	Tue Feb 23 10:17:51 2010 -0800
    16.3 @@ -76,7 +76,6 @@
    16.4              throw new AssertionError("Annotation processor failed");
    16.5      }
    16.6      @SupportedAnnotationTypes("*")
    16.7 -    @SupportedSourceVersion(SourceVersion.RELEASE_6)
    16.8      static class MyProcessor extends AbstractProcessor {
    16.9          void test(TypeElement element, boolean fbound) {
   16.10              TypeParameterElement tpe = element.getTypeParameters().iterator().next();
   16.11 @@ -96,6 +95,10 @@
   16.12              test(processingEnv.getElementUtils().getTypeElement("Test2"), true);
   16.13              return false;
   16.14          }
   16.15 +        @Override
   16.16 +        public SourceVersion getSupportedSourceVersion() {
   16.17 +            return SourceVersion.latest();
   16.18 +        }
   16.19      }
   16.20      public static void main(String... args) {
   16.21          new T6421111().test(args);
    17.1 --- a/test/tools/javac/api/6468404/T6468404.java	Thu Feb 18 13:31:57 2010 -0800
    17.2 +++ b/test/tools/javac/api/6468404/T6468404.java	Tue Feb 23 10:17:51 2010 -0800
    17.3 @@ -105,7 +105,6 @@
    17.4  }
    17.5  
    17.6  @SupportedAnnotationTypes("*")
    17.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    17.8  class P extends AbstractProcessor {
    17.9      boolean ran = false;
   17.10  
   17.11 @@ -145,4 +144,9 @@
   17.12          }
   17.13          return true;
   17.14      }
   17.15 +
   17.16 +    @Override
   17.17 +    public SourceVersion getSupportedSourceVersion() {
   17.18 +        return SourceVersion.latest();
   17.19 +    }
   17.20  }
    18.1 --- a/test/tools/javac/api/T6412669.java	Thu Feb 18 13:31:57 2010 -0800
    18.2 +++ b/test/tools/javac/api/T6412669.java	Tue Feb 23 10:17:51 2010 -0800
    18.3 @@ -38,7 +38,6 @@
    18.4  import com.sun.tools.javac.api.*;
    18.5  
    18.6  @SupportedAnnotationTypes("*")
    18.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    18.8  public class T6412669 extends AbstractProcessor {
    18.9      public static void main(String... args) throws IOException {
   18.10          String testSrc = System.getProperty("test.src", ".");
   18.11 @@ -72,4 +71,9 @@
   18.12          }
   18.13          return true;
   18.14      }
   18.15 +
   18.16 +    @Override
   18.17 +    public SourceVersion getSupportedSourceVersion() {
   18.18 +        return SourceVersion.latest();
   18.19 +    }
   18.20  }
    19.1 --- a/test/tools/javac/enum/6424358/T6424358.java	Thu Feb 18 13:31:57 2010 -0800
    19.2 +++ b/test/tools/javac/enum/6424358/T6424358.java	Tue Feb 23 10:17:51 2010 -0800
    19.3 @@ -34,13 +34,12 @@
    19.4  import javax.annotation.processing.*;
    19.5  import javax.lang.model.element.*;
    19.6  import javax.lang.model.util.*;
    19.7 +import javax.lang.model.SourceVersion;
    19.8  import static javax.tools.Diagnostic.Kind.*;
    19.9 -import static javax.lang.model.SourceVersion.RELEASE_6;
   19.10  
   19.11  @interface TestMe {}
   19.12  
   19.13  @SupportedAnnotationTypes("*")
   19.14 -@SupportedSourceVersion(RELEASE_6)
   19.15  public class T6424358 extends AbstractProcessor {
   19.16      @TestMe enum Test { FOO; }
   19.17  
   19.18 @@ -66,4 +65,9 @@
   19.19              scan.scan(e);
   19.20          return true;
   19.21      }
   19.22 +
   19.23 +    @Override
   19.24 +    public SourceVersion getSupportedSourceVersion() {
   19.25 +        return SourceVersion.latest();
   19.26 +    }
   19.27  }
    20.1 --- a/test/tools/javac/processing/6348499/A.java	Thu Feb 18 13:31:57 2010 -0800
    20.2 +++ b/test/tools/javac/processing/6348499/A.java	Tue Feb 23 10:17:51 2010 -0800
    20.3 @@ -28,7 +28,6 @@
    20.4  import javax.lang.model.element.*;
    20.5  
    20.6  @SupportedAnnotationTypes("*")
    20.7 -@SupportedSourceVersion(SourceVersion.RELEASE_7)
    20.8  public class A extends AbstractProcessor {
    20.9      public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
   20.10          Filer filer = processingEnv.getFiler();
   20.11 @@ -40,4 +39,8 @@
   20.12          }
   20.13          return true;
   20.14      }
   20.15 +    @Override
   20.16 +    public SourceVersion getSupportedSourceVersion() {
   20.17 +        return SourceVersion.latest();
   20.18 +    }
   20.19  }
    21.1 --- a/test/tools/javac/processing/6414633/A.java	Thu Feb 18 13:31:57 2010 -0800
    21.2 +++ b/test/tools/javac/processing/6414633/A.java	Tue Feb 23 10:17:51 2010 -0800
    21.3 @@ -30,7 +30,6 @@
    21.4  import javax.tools.*;
    21.5  
    21.6  @SupportedAnnotationTypes("*")
    21.7 -@SupportedSourceVersion(SourceVersion.RELEASE_7)
    21.8  public class A extends AbstractProcessor {
    21.9  
   21.10      public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
   21.11 @@ -42,4 +41,9 @@
   21.12          }
   21.13          return true;
   21.14      }
   21.15 +
   21.16 +    @Override
   21.17 +    public SourceVersion getSupportedSourceVersion() {
   21.18 +        return SourceVersion.latest();
   21.19 +    }
   21.20  }
    22.1 --- a/test/tools/javac/processing/6430209/T6430209.java	Thu Feb 18 13:31:57 2010 -0800
    22.2 +++ b/test/tools/javac/processing/6430209/T6430209.java	Tue Feb 23 10:17:51 2010 -0800
    22.3 @@ -63,7 +63,6 @@
    22.4              new File(testSrc, "test0.java"), new File(testSrc, "test1.java")));
    22.5          Iterable<String> opts = Arrays.asList("-proc:only",
    22.6                                                "-processor", "b6341534",
    22.7 -                                              "-source", "1.6",
    22.8                                                "-processorpath", testClasses);
    22.9          StringWriter out = new StringWriter();
   22.10          JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
    23.1 --- a/test/tools/javac/processing/6430209/b6341534.java	Thu Feb 18 13:31:57 2010 -0800
    23.2 +++ b/test/tools/javac/processing/6430209/b6341534.java	Tue Feb 23 10:17:51 2010 -0800
    23.3 @@ -22,6 +22,7 @@
    23.4   */
    23.5  
    23.6  import javax.annotation.processing.*;
    23.7 +import javax.lang.model.SourceVersion;
    23.8  import javax.lang.model.element.*;
    23.9  import javax.lang.model.util.*;
   23.10  import static javax.lang.model.util.ElementFilter.*;
   23.11 @@ -30,7 +31,6 @@
   23.12  import java.util.Set;
   23.13  
   23.14  @SupportedAnnotationTypes({"*"})
   23.15 -@SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_7)
   23.16  public class b6341534 extends AbstractProcessor {
   23.17      static int r = 0;
   23.18      static Elements E = null;
   23.19 @@ -62,4 +62,9 @@
   23.20          if( renv.errorRaised() ) {      msgr.printMessage(ERROR, "FAILED");}
   23.21          return true;
   23.22      }
   23.23 +
   23.24 +    @Override
   23.25 +    public SourceVersion getSupportedSourceVersion() {
   23.26 +        return SourceVersion.latest();
   23.27 +    }
   23.28  }
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/tools/javac/processing/6634138/Dummy.java	Tue Feb 23 10:17:51 2010 -0800
    24.3 @@ -0,0 +1,27 @@
    24.4 +/*
    24.5 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
    24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.7 + *
    24.8 + * This code is free software; you can redistribute it and/or modify it
    24.9 + * under the terms of the GNU General Public License version 2 only, as
   24.10 + * published by the Free Software Foundation.
   24.11 + *
   24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   24.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   24.15 + * version 2 for more details (a copy is included in the LICENSE file that
   24.16 + * accompanied this code).
   24.17 + *
   24.18 + * You should have received a copy of the GNU General Public License version
   24.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   24.21 + *
   24.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   24.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   24.24 + * have any questions.
   24.25 + */
   24.26 +
   24.27 +/**
   24.28 + * A dummy class to be compiled.
   24.29 + */
   24.30 +public class Dummy {}
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/test/tools/javac/processing/6634138/ExerciseDependency.java	Tue Feb 23 10:17:51 2010 -0800
    25.3 @@ -0,0 +1,37 @@
    25.4 +/*
    25.5 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
    25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 + *
    25.8 + * This code is free software; you can redistribute it and/or modify it
    25.9 + * under the terms of the GNU General Public License version 2 only, as
   25.10 + * published by the Free Software Foundation.
   25.11 + *
   25.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   25.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.15 + * version 2 for more details (a copy is included in the LICENSE file that
   25.16 + * accompanied this code).
   25.17 + *
   25.18 + * You should have received a copy of the GNU General Public License version
   25.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   25.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.21 + *
   25.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   25.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   25.24 + * have any questions.
   25.25 + */
   25.26 +
   25.27 +/**
   25.28 + * Class to exercise dependencies on the two source files generated by
   25.29 + * T6634138.java, foo.WrittenAfterProcessing.java and
   25.30 + * foo.package-info.java.
   25.31 + */
   25.32 +public class ExerciseDependency {
   25.33 +    public static void main(String... args) {
   25.34 +        foo.WrittenAfterProcessing wap = new foo.WrittenAfterProcessing();
   25.35 +        java.lang.Package pkg = wap.getClass().getPackage();
   25.36 +        Deprecated d = pkg.getAnnotation(Deprecated.class);
   25.37 +        if (d == null)
   25.38 +            throw new RuntimeException();
   25.39 +    }
   25.40 +}
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/tools/javac/processing/6634138/T6634138.java	Tue Feb 23 10:17:51 2010 -0800
    26.3 @@ -0,0 +1,93 @@
    26.4 +/*
    26.5 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
    26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 + *
    26.8 + * This code is free software; you can redistribute it and/or modify it
    26.9 + * under the terms of the GNU General Public License version 2 only, as
   26.10 + * published by the Free Software Foundation.
   26.11 + *
   26.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   26.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.15 + * version 2 for more details (a copy is included in the LICENSE file that
   26.16 + * accompanied this code).
   26.17 + *
   26.18 + * You should have received a copy of the GNU General Public License version
   26.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   26.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.21 + *
   26.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   26.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   26.24 + * have any questions.
   26.25 + */
   26.26 +
   26.27 +/*
   26.28 + * @test
   26.29 + * @bug 6634138
   26.30 + * @author  Joseph D. Darcy
   26.31 + * @summary Verify source files output after processing is over are compiled
   26.32 + * @compile T6634138.java
   26.33 + * @compile -processor T6634138 Dummy.java
   26.34 + * @run main ExerciseDependency
   26.35 + */
   26.36 +
   26.37 +import java.lang.annotation.Annotation;
   26.38 +import java.io.*;
   26.39 +import java.util.Collections;
   26.40 +import java.util.Set;
   26.41 +import java.util.HashSet;
   26.42 +import java.util.List;
   26.43 +import java.util.ArrayList;
   26.44 +import java.util.Arrays;
   26.45 +import javax.annotation.processing.*;
   26.46 +import javax.lang.model.SourceVersion;
   26.47 +import javax.lang.model.element.*;
   26.48 +import javax.lang.model.util.*;
   26.49 +
   26.50 +@SupportedAnnotationTypes("*")
   26.51 +public class T6634138 extends AbstractProcessor {
   26.52 +    private Filer filer;
   26.53 +
   26.54 +    public boolean process(Set<? extends TypeElement> annotations,
   26.55 +                           RoundEnvironment roundEnvironment) {
   26.56 +        // Write out files *after* processing is over.
   26.57 +        if (roundEnvironment.processingOver()) {
   26.58 +            System.out.println("Writing out source files.");
   26.59 +            try {
   26.60 +                PrintWriter pw = new PrintWriter(filer.createSourceFile("foo.WrittenAfterProcessing").openWriter());
   26.61 +                try {
   26.62 +                     pw.println("package foo;");
   26.63 +                     pw.println("public class WrittenAfterProcessing {");
   26.64 +                     pw.println("  public WrittenAfterProcessing() {super();}");
   26.65 +                     pw.println("}");
   26.66 +                 } finally {
   26.67 +                     pw.close();
   26.68 +                 }
   26.69 +
   26.70 +                pw = new PrintWriter(filer.createSourceFile("foo.package-info").openWriter());
   26.71 +                try {
   26.72 +                     pw.println("@Deprecated");
   26.73 +                     pw.println("package foo;");
   26.74 +                 } finally {
   26.75 +                     pw.close();
   26.76 +                 }
   26.77 +            } catch(IOException io) {
   26.78 +                throw new RuntimeException(io);
   26.79 +            }
   26.80 +        }
   26.81 +        return true;
   26.82 +    }
   26.83 +
   26.84 +    @Override
   26.85 +    public SourceVersion getSupportedSourceVersion() {
   26.86 +        return SourceVersion.latest();
   26.87 +    }
   26.88 +
   26.89 +    public void init(ProcessingEnvironment processingEnv) {
   26.90 +        super.init(processingEnv);
   26.91 +        filer    = processingEnv.getFiler();
   26.92 +    }
   26.93 +}
   26.94 +
   26.95 +
   26.96 +
    27.1 --- a/test/tools/javac/processing/T6439826.java	Thu Feb 18 13:31:57 2010 -0800
    27.2 +++ b/test/tools/javac/processing/T6439826.java	Tue Feb 23 10:17:51 2010 -0800
    27.3 @@ -39,7 +39,6 @@
    27.4  
    27.5  
    27.6  @SupportedAnnotationTypes("*")
    27.7 -@SupportedSourceVersion(SourceVersion.RELEASE_7 )
    27.8  public class T6439826 extends AbstractProcessor {
    27.9      public static void main(String... args) {
   27.10          String testSrc = System.getProperty("test.src", ".");
   27.11 @@ -76,6 +75,11 @@
   27.12          return false;
   27.13      }
   27.14  
   27.15 +    @Override
   27.16 +    public SourceVersion getSupportedSourceVersion() {
   27.17 +        return SourceVersion.latest();
   27.18 +    }
   27.19 +
   27.20      private void writeBadFile() {
   27.21          Filer filer = processingEnv.getFiler();
   27.22          Messager messager = processingEnv.getMessager();
    28.1 --- a/test/tools/javac/processing/model/element/TypeParamBounds.java	Thu Feb 18 13:31:57 2010 -0800
    28.2 +++ b/test/tools/javac/processing/model/element/TypeParamBounds.java	Tue Feb 23 10:17:51 2010 -0800
    28.3 @@ -40,7 +40,6 @@
    28.4  import javax.lang.model.type.*;
    28.5  import javax.lang.model.util.*;
    28.6  
    28.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    28.8  @SupportedAnnotationTypes("*")
    28.9  public class TypeParamBounds extends AbstractProcessor {
   28.10  
   28.11 @@ -60,6 +59,11 @@
   28.12          return true;
   28.13      }
   28.14  
   28.15 +    @Override
   28.16 +    public SourceVersion getSupportedSourceVersion() {
   28.17 +        return SourceVersion.latest();
   28.18 +    }
   28.19 +
   28.20      private void doit(Set<? extends TypeElement> annoTypes,
   28.21                        RoundEnvironment round) {
   28.22          TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen");
    29.1 --- a/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java	Thu Feb 18 13:31:57 2010 -0800
    29.2 +++ b/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java	Tue Feb 23 10:17:51 2010 -0800
    29.3 @@ -38,7 +38,6 @@
    29.4  import javax.lang.model.util.*;
    29.5  import static javax.lang.model.util.ElementFilter.*;
    29.6  
    29.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    29.8  @SupportedAnnotationTypes("IAm")
    29.9  @IAm(OverEager.class)
   29.10  public class OverEager extends AbstractProcessor {
   29.11 @@ -59,6 +58,11 @@
   29.12          return true;
   29.13      }
   29.14  
   29.15 +    @Override
   29.16 +    public SourceVersion getSupportedSourceVersion() {
   29.17 +        return SourceVersion.latest();
   29.18 +    }
   29.19 +
   29.20      private void doit(Set<? extends TypeElement> annoTypes,
   29.21                        RoundEnvironment round) {
   29.22          for (TypeElement t : typesIn(round.getRootElements())) {
    30.1 --- a/test/tools/javac/processing/model/type/NoTypes.java	Thu Feb 18 13:31:57 2010 -0800
    30.2 +++ b/test/tools/javac/processing/model/type/NoTypes.java	Tue Feb 23 10:17:51 2010 -0800
    30.3 @@ -39,8 +39,6 @@
    30.4  
    30.5  import static javax.lang.model.type.TypeKind.*;
    30.6  
    30.7 -
    30.8 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    30.9  @SupportedAnnotationTypes("*")
   30.10  public class NoTypes extends AbstractProcessor {
   30.11  
   30.12 @@ -60,6 +58,11 @@
   30.13          return true;
   30.14      }
   30.15  
   30.16 +    @Override
   30.17 +    public SourceVersion getSupportedSourceVersion() {
   30.18 +        return SourceVersion.latest();
   30.19 +    }
   30.20 +
   30.21      private void doit(Set<? extends TypeElement> annoTypes,
   30.22                        RoundEnvironment round) {
   30.23  
    31.1 --- a/test/tools/javac/processing/model/util/GetTypeElemBadArg.java	Thu Feb 18 13:31:57 2010 -0800
    31.2 +++ b/test/tools/javac/processing/model/util/GetTypeElemBadArg.java	Tue Feb 23 10:17:51 2010 -0800
    31.3 @@ -37,7 +37,6 @@
    31.4  import javax.lang.model.type.*;
    31.5  import javax.lang.model.util.*;
    31.6  
    31.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    31.8  @SupportedAnnotationTypes("*")
    31.9  public class GetTypeElemBadArg extends AbstractProcessor {
   31.10  
   31.11 @@ -64,6 +63,12 @@
   31.12          return true;
   31.13      }
   31.14  
   31.15 +
   31.16 +    @Override
   31.17 +    public SourceVersion getSupportedSourceVersion() {
   31.18 +        return SourceVersion.latest();
   31.19 +    }
   31.20 +
   31.21      private static void tellAbout(TypeElement t) {
   31.22          System.out.println(t);
   31.23          System.out.println(t.getClass());
    32.1 --- a/test/tools/javac/processing/model/util/OverridesSpecEx.java	Thu Feb 18 13:31:57 2010 -0800
    32.2 +++ b/test/tools/javac/processing/model/util/OverridesSpecEx.java	Tue Feb 23 10:17:51 2010 -0800
    32.3 @@ -40,7 +40,6 @@
    32.4  import static javax.lang.model.util.ElementFilter.*;
    32.5  
    32.6  
    32.7 -@SupportedSourceVersion(SourceVersion.RELEASE_6)
    32.8  @SupportedAnnotationTypes("*")
    32.9  public class OverridesSpecEx extends AbstractProcessor {
   32.10  
   32.11 @@ -60,6 +59,11 @@
   32.12          return true;
   32.13      }
   32.14  
   32.15 +    @Override
   32.16 +    public SourceVersion getSupportedSourceVersion() {
   32.17 +        return SourceVersion.latest();
   32.18 +    }
   32.19 +
   32.20      private void doit(Set<? extends TypeElement> annoTypes,
   32.21                        RoundEnvironment round) {
   32.22          TypeElement string = elements.getTypeElement("java.lang.String");
    33.1 --- a/test/tools/javac/treepostests/TreePosTest.java	Thu Feb 18 13:31:57 2010 -0800
    33.2 +++ b/test/tools/javac/treepostests/TreePosTest.java	Tue Feb 23 10:17:51 2010 -0800
    33.3 @@ -98,7 +98,7 @@
    33.4   * @test
    33.5   * @bug 6919889
    33.6   * @summary assorted position errors in compiler syntax trees
    33.7 - * @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations  .
    33.8 + * @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations -et ANNOTATED_TYPE .
    33.9   */
   33.10  public class TreePosTest {
   33.11      /**
   33.12 @@ -150,6 +150,8 @@
   33.13                  tags.add(args[++i]);
   33.14              else if (arg.equals("-ef") && i + 1 < args.length)
   33.15                  excludeFiles.add(new File(baseDir, args[++i]));
   33.16 +            else if (arg.equals("-et") && i + 1 < args.length)
   33.17 +                excludeTags.add(args[++i]);
   33.18              else if (arg.equals("-r")) {
   33.19                  if (excludeFiles.size() > 0)
   33.20                      throw new Error("-r must be used before -ef");
   33.21 @@ -199,6 +201,7 @@
   33.22          out.println("-t tag    Limit checks to tree nodes with this tag");
   33.23          out.println("          Can be repeated if desired");
   33.24          out.println("-ef file  Exclude file or directory");
   33.25 +        out.println("-et tag   Exclude tree nodes with given tag name");
   33.26          out.println("");
   33.27          out.println("files may be directories or files");
   33.28          out.println("directories will be scanned recursively");
   33.29 @@ -304,6 +307,8 @@
   33.30      Set<String> tags = new HashSet<String>();
   33.31      /** Set of files and directories to be excluded from analysis. */
   33.32      Set<File> excludeFiles = new HashSet<File>();
   33.33 +    /** Set of tag names to be excluded from analysis. */
   33.34 +    Set<String> excludeTags = new HashSet<String>();
   33.35      /** Table of printable names for tree tag values. */
   33.36      TagNames tagNames = new TagNames();
   33.37  
   33.38 @@ -324,7 +329,7 @@
   33.39                  return;
   33.40  
   33.41              Info self = new Info(tree, endPosTable);
   33.42 -            if (check(self)) {
   33.43 +            if (check(encl, self)) {
   33.44                  // Modifiers nodes are present throughout the tree even where
   33.45                  // there is no corresponding source text.
   33.46                  // Redundant semicolons in a class definition can cause empty
   33.47 @@ -392,8 +397,13 @@
   33.48                  super.visitVarDef(tree);
   33.49          }
   33.50  
   33.51 -        boolean check(Info x) {
   33.52 -            return tags.size() == 0 || tags.contains(tagNames.get(x.tag));
   33.53 +        boolean check(Info encl, Info self) {
   33.54 +            if (excludeTags.size() > 0) {
   33.55 +                if (encl != null && excludeTags.contains(tagNames.get(encl.tag))
   33.56 +                        || excludeTags.contains(tagNames.get(self.tag)))
   33.57 +                    return false;
   33.58 +            }
   33.59 +            return tags.size() == 0 || tags.contains(tagNames.get(self.tag));
   33.60          }
   33.61  
   33.62          void check(String label, Info encl, Info self, boolean ok) {

mercurial