Merge jdk7-b81

Fri, 22 Jan 2010 09:34:46 -0800

author
lana
date
Fri, 22 Jan 2010 09:34:46 -0800
changeset 473
cfabfcf9f110
parent 456
250a580ab046
parent 472
a84062774f0e
child 474
47003a3622f6
child 481
ff7a01f9eff3

Merge

     1.1 --- a/make/Makefile	Thu Jan 21 11:12:47 2010 -0800
     1.2 +++ b/make/Makefile	Fri Jan 22 09:34:46 2010 -0800
     1.3 @@ -144,8 +144,8 @@
     1.4    ifdef ALT_JDK_TOPDIR
     1.5      ANT_OPTIONS += -Dimport.jdk=$(ALT_JDK_TOPDIR)
     1.6    else 
     1.7 -    ifdef ALT_JDK_IMPORT_DIR
     1.8 -      ANT_OPTIONS += -Dimport.jdk=$(ALT_JDK_IMPORT_DIR)
     1.9 +    ifdef ALT_JDK_IMPORT_PATH
    1.10 +      ANT_OPTIONS += -Dimport.jdk=$(ALT_JDK_IMPORT_PATH)
    1.11      endif
    1.12    endif
    1.13  endif
     2.1 --- a/make/build.xml	Thu Jan 21 11:12:47 2010 -0800
     2.2 +++ b/make/build.xml	Fri Jan 22 09:34:46 2010 -0800
     2.3 @@ -107,14 +107,21 @@
     2.4          ignoresystemclasses="true"
     2.5          classpath="${import.jdk}/jre/lib/rt.jar" classname="java.nio.file.Path"/>
     2.6  
     2.7 +    <!-- Set the default value of the sourcepath used for javac. -->
     2.8      <condition property="javac.sourcepath" value="${build.genstubs.dir}" else="">
     2.9          <isset property="import.jdk.src.dir"/>
    2.10      </condition>
    2.11  
    2.12 +    <!-- Set the default value of the classpath used for javac. -->
    2.13      <property name="javac.classpath" value=""/>
    2.14  
    2.15 +    <!-- Set the default bootclasspath option used for javac. 
    2.16 +	Note that different variants of the option are used, meaning we can't just 
    2.17 +	define the value for the option.
    2.18 +	Note the explicit use of the standard property ${path.separator} in the following.
    2.19 +	This is because Ant is not clever enough to handle direct use of : or ; -->
    2.20      <condition property="javac.bootclasspath.opt"
    2.21 -            value="-Xbootclasspath:${build.classes.dir}:${import.jdk.jar}"
    2.22 +            value="-Xbootclasspath:${build.classes.dir}${path.separator}${import.jdk.jar}"
    2.23              else="-Xbootclasspath/p:${build.classes.dir}">
    2.24          <isset property="import.jdk.jar"/>
    2.25      </condition>
     3.1 --- a/make/tools/CompileProperties/CompileProperties.java	Thu Jan 21 11:12:47 2010 -0800
     3.2 +++ b/make/tools/CompileProperties/CompileProperties.java	Fri Jan 22 09:34:46 2010 -0800
     3.3 @@ -101,7 +101,7 @@
     3.4          boolean ok = true;
     3.5          /* Original usage */
     3.6          if (args.length == 2 && args[0].charAt(0) != '-' ) {
     3.7 -            ok = createFile(args[0], args[1], "ListResourceBundle");
     3.8 +            ok = createFile(args[0], args[1], "java.util.ListResourceBundle");
     3.9          } else if (args.length == 3) {
    3.10              ok = createFile(args[0], args[1], args[2]);
    3.11          } else if (args.length == 0) {
    3.12 @@ -285,9 +285,9 @@
    3.13          log.info("    java CompileProperties {-compile path_to_properties_file path_to_java_output_file super_class} -or- -optionsfile filename");
    3.14          log.info("");
    3.15          log.info("Example:");
    3.16 -        log.info("    java CompileProperties -compile test.properties test.java ListResourceBundle");
    3.17 +        log.info("    java CompileProperties -compile test.properties test.java java.util.ListResourceBundle");
    3.18          log.info("    java CompileProperties -optionsfile option_file");
    3.19 -        log.info("option_file contains: -compile test.properties test.java ListResourceBundle");
    3.20 +        log.info("option_file contains: -compile test.properties test.java java.util.ListResourceBundle");
    3.21      }
    3.22  
    3.23      private static String escape(String theString) {
    3.24 @@ -379,7 +379,6 @@
    3.25  
    3.26      private static final String FORMAT =
    3.27              "{0}" +
    3.28 -            "import java.util.ListResourceBundle;\n\n" +
    3.29              "public final class {1} extends {2} '{'\n" +
    3.30              "    protected final Object[][] getContents() '{'\n" +
    3.31              "        return new Object[][] '{'\n" +
     4.1 --- a/make/tools/CompileProperties/CompilePropertiesTask.java	Thu Jan 21 11:12:47 2010 -0800
     4.2 +++ b/make/tools/CompileProperties/CompilePropertiesTask.java	Fri Jan 22 09:34:46 2010 -0800
     4.3 @@ -45,6 +45,7 @@
     4.4          this.superclass = superclass;
     4.5      }
     4.6  
     4.7 +    @Override
     4.8      public void execute() {
     4.9          CompileProperties.Log log = new CompileProperties.Log() {
    4.10              public void error(String msg, Exception e) {
    4.11 @@ -84,7 +85,7 @@
    4.12              log("Generating " + count + " resource files to " + destDir, Project.MSG_INFO);
    4.13              CompileProperties cp = new CompileProperties();
    4.14              cp.setLog(log);
    4.15 -            boolean ok = cp.run((String[])mainOpts.toArray(new String[mainOpts.size()]));
    4.16 +            boolean ok = cp.run(mainOpts.toArray(new String[mainOpts.size()]));
    4.17              if (!ok)
    4.18                  throw new BuildException("CompileProperties failed.");
    4.19          }
     5.1 --- a/make/tools/GenStubs/GenStubs.java	Thu Jan 21 11:12:47 2010 -0800
     5.2 +++ b/make/tools/GenStubs/GenStubs.java	Fri Jan 22 09:34:46 2010 -0800
     5.3 @@ -22,6 +22,7 @@
     5.4   * CA 95054 USA or visit www.sun.com if you need additional information or
     5.5   * have any questions.
     5.6   */
     5.7 +
     5.8  import java.io.*;
     5.9  import java.util.*;
    5.10  import javax.tools.JavaFileObject;
    5.11 @@ -41,15 +42,22 @@
    5.12  import com.sun.tools.javac.code.Flags;
    5.13  import com.sun.tools.javac.code.TypeTags;
    5.14  import com.sun.tools.javac.tree.JCTree;
    5.15 -import com.sun.tools.javac.tree.JCTree.JCBlock;
    5.16  import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
    5.17 +import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
    5.18 +import com.sun.tools.javac.tree.JCTree.JCIdent;
    5.19 +import com.sun.tools.javac.tree.JCTree.JCImport;
    5.20  import com.sun.tools.javac.tree.JCTree.JCLiteral;
    5.21  import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
    5.22  import com.sun.tools.javac.tree.JCTree.JCModifiers;
    5.23 -import com.sun.tools.javac.tree.JCTree.JCStatement;
    5.24  import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
    5.25  import com.sun.tools.javac.tree.Pretty;
    5.26 +import com.sun.tools.javac.tree.TreeMaker;
    5.27 +import com.sun.tools.javac.tree.TreeScanner;
    5.28  import com.sun.tools.javac.tree.TreeTranslator;
    5.29 +import com.sun.tools.javac.util.Context;
    5.30 +import com.sun.tools.javac.util.ListBuffer;
    5.31 +import com.sun.tools.javac.util.Name;
    5.32 +import javax.tools.JavaFileManager;
    5.33  
    5.34  /**
    5.35   * Generate stub source files by removing implementation details from input files.
    5.36 @@ -161,6 +169,7 @@
    5.37  
    5.38      void makeStub(StandardJavaFileManager fm, CompilationUnitTree tree) throws IOException {
    5.39          CompilationUnitTree tree2 = new StubMaker().translate(tree);
    5.40 +        CompilationUnitTree tree3 = new ImportCleaner(fm).removeRedundantImports(tree2);
    5.41  
    5.42          String className = fm.inferBinaryName(StandardLocation.SOURCE_PATH, tree.getSourceFile());
    5.43          JavaFileObject fo = fm.getJavaFileForOutput(StandardLocation.SOURCE_OUTPUT,
    5.44 @@ -168,7 +177,7 @@
    5.45          // System.err.println("Writing " + className + " to " + fo.getName());
    5.46          Writer out = fo.openWriter();
    5.47          try {
    5.48 -            new Pretty(out, true).printExpr((JCTree) tree2);
    5.49 +            new Pretty(out, true).printExpr((JCTree) tree3);
    5.50          } finally {
    5.51              out.close();
    5.52          }
    5.53 @@ -272,6 +281,53 @@
    5.54          }
    5.55      }
    5.56  
    5.57 +    class ImportCleaner extends TreeScanner {
    5.58 +        private Set<Name> names = new HashSet<Name>();
    5.59 +        private TreeMaker m;
    5.60 +
    5.61 +        ImportCleaner(JavaFileManager fm) {
    5.62 +            // ImportCleaner itself doesn't require a filemanager, but instantiating
    5.63 +            // a TreeMaker does, indirectly (via ClassReader, sigh)
    5.64 +            Context c = new Context();
    5.65 +            c.put(JavaFileManager.class, fm);
    5.66 +            m = TreeMaker.instance(c);
    5.67 +        }
    5.68 +
    5.69 +        CompilationUnitTree removeRedundantImports(CompilationUnitTree t) {
    5.70 +            JCCompilationUnit tree = (JCCompilationUnit) t;
    5.71 +            tree.accept(this);
    5.72 +            ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
    5.73 +            for (JCTree def: tree.defs) {
    5.74 +                if (def.getTag() == JCTree.IMPORT) {
    5.75 +                    JCImport imp = (JCImport) def;
    5.76 +                    if (imp.qualid.getTag() == JCTree.SELECT) {
    5.77 +                        JCFieldAccess qualid = (JCFieldAccess) imp.qualid;
    5.78 +                        if (!qualid.name.toString().equals("*")
    5.79 +                                && !names.contains(qualid.name)) {
    5.80 +                            continue;
    5.81 +                        }
    5.82 +                    }
    5.83 +                }
    5.84 +                defs.add(def);
    5.85 +            }
    5.86 +            return m.TopLevel(tree.packageAnnotations, tree.pid, defs.toList());
    5.87 +        }
    5.88 +
    5.89 +        @Override
    5.90 +        public void visitImport(JCImport tree) { } // ignore names found in imports
    5.91 +
    5.92 +        @Override
    5.93 +        public void visitIdent(JCIdent tree) {
    5.94 +            names.add(tree.name);
    5.95 +        }
    5.96 +
    5.97 +        @Override
    5.98 +        public void visitSelect(JCFieldAccess tree) {
    5.99 +            super.visitSelect(tree);
   5.100 +            names.add(tree.name);
   5.101 +        }
   5.102 +    }
   5.103 +
   5.104      //---------- Ant Invocation ------------------------------------------------
   5.105  
   5.106      public static class Ant extends MatchingTask {
     6.1 --- a/src/share/bin/launcher.sh-template	Thu Jan 21 11:12:47 2010 -0800
     6.2 +++ b/src/share/bin/launcher.sh-template	Fri Jan 22 09:34:46 2010 -0800
     6.3 @@ -38,7 +38,7 @@
     6.4  # dependent jar files for additional dependencies.
     6.5  
     6.6  if [ "$LANGTOOLS_USE_BOOTCLASSPATH" != "no" ]; then
     6.7 -   cp=`unzip -c $mylib/#PROGRAM#.jar META-INF/MANIFEST.MF |
     6.8 +   cp=`unzip -c "$mylib/#PROGRAM#.jar" META-INF/MANIFEST.MF |
     6.9         grep "Class-Path:" |
    6.10         sed -e 's|Class-Path: *||' -e 's|\([a-z]*\.jar\) *|'"$mylib"'/\1:|g'`
    6.11     bcp="$mylib/#PROGRAM#.jar":$cp 
     7.1 --- a/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java	Thu Jan 21 11:12:47 2010 -0800
     7.2 +++ b/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java	Fri Jan 22 09:34:46 2010 -0800
     7.3 @@ -309,7 +309,7 @@
     7.4      }
     7.5  
     7.6      protected static String toBinaryName(String relativePath, String sep) {
     7.7 -        return removeExtension(relativePath).replaceAll(sep, ".");
     7.8 +        return removeExtension(relativePath).replace(sep, ".");
     7.9      }
    7.10  
    7.11      protected static String removeExtension(String fileName) {
     8.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Jan 21 11:12:47 2010 -0800
     8.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Jan 22 09:34:46 2010 -0800
     8.3 @@ -2613,12 +2613,12 @@
     8.4              body = toP(F.at(identPos).AnonymousClassDef(mods1, defs));
     8.5          }
     8.6          if (args.isEmpty() && body == null)
     8.7 -            createPos = Position.NOPOS;
     8.8 -        JCIdent ident = F.at(Position.NOPOS).Ident(enumName);
     8.9 +            createPos = identPos;
    8.10 +        JCIdent ident = F.at(identPos).Ident(enumName);
    8.11          JCNewClass create = F.at(createPos).NewClass(null, typeArgs, ident, args, body);
    8.12 -        if (createPos != Position.NOPOS)
    8.13 +        if (createPos != identPos)
    8.14              storeEnd(create, S.prevEndPos());
    8.15 -        ident = F.at(Position.NOPOS).Ident(enumName);
    8.16 +        ident = F.at(identPos).Ident(enumName);
    8.17          JCTree result = toP(F.at(pos).VarDef(mods, name, ident, create));
    8.18          attach(result, dc);
    8.19          return result;
     9.1 --- a/src/share/classes/com/sun/tools/javac/parser/Keywords.java	Thu Jan 21 11:12:47 2010 -0800
     9.2 +++ b/src/share/classes/com/sun/tools/javac/parser/Keywords.java	Fri Jan 22 09:34:46 2010 -0800
     9.3 @@ -51,12 +51,10 @@
     9.4          return instance;
     9.5      }
     9.6  
     9.7 -    private final Log log;
     9.8      private final Names names;
     9.9  
    9.10      protected Keywords(Context context) {
    9.11          context.put(keywordsKey, this);
    9.12 -        log = Log.instance(context);
    9.13          names = Names.instance(context);
    9.14  
    9.15          for (Token t : Token.values()) {
    10.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Jan 21 11:12:47 2010 -0800
    10.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Jan 22 09:34:46 2010 -0800
    10.3 @@ -704,7 +704,7 @@
    10.4      {0}; overridden method is a bridge method
    10.5  
    10.6  compiler.warn.pkg-info.already.seen=\
    10.7 -    [package-info] a package-info.java file has already been seen for package {0}
    10.8 +    a package-info.java file has already been seen for package {0}
    10.9  compiler.warn.path.element.not.found=\
   10.10      [path] bad path element "{0}": no such file or directory
   10.11  compiler.warn.possible.fall-through.into.case=\
    11.1 --- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Jan 21 11:12:47 2010 -0800
    11.2 +++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Fri Jan 22 09:34:46 2010 -0800
    11.3 @@ -468,6 +468,10 @@
    11.4                  print(" throws ");
    11.5                  printExprs(tree.thrown);
    11.6              }
    11.7 +            if (tree.defaultValue != null) {
    11.8 +                print(" default ");
    11.9 +                printExpr(tree.defaultValue);
   11.10 +            }
   11.11              if (tree.body != null) {
   11.12                  print(" ");
   11.13                  printStat(tree.body);
   11.14 @@ -1148,20 +1152,7 @@
   11.15  
   11.16      // Prints the inner element type of a nested array
   11.17      private void printBaseElementType(JCTree tree) throws IOException {
   11.18 -        switch (tree.getTag()) {
   11.19 -        case JCTree.TYPEARRAY:
   11.20 -            printBaseElementType(((JCArrayTypeTree)tree).elemtype);
   11.21 -            return;
   11.22 -        case JCTree.WILDCARD:
   11.23 -            printBaseElementType(((JCWildcard)tree).inner);
   11.24 -            return;
   11.25 -        case JCTree.ANNOTATED_TYPE:
   11.26 -            printBaseElementType(((JCAnnotatedType)tree).underlyingType);
   11.27 -            return;
   11.28 -        default:
   11.29 -            printExpr(tree);
   11.30 -            return;
   11.31 -        }
   11.32 +        printExpr(TreeInfo.innermostType(tree));
   11.33      }
   11.34  
   11.35      // prints the brackets of a nested array in reverse order
    12.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu Jan 21 11:12:47 2010 -0800
    12.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Fri Jan 22 09:34:46 2010 -0800
    12.3 @@ -891,4 +891,17 @@
    12.4              throw new AssertionError("Unexpected type tree: " + tree);
    12.5          }
    12.6      }
    12.7 +
    12.8 +    public static JCTree innermostType(JCTree type) {
    12.9 +        switch (type.getTag()) {
   12.10 +        case JCTree.TYPEARRAY:
   12.11 +            return innermostType(((JCArrayTypeTree)type).elemtype);
   12.12 +        case JCTree.WILDCARD:
   12.13 +            return innermostType(((JCWildcard)type).inner);
   12.14 +        case JCTree.ANNOTATED_TYPE:
   12.15 +            return innermostType(((JCAnnotatedType)type).underlyingType);
   12.16 +        default:
   12.17 +            return type;
   12.18 +        }
   12.19 +    }
   12.20  }
    13.1 --- a/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java	Thu Jan 21 11:12:47 2010 -0800
    13.2 +++ b/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java	Fri Jan 22 09:34:46 2010 -0800
    13.3 @@ -49,7 +49,7 @@
    13.4  
    13.5      /** Tabulator character.
    13.6       */
    13.7 -    final static byte TAB   = 0x8;
    13.8 +    final static byte TAB   = 0x9;
    13.9  
   13.10      /** Line feed character.
   13.11       */
    14.1 --- a/src/share/classes/com/sun/tools/javac/util/Log.java	Thu Jan 21 11:12:47 2010 -0800
    14.2 +++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Fri Jan 22 09:34:46 2010 -0800
    14.3 @@ -145,7 +145,10 @@
    14.4          private int getIntOption(Options options, String optionName, int defaultValue) {
    14.5              String s = options.get(optionName);
    14.6              try {
    14.7 -                if (s != null) return Integer.parseInt(s);
    14.8 +                if (s != null) {
    14.9 +                    int n = Integer.parseInt(s);
   14.10 +                    return (n <= 0 ? Integer.MAX_VALUE : n);
   14.11 +                }
   14.12              } catch (NumberFormatException e) {
   14.13                  // silently ignore ill-formed numbers
   14.14              }
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/tools/javac/T6326754.java	Fri Jan 22 09:34:46 2010 -0800
    15.3 @@ -0,0 +1,76 @@
    15.4 +/*
    15.5 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
    15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 + *
    15.8 + * This code is free software; you can redistribute it and/or modify it
    15.9 + * under the terms of the GNU General Public License version 2 only, as
   15.10 + * published by the Free Software Foundation.
   15.11 + *
   15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 + * version 2 for more details (a copy is included in the LICENSE file that
   15.16 + * accompanied this code).
   15.17 + *
   15.18 + * You should have received a copy of the GNU General Public License version
   15.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 + *
   15.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   15.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   15.24 + * have any questions.
   15.25 + */
   15.26 +
   15.27 +/*
   15.28 + * @test
   15.29 + * @bug 6326754
   15.30 + * @summary Compiler will fail to handle -Xmaxerrs with -ve numbers
   15.31 + *
   15.32 + * @compile/fail/ref=T6326754.out -XDrawDiagnostics -Xmaxerrs -1 T6326754.java
   15.33 + * @compile/fail/ref=T6326754.out -XDrawDiagnostics -Xmaxerrs  0 T6326754.java
   15.34 + * @compile/fail/ref=T6326754.out -XDrawDiagnostics -Xmaxerrs 10 T6326754.java
   15.35 + * @compile/fail/ref=T6326754.out -XDrawDiagnostics              T6326754.java
   15.36 + */
   15.37 +class TestConstructor<T,K>{
   15.38 +    T t;
   15.39 +    K k;
   15.40 +    public TestConstructor(T t,K k){
   15.41 +        this.t =t;
   15.42 +    }
   15.43 +    public TestConstructor(K k){
   15.44 +        this.k = k;
   15.45 +        this.t = null;
   15.46 +    }
   15.47 +    public TestConstructor(T t){
   15.48 +        this.t=t;
   15.49 +        this.k=null;
   15.50 +    }
   15.51 +    public void setT(T t){
   15.52 +        this.t=t;
   15.53 +        this.k=null;
   15.54 +    }
   15.55 +    public void setT(K k){
   15.56 +        this.k = k;
   15.57 +        this.t = null;
   15.58 +    }
   15.59 +    public void setT(T t,K k){
   15.60 +        this.t = t;
   15.61 +        this.k = k;
   15.62 +    }
   15.63 +}
   15.64 +class TestC<T>{
   15.65 +    T t;
   15.66 +    public <T>void setT(T t){
   15.67 +        this.t = t;
   15.68 +    }
   15.69 +}
   15.70 +public class T6326754{
   15.71 +    public static void main(String... arg){
   15.72 +        TestC tC =new TestC();
   15.73 +        tC.setT();
   15.74 +        TestConstructor tc = new TestConstructor("saaa");
   15.75 +        tc.setT("sasa");
   15.76 +        TestC<Integer> tC1 = new TestC();
   15.77 +        tC1.setT(545);
   15.78 +    }
   15.79 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/tools/javac/T6326754.out	Fri Jan 22 09:34:46 2010 -0800
    16.3 @@ -0,0 +1,7 @@
    16.4 +T6326754.java:44:12: compiler.err.name.clash.same.erasure: TestConstructor(T), TestConstructor(K)
    16.5 +T6326754.java:52:17: compiler.err.name.clash.same.erasure: setT(K), setT(T)
    16.6 +T6326754.java:64:18: compiler.err.prob.found.req: (compiler.misc.incompatible.types), T, T
    16.7 +T6326754.java:70:11: compiler.err.cant.apply.symbol: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, null
    16.8 +- compiler.note.unchecked.filename: T6326754.java
    16.9 +- compiler.note.unchecked.recompile
   16.10 +4 errors
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/tools/javac/T6472751.java	Fri Jan 22 09:34:46 2010 -0800
    17.3 @@ -0,0 +1,81 @@
    17.4 +/*
    17.5 + * Copyright 2006-2010 Sun Microsystems, Inc.  All Rights Reserved.
    17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 + *
    17.8 + * This code is free software; you can redistribute it and/or modify it
    17.9 + * under the terms of the GNU General Public License version 2 only, as
   17.10 + * published by the Free Software Foundation.
   17.11 + *
   17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.15 + * version 2 for more details (a copy is included in the LICENSE file that
   17.16 + * accompanied this code).
   17.17 + *
   17.18 + * You should have received a copy of the GNU General Public License version
   17.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.21 + *
   17.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   17.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   17.24 + * have any questions.
   17.25 + */
   17.26 +
   17.27 +/*
   17.28 + * @test
   17.29 + * @bug 6472751
   17.30 + * @summary SourcePositions.getStartPos returns incorrect value for enum constants
   17.31 + * @author Peter Ahe
   17.32 + */
   17.33 +
   17.34 +import com.sun.source.tree.CompilationUnitTree;
   17.35 +import com.sun.source.tree.Tree;
   17.36 +import com.sun.source.tree.Tree.Kind;
   17.37 +import com.sun.source.util.JavacTask;
   17.38 +import com.sun.source.util.SourcePositions;
   17.39 +import com.sun.source.util.TreeScanner;
   17.40 +import com.sun.source.util.Trees;
   17.41 +import com.sun.tools.javac.util.List;
   17.42 +import java.io.IOException;
   17.43 +import java.net.URI;
   17.44 +import javax.tools.JavaCompiler;
   17.45 +import javax.tools.JavaFileObject;
   17.46 +import javax.tools.SimpleJavaFileObject;
   17.47 +import javax.tools.ToolProvider;
   17.48 +
   17.49 +public class T6472751 {
   17.50 +    static class MyFileObject extends SimpleJavaFileObject {
   17.51 +        public MyFileObject() {
   17.52 +            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
   17.53 +        }
   17.54 +        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
   17.55 +            return "public enum Test { ABC, DEF; }";
   17.56 +        }
   17.57 +    }
   17.58 +    static Trees trees;
   17.59 +    static SourcePositions positions;
   17.60 +    public static void main(String[] args) throws IOException {
   17.61 +        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
   17.62 +        JavacTask task = (JavacTask) compiler.getTask(null, null, null, null, null, List.of(new MyFileObject()));
   17.63 +        trees = Trees.instance(task);
   17.64 +        positions = trees.getSourcePositions();
   17.65 +        Iterable<? extends CompilationUnitTree> asts = task.parse();
   17.66 +        for (CompilationUnitTree ast : asts) {
   17.67 +            new MyVisitor().scan(ast, null);
   17.68 +        }
   17.69 +    }
   17.70 +
   17.71 +    static class MyVisitor extends TreeScanner<Void,Void> {
   17.72 +        @Override
   17.73 +        public Void scan(Tree node, Void ignored) {
   17.74 +            if (node == null)
   17.75 +                return null;
   17.76 +            Kind k = node.getKind();
   17.77 +            long pos = positions.getStartPosition(null,node);
   17.78 +            System.out.format("%s: %s%n", k, pos);
   17.79 +            if (k != Kind.MODIFIERS && pos < 0)
   17.80 +                throw new Error("unexpected position found");
   17.81 +            return super.scan(node, ignored);
   17.82 +        }
   17.83 +    }
   17.84 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/tools/javac/T6567414.java	Fri Jan 22 09:34:46 2010 -0800
    18.3 @@ -0,0 +1,11 @@
    18.4 +/*
    18.5 + * @test /nodynamiccopyright/
    18.6 + * @bug 6567414
    18.7 + * @summary javac compiler reports no source file or line on enum constant declaration error
    18.8 + * @compile/fail/ref=T6567414.out -XDrawDiagnostics T6567414.java
    18.9 + */
   18.10 +enum Test {
   18.11 +  FOO;
   18.12 +  Test() throws Exception {}
   18.13 +}
   18.14 +
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/tools/javac/T6567414.out	Fri Jan 22 09:34:46 2010 -0800
    19.3 @@ -0,0 +1,2 @@
    19.4 +T6567414.java:8:3: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
    19.5 +1 error
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/tools/javac/T6665791.java	Fri Jan 22 09:34:46 2010 -0800
    20.3 @@ -0,0 +1,81 @@
    20.4 +/*
    20.5 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
    20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 + *
    20.8 + * This code is free software; you can redistribute it and/or modify it
    20.9 + * under the terms of the GNU General Public License version 2 only, as
   20.10 + * published by the Free Software Foundation.
   20.11 + *
   20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 + * version 2 for more details (a copy is included in the LICENSE file that
   20.16 + * accompanied this code).
   20.17 + *
   20.18 + * You should have received a copy of the GNU General Public License version
   20.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 + *
   20.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   20.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   20.24 + * have any questions.
   20.25 + */
   20.26 +
   20.27 +/*
   20.28 + * @test
   20.29 + * @bug 6665791
   20.30 + * @summary com.sun.source.tree.MethodTree.toString() does not output default values
   20.31 + */
   20.32 +
   20.33 +import java.io.File;
   20.34 +import java.io.IOException;
   20.35 +import java.io.StringWriter;
   20.36 +import javax.tools.JavaCompiler;
   20.37 +import javax.tools.JavaFileObject;
   20.38 +import javax.tools.StandardJavaFileManager;
   20.39 +import javax.tools.ToolProvider;
   20.40 +import com.sun.source.tree.ClassTree;
   20.41 +import com.sun.source.util.JavacTask;
   20.42 +import com.sun.source.util.TreeScanner;
   20.43 +import java.io.FileWriter;
   20.44 +
   20.45 +public class T6665791 {
   20.46 +    static String test = "public @interface Annotation { boolean booleanProperty() default false; }";
   20.47 +    static File test_java = new File("Test.java");
   20.48 +
   20.49 +    public static void main(String[] args) throws Exception {
   20.50 +        write(test_java, test);
   20.51 +
   20.52 +        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
   20.53 +        StandardJavaFileManager manager =
   20.54 +                compiler.getStandardFileManager(null, null, null);
   20.55 +        Iterable<? extends JavaFileObject> units = manager.getJavaFileObjects(test_java);
   20.56 +        final StringWriter sw = new StringWriter();
   20.57 +        JavacTask task = (JavacTask) compiler.getTask(sw, manager, null, null,
   20.58 +                null, units);
   20.59 +
   20.60 +        new TreeScanner<Boolean, Void>() {
   20.61 +            @Override
   20.62 +            public Boolean visitClass(ClassTree arg0, Void arg1) {
   20.63 +                sw.write(arg0.toString());
   20.64 +                return super.visitClass(arg0, arg1);
   20.65 +            }
   20.66 +        }.scan(task.parse(), null);
   20.67 +
   20.68 +        System.out.println("output:");
   20.69 +        System.out.println(sw.toString());
   20.70 +        String found = sw.toString().replaceAll("\\s+", " ").trim();
   20.71 +        String expect = test.replaceAll("\\s+", " ").trim();
   20.72 +        if (!expect.equals(found)) {
   20.73 +            System.out.println("expect: " + expect);
   20.74 +            System.out.println("found:  " + found);
   20.75 +            throw new Exception("unexpected output");
   20.76 +        }
   20.77 +    }
   20.78 +
   20.79 +    static void write(File file, String body) throws IOException {
   20.80 +        FileWriter out = new FileWriter(file);
   20.81 +        out.write(body);
   20.82 +        out.close();
   20.83 +    }
   20.84 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/tools/javac/T6855236.java	Fri Jan 22 09:34:46 2010 -0800
    21.3 @@ -0,0 +1,95 @@
    21.4 +/*
    21.5 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + *
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + *
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + *
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + *
   21.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   21.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   21.24 + * have any questions.
   21.25 + */
   21.26 +
   21.27 +/*
   21.28 + * @test
   21.29 + * @bug 6855236
   21.30 + * @summary Compiler Tree API TreePath class generates NullPointerException from Iterator
   21.31 + * @compile T6855236.java
   21.32 + * @compile -processor T6855236 -proc:only T6855236.java
   21.33 + */
   21.34 +
   21.35 +import java.util.*;
   21.36 +
   21.37 +import javax.annotation.processing.*;
   21.38 +import javax.lang.model.*;
   21.39 +import javax.lang.model.element.*;
   21.40 +
   21.41 +import com.sun.source.tree.*;
   21.42 +import com.sun.source.util.*;
   21.43 +
   21.44 +@SupportedSourceVersion(SourceVersion.RELEASE_6)
   21.45 +@SupportedAnnotationTypes("*")
   21.46 +public class T6855236 extends AbstractProcessor {
   21.47 +
   21.48 +    private Trees trees;
   21.49 +
   21.50 +    @Override
   21.51 +    public void init(ProcessingEnvironment pe) {
   21.52 +        super.init(pe);
   21.53 +        trees = Trees.instance(pe);
   21.54 +    }
   21.55 +
   21.56 +    @Override
   21.57 +    public boolean process(Set<? extends TypeElement> arg0, RoundEnvironment roundEnvironment) {
   21.58 +        // Scanner class to scan through various component elements
   21.59 +        CodeVisitor visitor = new CodeVisitor();
   21.60 +
   21.61 +        for (Element e : roundEnvironment.getRootElements()) {
   21.62 +            TreePath tp = trees.getPath(e);
   21.63 +            visitor.scan(tp, trees);
   21.64 +        }
   21.65 +
   21.66 +        return true;
   21.67 +    }
   21.68 +
   21.69 +    class CodeVisitor extends TreePathScanner<Object, Trees> {
   21.70 +
   21.71 +        @Override
   21.72 +        public Object visitMethodInvocation(MethodInvocationTree node, Trees p) {
   21.73 +            System.out.print("current path: ");
   21.74 +            for (Tree t : getCurrentPath()) {
   21.75 +                System.out.print('/');
   21.76 +                System.out.print(t);
   21.77 +           }
   21.78 +            System.out.println();
   21.79 +            System.out.println("parent path: " + getCurrentPath().getParentPath());
   21.80 +            System.out.println("method select: " + node.getMethodSelect().toString());
   21.81 +            for (ExpressionTree arg : node.getArguments()) {
   21.82 +                System.out.println("argument: " + arg.toString());
   21.83 +            }
   21.84 +            return super.visitMethodInvocation(node, p);
   21.85 +        }
   21.86 +
   21.87 +        @Override
   21.88 +        public Object visitExpressionStatement(ExpressionStatementTree node, Trees p) {
   21.89 +            ExpressionTree t = node.getExpression();
   21.90 +            System.out.println("expression statement: " + t.toString());
   21.91 +            return super.visitExpressionStatement(node, p);
   21.92 +        }
   21.93 +
   21.94 +    }
   21.95 +
   21.96 +}
   21.97 +
   21.98 +
    22.1 --- a/test/tools/javac/nio/compileTest/CompileTest.java	Thu Jan 21 11:12:47 2010 -0800
    22.2 +++ b/test/tools/javac/nio/compileTest/CompileTest.java	Fri Jan 22 09:34:46 2010 -0800
    22.3 @@ -23,7 +23,9 @@
    22.4  
    22.5  /**
    22.6   * @test
    22.7 - * @compile HelloPathWorld.java
    22.8 + * @bug 6906175 6915476 6915497
    22.9 + * @summary Path-based JavaFileManager
   22.10 + * @compile -g HelloPathWorld.java
   22.11   * @run main CompileTest
   22.12   */
   22.13  
   22.14 @@ -92,7 +94,8 @@
   22.15          options.addAll(Arrays.asList(opts));
   22.16          options.addAll(Arrays.asList(
   22.17                  "-verbose", "-XDverboseCompilePolicy",
   22.18 -                "-d", classes.toString()
   22.19 +                "-d", classes.toString(),
   22.20 +                "-g"
   22.21          ));
   22.22          Iterable<? extends JavaFileObject> compilationUnits =
   22.23                  fm.getJavaFileObjects(testSrcDir.resolve(className + ".java"));
   22.24 @@ -109,6 +112,8 @@
   22.25          File expect = new File("classes." + count + "/" + className + ".class");
   22.26          if (!expect.exists())
   22.27              throw new Exception("expected file not found: " + expect);
   22.28 +        // Note that we explicitly specify -g for compiling both the actual class and the expected class.
   22.29 +        // This isolates the expected class from javac options that might be given to jtreg.
   22.30          long expectedSize = new File(testClassesDir.toString(), className + ".class").length();
   22.31          long actualSize = expect.length();
   22.32          if (expectedSize != actualSize)

mercurial