changeset 2352:a07271bca831 jdk8u20-b03

Merge
author lana
date Wed, 19 Feb 2014 21:01:41 -0800
parents 043a73c7e343 c09305701001
children 613c1d9930c9
files .hgtags
diffstat 17 files changed, 620 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Feb 19 13:14:43 2014 -0800
+++ b/.hgtags	Wed Feb 19 21:01:41 2014 -0800
@@ -248,4 +248,9 @@
 d5aab8300d3b51e8043ab5fe5832ef6c6cbb5552 jdk8u20-b00
 436176151e85455e74cd1441a2ba96e791c56785 jdk8-b124
 79dc4b992c0a385c1364592801781b747b85c6ca jdk8u20-b01
+436176151e85455e74cd1441a2ba96e791c56785 jdk8-b125
+ba24b63043626003929927f091e8b84190f39261 jdk8-b126
+bb69217ed81202b1a490dc7150dc7cd073689341 jdk8-b127
+09cdd3b493c0d13dc32206e5f12bb1a2f7465687 jdk8-b128
+8fe7202d3c38784f3f14368e3954fc4e0394afa4 jdk8-b129
 26b33a6ea08810853af37e81c9b435465b289c98 jdk8u20-b02
--- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Wed Feb 19 13:14:43 2014 -0800
+++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java	Wed Feb 19 21:01:41 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1172,8 +1172,10 @@
                             DCText string = quotedString();
                             if (string != null) {
                                 skipWhitespace();
-                                if (ch == '@')
+                                if (ch == '@'
+                                        || ch == EOI && bp == buf.length - 1) {
                                     return m.at(pos).See(List.<DCTree>of(string));
+                                }
                             }
                             break;
 
--- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Wed Feb 19 13:14:43 2014 -0800
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Wed Feb 19 21:01:41 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import java.util.Collection;
 import java.util.EnumSet;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import javax.tools.JavaFileManager.Location;
@@ -238,10 +239,13 @@
             files = lb.toList();
         }
 
+        Set<JavaFileObject> ufiles = new HashSet<>();
         for (JavaFileObject fo : files) {
-            // messager.notice("main.Loading_source_file", fn);
-            trees.append(parse(fo));
-            hasFiles = true;
+            if (ufiles.add(fo)) { // ignore duplicates
+                // messager.notice("main.Loading_source_file", fn);
+                trees.append(parse(fo));
+                hasFiles = true;
+            }
         }
 
         if (!hasFiles) {
--- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Wed Feb 19 13:14:43 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Wed Feb 19 21:01:41 2014 -0800
@@ -547,7 +547,6 @@
         for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
             w.write(entry);
         }
-        println();
         indent(-1);
         return null;
     }
@@ -559,7 +558,6 @@
         for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
             w.write(entry);
         }
-        println();
         indent(-1);
         return null;
     }
@@ -571,14 +569,12 @@
         }
 
         public Void visit_same_frame(StackMapTable_attribute.same_frame frame, Void p) {
-            printHeader(frame);
-            println(" /* same */");
+            printHeader(frame, "/* same */");
             return null;
         }
 
         public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) {
-            printHeader(frame);
-            println(" /* same_locals_1_stack_item */");
+            printHeader(frame, "/* same_locals_1_stack_item */");
             indent(+1);
             printMap("stack", frame.stack);
             indent(-1);
@@ -586,8 +582,7 @@
         }
 
         public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) {
-            printHeader(frame);
-            println(" /* same_locals_1_stack_item_frame_extended */");
+            printHeader(frame, "/* same_locals_1_stack_item_frame_extended */");
             indent(+1);
             println("offset_delta = " + frame.offset_delta);
             printMap("stack", frame.stack);
@@ -596,8 +591,7 @@
         }
 
         public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) {
-            printHeader(frame);
-            println(" /* chop */");
+            printHeader(frame, "/* chop */");
             indent(+1);
             println("offset_delta = " + frame.offset_delta);
             indent(-1);
@@ -605,8 +599,7 @@
         }
 
         public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) {
-            printHeader(frame);
-            println(" /* same_frame_extended */");
+            printHeader(frame, "/* same_frame_extended */");
             indent(+1);
             println("offset_delta = " + frame.offset_delta);
             indent(-1);
@@ -614,21 +607,20 @@
         }
 
         public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) {
-            printHeader(frame);
-            println(" /* append */");
+            printHeader(frame, "/* append */");
             indent(+1);
             println("offset_delta = " + frame.offset_delta);
             printMap("locals", frame.locals);
+            indent(-1);
             return null;
         }
 
         public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) {
-            printHeader(frame);
             if (frame instanceof StackMap_attribute.stack_map_frame) {
+                printHeader(frame, "offset = " + frame.offset_delta);
                 indent(+1);
-                println(" offset = " + frame.offset_delta);
             } else {
-                println(" /* full_frame */");
+                printHeader(frame, "/* full_frame */");
                 indent(+1);
                 println("offset_delta = " + frame.offset_delta);
             }
@@ -638,8 +630,9 @@
             return null;
         }
 
