mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
6715753: unknown option error can be a little more helpful
Reviewed-by: ksrini
This commit is contained in:
parent
23aea10d3e
commit
a2ef1138ad
3 changed files with 58 additions and 1 deletions
|
@ -298,7 +298,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
|
||||||
return new DiagnosticListener<JavaFileObject> () {
|
return new DiagnosticListener<JavaFileObject> () {
|
||||||
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
|
public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
|
||||||
if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
|
if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
|
||||||
pw.print(getMessage("err.prefix"));
|
pw.print(getMessage("err.prefix"));
|
||||||
pw.print(" ");
|
pw.print(" ");
|
||||||
}
|
}
|
||||||
pw.println(diagnostic.getMessage(null));
|
pw.println(diagnostic.getMessage(null));
|
||||||
|
@ -331,6 +331,9 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask {
|
||||||
return ok ? EXIT_OK : EXIT_ERROR;
|
return ok ? EXIT_OK : EXIT_ERROR;
|
||||||
} catch (BadArgs e) {
|
} catch (BadArgs e) {
|
||||||
diagnosticListener.report(createDiagnostic(e.key, e.args));
|
diagnosticListener.report(createDiagnostic(e.key, e.args));
|
||||||
|
if (e.showUsage) {
|
||||||
|
log.println(getMessage("main.usage.summary", progname));
|
||||||
|
}
|
||||||
return EXIT_CMDERR;
|
return EXIT_CMDERR;
|
||||||
} catch (InternalError e) {
|
} catch (InternalError e) {
|
||||||
Object[] e_args;
|
Object[] e_args;
|
||||||
|
|
|
@ -16,6 +16,10 @@ err.unknown.option=unknown option: {0}
|
||||||
err.verify.not.supported=-verify not supported
|
err.verify.not.supported=-verify not supported
|
||||||
err.Xold.not.supported.here=-Xold must be given as the first option
|
err.Xold.not.supported.here=-Xold must be given as the first option
|
||||||
|
|
||||||
|
main.usage.summary=\
|
||||||
|
Usage: {0} <options> <classes>\n\
|
||||||
|
use -help for a list of possible options
|
||||||
|
|
||||||
main.usage=\
|
main.usage=\
|
||||||
Usage: {0} <options> <classes>\n\
|
Usage: {0} <options> <classes>\n\
|
||||||
where possible options include:
|
where possible options include:
|
||||||
|
|
50
langtools/test/tools/javap/T6715753.java
Normal file
50
langtools/test/tools/javap/T6715753.java
Normal file
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue