# HG changeset patch # User jjg # Date 1215563150 25200 # Node ID c7a22d6d7184d4e0b39110c11231924ec2a7b696 # Parent 16b1ea00598f2c5ed8886301116ee745c4d1c73b 6715753: unknown option error can be a little more helpful Reviewed-by: ksrini diff -r 16b1ea00598f -r c7a22d6d7184 langtools/src/share/classes/com/sun/tools/javap/JavapTask.java --- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Jul 08 17:14:22 2008 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Jul 08 17:25:50 2008 -0700 @@ -298,7 +298,7 @@ return new DiagnosticListener () { public void report(Diagnostic diagnostic) { if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { - pw.print(getMessage("err.prefix")); + pw.print(getMessage("err.prefix")); pw.print(" "); } pw.println(diagnostic.getMessage(null)); @@ -331,6 +331,9 @@ return ok ? EXIT_OK : EXIT_ERROR; } catch (BadArgs e) { diagnosticListener.report(createDiagnostic(e.key, e.args)); + if (e.showUsage) { + log.println(getMessage("main.usage.summary", progname)); + } return EXIT_CMDERR; } catch (InternalError e) { Object[] e_args; diff -r 16b1ea00598f -r c7a22d6d7184 langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties --- a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue Jul 08 17:14:22 2008 -0700 +++ b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue Jul 08 17:25:50 2008 -0700 @@ -16,6 +16,10 @@ err.verify.not.supported=-verify not supported err.Xold.not.supported.here=-Xold must be given as the first option +main.usage.summary=\ +Usage: {0} \n\ +use -help for a list of possible options + main.usage=\ Usage: {0} \n\ where possible options include: diff -r 16b1ea00598f -r c7a22d6d7184 langtools/test/tools/javap/T6715753.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javap/T6715753.java Tue Jul 08 17:25:50 2008 -0700 @@ -0,0 +1,50 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.io.*; + +/* + * @test + * @bug 6715753 + * @summary Use javap to inquire about a specific inner class + */ + +public class T6715753 { + public static void main(String... args) throws Exception { + new T6715753().run(); + } + + void run() throws Exception { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + String[] args = { "-notAnOption" }; + int rc = com.sun.tools.javap.Main.run(args, pw); + String log = sw.toString(); + if (rc == 0 + || log.indexOf("-notAnOption") == -1 + || log.indexOf("javap") == -1) { // locale-independent indication of usage message + System.err.println("rc: " + rc + ", log=\n" + log); + throw new Exception("test failed"); + } + } +} \ No newline at end of file