-        void printHeader(StackMapTable_attribute.stack_map_frame frame) {
-            print("   frame_type = " + frame.frame_type);
+        void printHeader(StackMapTable_attribute.stack_map_frame frame, String extra) {
+            print("frame_type = " + frame.frame_type + " ");
+            println(extra);
         }
 
         void printMap(String name, StackMapTable_attribute.verification_type_info[] map) {
--- a/src/share/classes/com/sun/tools/javap/BasicWriter.java	Wed Feb 19 13:14:43 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/BasicWriter.java	Wed Feb 19 21:01:41 2014 -0800
@@ -151,12 +151,22 @@
             for (int i = 0; i < s.length(); i++) {
                 char c = s.charAt(i);
                 switch (c) {
+                    case ' ':
+                        pendingSpaces++;
+                        break;
+
                     case '\n':
                         println();
                         break;
+
                     default:
                         if (buffer.length() == 0)
                             indent();
+                        if (pendingSpaces > 0) {
+                            for (int sp = 0; sp < pendingSpaces; sp++)
+                                buffer.append(' ');
+                            pendingSpaces = 0;
+                        }
                         buffer.append(c);
                 }
             }
@@ -164,6 +174,8 @@
         }
 
         protected void println() {
+            // ignore/discard pending spaces
+            pendingSpaces = 0;
             out.println(buffer);
             buffer.setLength(0);
         }
@@ -173,26 +185,21 @@
         }
 
         protected void tab() {
-            if (buffer.length() == 0)
-                indent();
-            space(indentCount * indentWidth + tabColumn - buffer.length());
+            int col = indentCount * indentWidth + tabColumn;
+            pendingSpaces += (col <= buffer.length() ? 1 : col - buffer.length());
         }
 
         private void indent() {
-            space(indentCount * indentWidth);
+            pendingSpaces += (indentCount * indentWidth);
         }
 
-        private void space(int n) {
-            for (int i = 0; i < n; i++)
-                buffer.append(' ');
-        }
-
-        private PrintWriter out;
-        private StringBuilder buffer;
+        private final PrintWriter out;
+        private final StringBuilder buffer;
         private int indentCount;
-        private int indentWidth;
-        private int tabColumn;
+        private final int indentWidth;
+        private final int tabColumn;
         private boolean pendingNewline;
+        private int pendingSpaces;
     }
 }
 
--- a/src/share/classes/com/sun/tools/javap/ClassWriter.java	Wed Feb 19 13:14:43 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java	Wed Feb 19 21:01:41 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -385,6 +385,8 @@
 
         indent(+1);
 
+        boolean showBlank = false;
+
         if (options.showDescriptors)
             println("descriptor: " + getValue(f.descriptor));
 
@@ -394,12 +396,12 @@
         if (options.showAllAttrs) {
             for (Attribute attr: f.attributes)
                 attrWriter.write(f, attr, constant_pool);
-            println();
+            showBlank = true;
         }
 
         indent(-1);
 
-        if (options.showDisassembled || options.showLineAndLocalVariableTables)
+        if (showBlank || options.showDisassembled || options.showLineAndLocalVariableTables)
             println();
     }
 
@@ -498,27 +500,23 @@
                 report("Unexpected or invalid value for Code attribute");
         }
 
