Merge

Wed, 19 Feb 2014 18:24:56 -0800

author
lana
date
Wed, 19 Feb 2014 18:24:56 -0800
changeset 2283
c09305701001
parent 2282
395fcc4a59ce
parent 2281
b06e33ab7f61
child 2284
a07271bca831
child 2287
b2bc7b778287

Merge

     1.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Mon Feb 17 15:52:34 2014 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Wed Feb 19 18:24:56 2014 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -30,6 +30,7 @@
    1.11  import java.util.Collection;
    1.12  import java.util.EnumSet;
    1.13  import java.util.HashMap;
    1.14 +import java.util.HashSet;
    1.15  import java.util.Map;
    1.16  import java.util.Set;
    1.17  import javax.tools.JavaFileManager.Location;
    1.18 @@ -238,10 +239,13 @@
    1.19              files = lb.toList();
    1.20          }
    1.21  
    1.22 +        Set<JavaFileObject> ufiles = new HashSet<>();
    1.23          for (JavaFileObject fo : files) {
    1.24 -            // messager.notice("main.Loading_source_file", fn);
    1.25 -            trees.append(parse(fo));
    1.26 -            hasFiles = true;
    1.27 +            if (ufiles.add(fo)) { // ignore duplicates
    1.28 +                // messager.notice("main.Loading_source_file", fn);
    1.29 +                trees.append(parse(fo));
    1.30 +                hasFiles = true;
    1.31 +            }
    1.32          }
    1.33  
    1.34          if (!hasFiles) {
     2.1 --- a/src/share/classes/com/sun/tools/javap/JavapTask.java	Mon Feb 17 15:52:34 2014 -0800
     2.2 +++ b/src/share/classes/com/sun/tools/javap/JavapTask.java	Wed Feb 19 18:24:56 2014 -0800
     2.3 @@ -309,7 +309,9 @@
     2.4              void process(JavapTask task, String opt, String arg) throws BadArgs {
     2.5                  int sep = opt.indexOf(":");
     2.6                  try {
     2.7 -                    task.options.indentWidth = Integer.valueOf(opt.substring(sep + 1));
     2.8 +                    int i = Integer.valueOf(opt.substring(sep + 1));
     2.9 +                    if (i > 0) // silently ignore invalid values
    2.10 +                        task.options.indentWidth = i;
    2.11                  } catch (NumberFormatException e) {
    2.12                  }
    2.13              }
    2.14 @@ -325,7 +327,9 @@
    2.15              void process(JavapTask task, String opt, String arg) throws BadArgs {
    2.16                  int sep = opt.indexOf(":");
    2.17                  try {
    2.18 -                    task.options.tabColumn = Integer.valueOf(opt.substring(sep + 1));
    2.19 +                    int i = Integer.valueOf(opt.substring(sep + 1));
    2.20 +                    if (i > 0) // silently ignore invalid values
    2.21 +                        task.options.tabColumn = i;
    2.22                  } catch (NumberFormatException e) {
    2.23                  }
    2.24              }
    2.25 @@ -466,7 +470,7 @@
    2.26          } catch (BadArgs e) {
    2.27              reportError(e.key, e.args);
    2.28              if (e.showUsage) {
    2.29 -                log.println(getMessage("main.usage.summary", progname));
    2.30 +                printLines(getMessage("main.usage.summary", progname));
    2.31              }
    2.32              return EXIT_CMDERR;
    2.33          } catch (InternalError e) {
    2.34 @@ -882,27 +886,33 @@
    2.35      }
    2.36  
    2.37      private void showHelp() {
    2.38 -        log.println(getMessage("main.usage", progname));
    2.39 +        printLines(getMessage("main.usage", progname));
    2.40          for (Option o: recognizedOptions) {
    2.41              String name = o.aliases[0].substring(1); // there must always be at least one name
    2.42              if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify"))
    2.43                  continue;
    2.44 -            log.println(getMessage("main.opt." + name));
    2.45 +            printLines(getMessage("main.opt." + name));
    2.46          }
    2.47          String[] fmOptions = { "-classpath", "-cp", "-bootclasspath" };
    2.48          for (String o: fmOptions) {
    2.49              if (fileManager.isSupportedOption(o) == -1)
    2.50                  continue;
    2.51              String name = o.substring(1);
    2.52 -            log.println(getMessage("main.opt." + name));
    2.53 +            printLines(getMessage("main.opt." + name));
    2.54          }
    2.55  
    2.56      }
    2.57  
    2.58      private void showVersion(boolean full) {
    2.59 -        log.println(version(full ? "full" : "release"));
    2.60 +        printLines(version(full ? "full" : "release"));
    2.61      }
    2.62  
    2.63 +    private void printLines(String msg) {
    2.64 +        log.println(msg.replace("\n", nl));
    2.65 +    }
    2.66 +
    2.67 +    private static final String nl = System.getProperty("line.separator");
    2.68 +
    2.69      private static final String versionRBName = "com.sun.tools.javap.resources.version";
    2.70      private static ResourceBundle versionRB;
    2.71  
     3.1 --- a/src/share/classes/com/sun/tools/javap/Options.java	Mon Feb 17 15:52:34 2014 -0800
     3.2 +++ b/src/share/classes/com/sun/tools/javap/Options.java	Wed Feb 19 18:24:56 2014 -0800
     3.3 @@ -86,8 +86,8 @@
     3.4      public boolean showConstants;
     3.5      public boolean sysInfo;
     3.6      public boolean showInnerClasses;
     3.7 -    public int indentWidth = 2;   // #spaces per indentWidth level
     3.8 -    public int tabColumn = 40;    // column number for comments
     3.9 +    public int indentWidth = 2;   // #spaces per indentWidth level; must be > 0
    3.10 +    public int tabColumn = 40;    // column number for comments; must be > 0
    3.11  
    3.12      public boolean compat;             // bug-for-bug compatibility mode with old javap
    3.13  }
     4.1 --- a/test/tools/javadoc/parser/7091528/T7091528.java	Mon Feb 17 15:52:34 2014 -0800
     4.2 +++ b/test/tools/javadoc/parser/7091528/T7091528.java	Wed Feb 19 18:24:56 2014 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -23,8 +23,8 @@
    4.11  
    4.12  /**
    4.13   * @test
    4.14 - * @bug     7091528
    4.15 - * @summary javadoc attempts to parse .class files
    4.16 + * @bug     7091528 8029145
    4.17 + * @summary ensures javadoc parses unique source files and ignores all class files
    4.18   * @compile p/C1.java p/q/C2.java
    4.19   * @run main T7091528
    4.20   */
    4.21 @@ -37,17 +37,22 @@
    4.22      public static void main(String... args) {
    4.23          new T7091528().run();
    4.24      }
    4.25 -
    4.26      void run() {
    4.27          File testSrc = new File(System.getProperty("test.src"));
    4.28          File testClasses = new File(System.getProperty("test.classes"));
    4.29 -        String[] args = {
    4.30 -            "-d", ".",
    4.31 +        // 7091528, tests if class files are being ignored
    4.32 +        runTest("-d", ".",
    4.33              "-sourcepath", testClasses + File.pathSeparator + testSrc,
    4.34              "-subpackages",
    4.35 -            "p"
    4.36 -        };
    4.37 +            "p");
    4.38 +        // 8029145, tests if unique source files are parsed
    4.39 +        runTest("-d", ".",
    4.40 +            "-sourcepath", testSrc.getAbsolutePath(),
    4.41 +            "-subpackages",
    4.42 +            "p:p.q");
    4.43  
    4.44 +    }
    4.45 +    void runTest(String... args) {
    4.46          StringWriter sw = new StringWriter();
    4.47          PrintWriter pw = new PrintWriter(sw);
    4.48          String doclet = com.sun.tools.doclets.standard.Standard.class.getName();
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/tools/javap/T8033180.java	Wed Feb 19 18:24:56 2014 -0800
     5.3 @@ -0,0 +1,88 @@
     5.4 +/*
     5.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.
    5.11 + *
    5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.15 + * version 2 for more details (a copy is included in the LICENSE file that
    5.16 + * accompanied this code).
    5.17 + *
    5.18 + * You should have received a copy of the GNU General Public License version
    5.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.21 + *
    5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.23 + * or visit www.oracle.com if you need additional information or have any
    5.24 + * questions.
    5.25 + */
    5.26 +
    5.27 +/*
    5.28 + * @test
    5.29 + * @bug 8033180
    5.30 + * @summary Bad newline characters
    5.31 + */
    5.32 +
    5.33 +import java.io.*;
    5.34 +import java.util.*;
    5.35 +
    5.36 +public class T8033180 {
    5.37 +
    5.38 +    public static void main(String... args) throws Exception {
    5.39 +        new T8033180().run();
    5.40 +    }
    5.41 +
    5.42 +    void run() throws Exception {
    5.43 +        // fast-track this case, because test cannot fail in this case
    5.44 +        if (lineSep.equals(nl))
    5.45 +            return;
    5.46 +
    5.47 +        test("-help");
    5.48 +        test("-version");
    5.49 +
    5.50 +        if (errors > 0)
    5.51 +            throw new Exception(errors + " errors occurred");
    5.52 +    }
    5.53 +
    5.54 +    static final String lineSep = System.getProperty("line.separator");
    5.55 +    static final String nl = "\n";
    5.56 +
    5.57 +    void test(String... opts) throws Exception {
    5.58 +        System.err.println("test " + Arrays.asList(opts));
    5.59 +        List<String> args = new ArrayList<String>();
    5.60 +        args.addAll(Arrays.asList(opts));
    5.61 +        StringWriter sw = new StringWriter();
    5.62 +        PrintWriter pw = new PrintWriter(sw);
    5.63 +        int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
    5.64 +        pw.close();
    5.65 +        String out = sw.toString();
    5.66 +        if (rc != 0)
    5.67 +            throw new Exception("javap failed unexpectedly: rc=" + rc);
    5.68 +
    5.69 +        // remove all valid platform newline sequences
    5.70 +        String out2 = out.replace(lineSep, "");
    5.71 +
    5.72 +        // count the remaining simple newline characters
    5.73 +        int count = 0;
    5.74 +        int i = out2.indexOf(nl, 0);
    5.75 +        while (i != -1) {
    5.76 +            count++;
    5.77 +            i = out2.indexOf(nl, i + nl.length());
    5.78 +        }
    5.79 +
    5.80 +        if (count > 0)
    5.81 +            error(count + " newline characters found");
    5.82 +    }
    5.83 +
    5.84 +    void error(String msg) {
    5.85 +        System.err.println("Error: " + msg);
    5.86 +        errors++;
    5.87 +    }
    5.88 +
    5.89 +    int errors = 0;
    5.90 +}
    5.91 +

mercurial