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