-        if (options.showDisassembled && !options.showAllAttrs) {
-            if (code != null) {
+        if (options.showAllAttrs) {
+            Attribute[] attrs = m.attributes.attrs;
+            for (Attribute attr: attrs)
+                attrWriter.write(m, attr, constant_pool);
+        } else if (code != null) {
+            if (options.showDisassembled) {
                 println("Code:");
                 codeWriter.writeInstrs(code);
                 codeWriter.writeExceptionTable(code);
             }
-        }
 
-        if (options.showLineAndLocalVariableTables) {
-            if (code != null) {
+            if (options.showLineAndLocalVariableTables) {
                 attrWriter.write(code, code.attributes.get(Attribute.LineNumberTable), constant_pool);
                 attrWriter.write(code, code.attributes.get(Attribute.LocalVariableTable), constant_pool);
             }
         }
 
-        if (options.showAllAttrs) {
-            Attribute[] attrs = m.attributes.attrs;
-            for (Attribute attr: attrs)
-                attrWriter.write(m, attr, constant_pool);
-        }
-
         indent(-1);
 
         // set pendingNewline to write a newline before the next method (if any)
--- a/src/share/classes/com/sun/tools/javap/JavapTask.java	Wed Feb 19 13:14:43 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/JavapTask.java	Wed Feb 19 21:01:41 2014 -0800
@@ -309,7 +309,9 @@
             void process(JavapTask task, String opt, String arg) throws BadArgs {
                 int sep = opt.indexOf(":");
                 try {
-                    task.options.indentWidth = Integer.valueOf(opt.substring(sep + 1));
+                    int i = Integer.valueOf(opt.substring(sep + 1));
+                    if (i > 0) // silently ignore invalid values
+                        task.options.indentWidth = i;
                 } catch (NumberFormatException e) {
                 }
             }
@@ -325,7 +327,9 @@
             void process(JavapTask task, String opt, String arg) throws BadArgs {
                 int sep = opt.indexOf(":");
                 try {
-                    task.options.tabColumn = Integer.valueOf(opt.substring(sep + 1));
+                    int i = Integer.valueOf(opt.substring(sep + 1));
+                    if (i > 0) // silently ignore invalid values
+                        task.options.tabColumn = i;
                 } catch (NumberFormatException e) {
                 }
             }
@@ -466,7 +470,7 @@
         } catch (BadArgs e) {
             reportError(e.key, e.args);
             if (e.showUsage) {
-                log.println(getMessage("main.usage.summary", progname));
+                printLines(getMessage("main.usage.summary", progname));
             }
             return EXIT_CMDERR;
         } catch (InternalError e) {
@@ -561,8 +565,12 @@
             }
         }
 
-        if (fileManager.handleOption(name, rest))
-            return;
+        try {
+            if (fileManager.handleOption(name, rest))
+                return;
+        } catch (IllegalArgumentException e) {
+            throw new BadArgs("err.invalid.use.of.option", name).showUsage(true);
+        }
 
         throw new BadArgs("err.unknown.option", name).showUsage(true);
     }
@@ -878,27 +886,33 @@
     }
 
     private void showHelp() {
-        log.println(getMessage("main.usage", progname));
+        printLines(getMessage("main.usage", progname));
         for (Option o: recognizedOptions) {
             String name = o.aliases[0].substring(1); // there must always be at least one name
             if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify"))
                 continue;
-            log.println(getMessage("main.opt." + name));
+            printLines(getMessage("main.opt." + name));
         }
         String[] fmOptions = { "-classpath", "-cp", "-bootclasspath" };
         for (String o: fmOptions) {
             if (fileManager.isSupportedOption(o) == -1)
                 continue;
             String name = o.substring(1);
-            log.println(getMessage("main.opt." + name));
+            printLines(getMessage("main.opt." + name));
         }
 
     }
 
     private void showVersion(boolean full) {
-        log.println(version(full ? "full" : "release"));
+        printLines(version(full ? "full" : "release"));
     }
 
+    private void printLines(String msg) {
+        log.println(msg.replace("\n", nl));
+    }
+
+    private static final String nl = System.getProperty("line.separator");
+
     private static final String versionRBName = "com.sun.tools.javap.resources.version";
     private static ResourceBundle versionRB;
 
