Thu, 10 Jan 2013 14:09:33 -0800
8006037: extra space in javac -help for -J and @ options
Reviewed-by: darcy
src/share/classes/com/sun/tools/javac/main/Option.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/main/Option_J_At_Test.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/classes/com/sun/tools/javac/main/Option.java Wed Jan 09 20:02:53 2013 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/main/Option.java Thu Jan 10 14:09:33 2013 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -311,7 +311,7 @@ 1.11 1.12 // This option exists only for the purpose of documenting itself. 1.13 // It's actually implemented by the launcher. 1.14 - J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO) { 1.15 + J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, true) { 1.16 @Override 1.17 public boolean process(OptionHelper helper, String option) { 1.18 throw new AssertionError 1.19 @@ -416,7 +416,7 @@ 1.20 1.21 // This option exists only for the purpose of documenting itself. 1.22 // It's actually implemented by the CommandLine class. 1.23 - AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO) { 1.24 + AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) { 1.25 @Override 1.26 public boolean process(OptionHelper helper, String option) { 1.27 throw new AssertionError("the @ flag should be caught by CommandLine.");
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/main/Option_J_At_Test.java Thu Jan 10 14:09:33 2013 -0800 2.3 @@ -0,0 +1,70 @@ 2.4 + 2.5 +import java.io.PrintWriter; 2.6 +import java.io.StringWriter; 2.7 + 2.8 +/* 2.9 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2.10 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.11 + * 2.12 + * This code is free software; you can redistribute it and/or modify it 2.13 + * under the terms of the GNU General Public License version 2 only, as 2.14 + * published by the Free Software Foundation. 2.15 + * 2.16 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.18 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.19 + * version 2 for more details (a copy is included in the LICENSE file that 2.20 + * accompanied this code). 2.21 + * 2.22 + * You should have received a copy of the GNU General Public License version 2.23 + * 2 along with this work; if not, write to the Free Software Foundation, 2.24 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.25 + * 2.26 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.27 + * or visit www.oracle.com if you need additional information or have any 2.28 + * questions. 2.29 + */ 2.30 + 2.31 +/* 2.32 + * @test 2.33 + * @bug 8006037 2.34 + * @summary extra space in javac -help for -J and @ options 2.35 + */ 2.36 + 2.37 +public class Option_J_At_Test { 2.38 + public static void main(String... args) throws Exception { 2.39 + new Option_J_At_Test().run(); 2.40 + } 2.41 + 2.42 + void run() throws Exception { 2.43 + StringWriter sw = new StringWriter(); 2.44 + PrintWriter pw = new PrintWriter(sw); 2.45 + String[] help = { "-help" }; 2.46 + int rc = com.sun.tools.javac.Main.compile(help, pw); 2.47 + pw.flush(); 2.48 + String out = sw.toString(); 2.49 + System.out.println(out); 2.50 + check(out, "-J<flag>", true); 2.51 + check(out, "-J <flag>", false); 2.52 + check(out, "@<filename>", true); 2.53 + check(out, "@ <filename>", false); 2.54 + if (errors > 0) 2.55 + throw new Exception(errors + " errors found"); 2.56 + } 2.57 + 2.58 + void check(String out, String text, boolean expect) { 2.59 + if (out.contains(text) != expect) { 2.60 + if (expect) 2.61 + error("expected string not found: " + text); 2.62 + else 2.63 + error("unexpected string found: " + text); 2.64 + } 2.65 + } 2.66 + 2.67 + void error(String msg) { 2.68 + System.err.println("Error: " + msg); 2.69 + errors++; 2.70 + } 2.71 + 2.72 + int errors; 2.73 +}