T6715251.java revision 63
0N/A/*
0N/A * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A */
0N/A
0N/Aimport java.io.*;
0N/Aimport java.util.*;
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 6715251
0N/A * @summary javap should be consistent with javac and return 2 if given no arguments
0N/A */
0N/A
0N/Apublic class T6715251 {
0N/A public static void main(String... args) throws Exception {
0N/A new T6715251().run();
0N/A }
0N/A
0N/A void run() throws Exception {
0N/A String testClasses = System.getProperty("test.classes", ".");
0N/A
0N/A test(2);
0N/A test(0, "-help");
0N/A test(0, "-version");
0N/A test(0, "-fullversion");
0N/A test(0, "-classpath", testClasses, "T6715251");
0N/A
0N/A if (errors > 0)
0N/A throw new Exception(errors + " errors received");
0N/A }
0N/A
0N/A void test(int expect, String ... args) {
0N/A int rc = javap(args);
0N/A if (rc != expect)
0N/A error("bad result: expected: " + expect + ", found " + rc + "\n"
0N/A + log);
0N/A
0N/A }
0N/A
0N/A int javap(String... args) {
0N/A StringWriter sw = new StringWriter();
0N/A PrintWriter pw = new PrintWriter(sw);
0N/A int rc = com.sun.tools.javap.Main.run(args, pw);
0N/A log = sw.toString();
0N/A return rc;
0N/A }
0N/A
0N/A void error(String msg) {
0N/A System.err.println(msg);
0N/A errors++;
0N/A }
0N/A
0N/A String log;
0N/A int errors;
0N/A}