--- a/src/share/classes/com/sun/tools/javap/Options.java	Wed Feb 19 13:14:43 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/Options.java	Wed Feb 19 21:01:41 2014 -0800
@@ -86,8 +86,8 @@
     public boolean showConstants;
     public boolean sysInfo;
     public boolean showInnerClasses;
-    public int indentWidth = 2;   // #spaces per indentWidth level
-    public int tabColumn = 40;    // column number for comments
+    public int indentWidth = 2;   // #spaces per indentWidth level; must be > 0
+    public int tabColumn = 40;    // column number for comments; must be > 0
 
     public boolean compat;             // bug-for-bug compatibility mode with old javap
 }
--- a/src/share/classes/com/sun/tools/javap/resources/javap.properties	Wed Feb 19 13:14:43 2014 -0800
+++ b/src/share/classes/com/sun/tools/javap/resources/javap.properties	Wed Feb 19 21:01:41 2014 -0800
@@ -14,6 +14,7 @@
 err.missing.arg=no value given for {0}
 err.no.classes.specified=no classes specified
 err.not.standard.file.manager=can only specify class files when using a standard file manager
+err.invalid.use.of.option=invalid use of option: {0}
 err.unknown.option=unknown option: {0}
 err.verify.not.supported=-verify not supported
 err.no.SourceFile.attribute=no SourceFile attribute
@@ -80,7 +81,7 @@
 \  -bootclasspath <path>    Override location of bootstrap class files
 
 main.opt.constants=\
-\  -constants               Show static final constants
+\  -constants               Show final constants
 
 
 main.opt.sysinfo=\
--- a/test/tools/javac/doctree/SeeTest.java	Wed Feb 19 13:14:43 2014 -0800
+++ b/test/tools/javac/doctree/SeeTest.java	Wed Feb 19 21:01:41 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7021614
+ * @bug 7021614 8031212
  * @summary extend com.sun.source API to support parsing javadoc comments
  * @build DocCommentTester
  * @run main DocCommentTester SeeTest.java
@@ -41,9 +41,9 @@
     Text[TEXT, pos:1, abc.]
   body: empty
   block tags: 1
-    Erroneous[ERRONEOUS, pos:7
-      code: compiler.err.dc.unexpected.content
-      body: @see_"String"
+    See[SEE, pos:7
+      reference: 1
+        Text[TEXT, pos:12, "String"]
     ]
 ]
 */
--- a/test/tools/javadoc/parser/7091528/T7091528.java	Wed Feb 19 13:14:43 2014 -0800
+++ b/test/tools/javadoc/parser/7091528/T7091528.java	Wed Feb 19 21:01:41 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,8 @@
 
 /**
  * @test
- * @bug     7091528
- * @summary javadoc attempts to parse .class files
+ * @bug     7091528 8029145
+ * @summary ensures javadoc parses unique source files and ignores all class files
  * @compile p/C1.java p/q/C2.java
  * @run main T7091528
  */
@@ -37,17 +37,22 @@
     public static void main(String... args) {
         new T7091528().run();
     }
