Mon, 11 Jan 2010 14:05:21 -0800
6326754: Compiler will fail to handle -Xmaxerrs with -ve numbers
Reviewed-by: ksrini
1.1 --- a/src/share/classes/com/sun/tools/javac/util/Log.java Fri Jan 08 13:14:45 2010 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/util/Log.java Mon Jan 11 14:05:21 2010 -0800 1.3 @@ -145,7 +145,10 @@ 1.4 private int getIntOption(Options options, String optionName, int defaultValue) { 1.5 String s = options.get(optionName); 1.6 try { 1.7 - if (s != null) return Integer.parseInt(s); 1.8 + if (s != null) { 1.9 + int n = Integer.parseInt(s); 1.10 + return (n <= 0 ? Integer.MAX_VALUE : n); 1.11 + } 1.12 } catch (NumberFormatException e) { 1.13 // silently ignore ill-formed numbers 1.14 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/T6326754.java Mon Jan 11 14:05:21 2010 -0800 2.3 @@ -0,0 +1,76 @@ 2.4 +/* 2.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 2.24 + * have any questions. 2.25 + */ 2.26 + 2.27 +/* 2.28 + * @test 2.29 + * @bug 6326754 2.30 + * @summary Compiler will fail to handle -Xmaxerrs with -ve numbers 2.31 + * 2.32 + * @compile/fail/ref=T6326754.out -XDrawDiagnostics -Xmaxerrs -1 T6326754.java 2.33 + * @compile/fail/ref=T6326754.out -XDrawDiagnostics -Xmaxerrs 0 T6326754.java 2.34 + * @compile/fail/ref=T6326754.out -XDrawDiagnostics -Xmaxerrs 10 T6326754.java 2.35 + * @compile/fail/ref=T6326754.out -XDrawDiagnostics T6326754.java 2.36 + */ 2.37 +class TestConstructor<T,K>{ 2.38 + T t; 2.39 + K k; 2.40 + public TestConstructor(T t,K k){ 2.41 + this.t =t; 2.42 + } 2.43 + public TestConstructor(K k){ 2.44 + this.k = k; 2.45 + this.t = null; 2.46 + } 2.47 + public TestConstructor(T t){ 2.48 + this.t=t; 2.49 + this.k=null; 2.50 + } 2.51 + public void setT(T t){ 2.52 + this.t=t; 2.53 + this.k=null; 2.54 + } 2.55 + public void setT(K k){ 2.56 + this.k = k; 2.57 + this.t = null; 2.58 + } 2.59 + public void setT(T t,K k){ 2.60 + this.t = t; 2.61 + this.k = k; 2.62 + } 2.63 +} 2.64 +class TestC<T>{ 2.65 + T t; 2.66 + public <T>void setT(T t){ 2.67 + this.t = t; 2.68 + } 2.69 +} 2.70 +public class T6326754{ 2.71 + public static void main(String... arg){ 2.72 + TestC tC =new TestC(); 2.73 + tC.setT(); 2.74 + TestConstructor tc = new TestConstructor("saaa"); 2.75 + tc.setT("sasa"); 2.76 + TestC<Integer> tC1 = new TestC(); 2.77 + tC1.setT(545); 2.78 + } 2.79 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javac/T6326754.out Mon Jan 11 14:05:21 2010 -0800 3.3 @@ -0,0 +1,7 @@ 3.4 +T6326754.java:44:12: compiler.err.name.clash.same.erasure: TestConstructor(T), TestConstructor(K) 3.5 +T6326754.java:52:17: compiler.err.name.clash.same.erasure: setT(K), setT(T) 3.6 +T6326754.java:64:18: compiler.err.prob.found.req: (compiler.misc.incompatible.types), T, T 3.7 +T6326754.java:70:11: compiler.err.cant.apply.symbol: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, null 3.8 +- compiler.note.unchecked.filename: T6326754.java 3.9 +- compiler.note.unchecked.recompile 3.10 +4 errors