test/tools/javap/T6715251.java

Thu, 04 Apr 2013 19:05:42 -0700

author
katleman
date
Thu, 04 Apr 2013 19:05:42 -0700
changeset 1662
4a48f3173534
parent 798
4868a36f6fd8
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8-b84 for changeset cfb65ca92082

jjg@64 1 /*
ohair@798 2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
jjg@64 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@64 4 *
jjg@64 5 * This code is free software; you can redistribute it and/or modify it
jjg@64 6 * under the terms of the GNU General Public License version 2 only, as
jjg@64 7 * published by the Free Software Foundation.
jjg@64 8 *
jjg@64 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@64 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@64 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@64 12 * version 2 for more details (a copy is included in the LICENSE file that
jjg@64 13 * accompanied this code).
jjg@64 14 *
jjg@64 15 * You should have received a copy of the GNU General Public License version
jjg@64 16 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@64 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@64 18 *
ohair@554 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 20 * or visit www.oracle.com if you need additional information or have any
ohair@554 21 * questions.
jjg@64 22 */
jjg@64 23
jjg@64 24 import java.io.*;
jjg@64 25 import java.util.*;
jjg@64 26
jjg@64 27 /*
jjg@64 28 * @test
jjg@64 29 * @bug 6715251
jjg@64 30 * @summary javap should be consistent with javac and return 2 if given no arguments
jjg@64 31 */
jjg@64 32
jjg@64 33 public class T6715251 {
jjg@64 34 public static void main(String... args) throws Exception {
jjg@64 35 new T6715251().run();
jjg@64 36 }
jjg@64 37
jjg@64 38 void run() throws Exception {
jjg@64 39 String testClasses = System.getProperty("test.classes", ".");
jjg@64 40
jjg@64 41 test(2);
jjg@64 42 test(0, "-help");
jjg@64 43 test(0, "-version");
jjg@64 44 test(0, "-fullversion");
jjg@64 45 test(0, "-classpath", testClasses, "T6715251");
jjg@64 46
jjg@64 47 if (errors > 0)
jjg@64 48 throw new Exception(errors + " errors received");
jjg@64 49 }
jjg@64 50
jjg@64 51 void test(int expect, String ... args) {
jjg@64 52 int rc = javap(args);
jjg@64 53 if (rc != expect)
jjg@64 54 error("bad result: expected: " + expect + ", found " + rc + "\n"
jjg@64 55 + log);
jjg@64 56
jjg@64 57 }
jjg@64 58
jjg@64 59 int javap(String... args) {
jjg@64 60 StringWriter sw = new StringWriter();
jjg@64 61 PrintWriter pw = new PrintWriter(sw);
jjg@64 62 int rc = com.sun.tools.javap.Main.run(args, pw);
jjg@64 63 log = sw.toString();
jjg@64 64 return rc;
jjg@64 65 }
jjg@64 66
jjg@64 67 void error(String msg) {
jjg@64 68 System.err.println(msg);
jjg@64 69 errors++;
jjg@64 70 }
jjg@64 71
jjg@64 72 String log;
jjg@64 73 int errors;
jjg@525 74 }

mercurial