-
     void run() {
         File testSrc = new File(System.getProperty("test.src"));
         File testClasses = new File(System.getProperty("test.classes"));
-        String[] args = {
-            "-d", ".",
+        // 7091528, tests if class files are being ignored
+        runTest("-d", ".",
             "-sourcepath", testClasses + File.pathSeparator + testSrc,
             "-subpackages",
-            "p"
-        };
+            "p");
+        // 8029145, tests if unique source files are parsed
+        runTest("-d", ".",
+            "-sourcepath", testSrc.getAbsolutePath(),
+            "-subpackages",
+            "p:p.q");
 
+    }
+    void runTest(String... args) {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         String doclet = com.sun.tools.doclets.standard.Standard.class.getName();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/StackMapTableTest.java	Wed Feb 19 21:01:41 2014 -0800
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8033930 8033913
+ * @summary bad formatting of StackMapTable entries
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class StackMapTableTest {
+    public static void main(String... args) throws Exception {
+        new StackMapTableTest().run();
+    }
+
+    void run() throws Exception {
+        String testClasses = System.getProperty("test.classes");
+        String out = javap("-v", "-classpath", testClasses, A.class.getName());
+
+        String nl = System.getProperty("line.separator");
+        out = out.replaceAll(nl, "\n");
+
+        if (out.contains("\n\n\n"))
+            error("double blank line found");
+
+        String expect =
+            "      StackMapTable: number_of_entries = 2\n" +
+            "        frame_type = 252 /* append */\n" +
+            "          offset_delta = 2\n" +
+            "          locals = [ int ]\n" +
+            "        frame_type = 250 /* chop */\n" +
+            "          offset_delta = 18\n";
+        if (!out.contains(expect))
+            error("expected text not found");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    String javap(String... args) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter out = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args, out);
+        out.close();
+        System.out.println(sw.toString());
+        if (rc < 0)
+            throw new Exception("javap exited, rc=" + rc);
+        return sw.toString();
+    }
+
+    void error(String msg) {
+        System.out.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    /** Simple test class to run through javap. */
+    public class A {
+        public void a() {
+            for (int i = 0; i < 10; i++) {
+                System.out.println(i);
+            }
+        }
+        public void b() {
+        }
+        public void c() {
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/T8032814.java	Wed Feb 19 21:01:41 2014 -0800
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8032814
+ * @summary LineNumberTable/LocalVariableTable tables duplication for the
+ *          "-v -l" combination of options
+ * @compile -g T8032814.java
+ * @run main T8032814
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T8032814 {
+    public static void main(String... args) throws Exception {
+        new T8032814().run();
+    }
+
+    void run() throws Exception {
+        Class<?> clazz = T8032814.class;
+        int count = clazz.getDeclaredConstructors().length
+                + clazz.getDeclaredMethods().length;
+        test(clazz, 0);
+        test(clazz, count, "-v");
+        test(clazz, count, "-l");
+        test(clazz, count, "-v", "-l");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(Class<?> clazz, int expectedCount, String... opts) throws Exception {
+        System.err.println("test class " + clazz.getName() + " " + Arrays.asList(opts) + ": expect: " + expectedCount);
+        List<String> args = new ArrayList<String>();
+        args.addAll(Arrays.asList(opts));
+        args.addAll(Arrays.asList("-classpath", System.getProperty("test.classes")));
+        args.add(clazz.getName());
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
+        pw.close();
+        String out = sw.toString();
+        if (rc != 0)
+            throw new Exception("javap failed unexpectedly: rc=" + rc);
+
+        int lntCount = 0, lvtCount = 0;
+        for (String line: out.split("[\r\n]+")) {
+            if (line.matches("^ *LineNumberTable:$"))
+                lntCount++;
+            if (line.matches("^ *LocalVariableTable:$"))
+                lvtCount++;
+        }
+        checkEqual("LineNumberTable", lntCount, expectedCount);
+        checkEqual("LocalVariableTable", lvtCount, expectedCount);
+    }
+
+    void checkEqual(String attr, int found, int expect) {
+        if (found != expect) {
+            error("Unexpected number of occurrences of " + attr + "\n" +
+                "found: " + found + ", expected: " + expect);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors = 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/T8032819.java	Wed Feb 19 21:01:41 2014 -0800
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8032819
+ * @summary Extra empty line between field declarations for the "-v -c" and "-v -l" combination of options
+ * @compile -g T8032819.java
+ * @run main T8032819
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T8032819 {
+    static class Fields {
+        int f1;
+        int f2;
+    }
+
+    public static void main(String... args) throws Exception {
+        new T8032819().run();
+    }
+
+    void run() throws Exception {
+        Class<?> clazz = Fields.class;
+        test(clazz);
+        test(clazz, "-c");
+        test(clazz, "-l");
+        test(clazz, "-l", "-c");
+        test(clazz, "-v");
+        test(clazz, "-v", "-c");
+        test(clazz, "-v", "-l");
+        test(clazz, "-v", "-l", "-c");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    static final String sep = System.getProperty("line.separator");
+    static final String doubleBlankLine = sep + sep + sep;
+
+    void test(Class<?> clazz, String... opts) throws Exception {
+        System.err.println("test " + Arrays.asList(opts));
+        List<String> args = new ArrayList<String>();
+        args.addAll(Arrays.asList(opts));
+        args.addAll(Arrays.asList("-classpath", System.getProperty("test.classes")));
+        args.add(clazz.getName());
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
+        pw.close();
+        String out = sw.toString();
+        if (rc != 0)
+            throw new Exception("javap failed unexpectedly: rc=" + rc);
+
+        int count = 0;
+        int i = out.indexOf(doubleBlankLine, 0);
+        while (i != -1) {
+            count++;
+            i = out.indexOf(doubleBlankLine, i + doubleBlankLine.length());
+        }
+
+        if (count > 0)
+            error(count + " double blank lines found");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors = 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/T8033180.java	Wed Feb 19 21:01:41 2014 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8033180
+ * @summary Bad newline characters
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T8033180 {
+
+    public static void main(String... args) throws Exception {
+        new T8033180().run();
+    }
+
+    void run() throws Exception {
+        // fast-track this case, because test cannot fail in this case
+        if (lineSep.equals(nl))
+            return;
+
+        test("-help");
+        test("-version");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    static final String lineSep = System.getProperty("line.separator");
+    static final String nl = "\n";
+
+    void test(String... opts) throws Exception {
+        System.err.println("test " + Arrays.asList(opts));
+        List<String> args = new ArrayList<String>();
+        args.addAll(Arrays.asList(opts));
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
+        pw.close();
+        String out = sw.toString();
+        if (rc != 0)
+            throw new Exception("javap failed unexpectedly: rc=" + rc);
+
+        // remove all valid platform newline sequences
+        String out2 = out.replace(lineSep, "");
+
+        // count the remaining simple newline characters
+        int count = 0;
+        int i = out2.indexOf(nl, 0);
+        while (i != -1) {
+            count++;
+            i = out2.indexOf(nl, i + nl.length());
+        }
+
+        if (count > 0)
+            error(count + " newline characters found");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors = 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/T8033711.java	Wed Feb 19 21:01:41 2014 -0800
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8033711
+ * @summary An exception is thrown if using the "-classpath" option with no arguments
+ */
+
+
+import java.io.*;
+
+public class T8033711 {
+    public static void main(String[] args) throws Exception {
+        new T8033711().run();
+    }
+
+    public void run() throws Exception {
+        String out = javap("-classpath");
+        if (out.contains("IllegalArgumentException"))
+            throw new Exception("exception found in javap output");
+        if (!out.contains("Error: invalid use of option"))
+            throw new Exception("expected error message not found in javap output");
+    }
+
+    String javap(String... args) {
+        StringWriter sw = new StringWriter();
+        PrintWriter out = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args, out);
+        out.close();
+        System.out.println(sw.toString());
+        System.out.println("javap exited, rc=" + rc);
+        return sw.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/WhitespaceTest.java	Wed Feb 19 21:01:41 2014 -0800
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8033581 8033798 8033726
+ * @summary Check whitespace in generated output
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class WhitespaceTest {
+    public static void main(String... args) throws Exception {
+        new WhitespaceTest().run();
+    }
+
+    void run() throws Exception {
+        test("-v", "java.lang.String");
+        test("-XDtab:1", "-v", "java.lang.String");
+
+        String testClasses = System.getProperty("test.classes");
+        for (int i = 10; i < 40; i++)
+            test("-XDtab:" + i, "-v", "-classpath", testClasses, "WhitespaceTest$HelloWorld");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void test(String... args) throws Exception {
+        // need to avoid "//" appearing as a constant in the constant pool
+        String slash = "/";
+        String doubleSlash = slash + slash;
+        System.out.println("test: " + Arrays.asList(args));
+        String out = javap(args);
+        for (String line: out.split("[\r\n]+")) {
+            if (line.endsWith(" "))
+                error("line has trailing whitespace: " + line);
+            int comment = line.indexOf(doubleSlash);
+            if (comment > 0 && line.charAt(comment - 1) != ' ')
+                error("no space before comment: " + line);
+            if (line.matches(" +}"))
+                error("bad indentation: " + line);
+        }
+    }
+
+    String javap(String... args) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter out = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args, out);
+        out.close();
+        System.out.println(sw.toString());
+        if (rc < 0)
+            throw new Exception("javap exited, rc=" + rc);
+        return sw.toString();
+    }
+
+    void error(String msg) {
+        System.out.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    // small class to test repeatedly with different tab values
+    static class HelloWorld {
+        public static void main(String... args) {
+            System.out.println("Hello World!");
+        }
+    }
+}