Tue, 11 Aug 2009 01:12:40 +0100
6840059: regression: javac silently crashes when resolving erroneous anonymous inner constructor
Summary: resolved an internal crash with constructor resolution
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Aug 11 01:12:13 2009 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Aug 11 01:12:40 2009 +0100 1.3 @@ -1554,13 +1554,18 @@ 1.4 typeargtypes, true, tree.varargsElement != null); 1.5 assert sym.kind < AMBIGUOUS || tree.constructor.type.isErroneous(); 1.6 tree.constructor = sym; 1.7 - tree.constructorType = checkMethod(clazztype, 1.8 - tree.constructor, 1.9 - localEnv, 1.10 - tree.args, 1.11 - argtypes, 1.12 - typeargtypes, 1.13 - localEnv.info.varArgs); 1.14 + if (tree.constructor.kind > ERRONEOUS) { 1.15 + tree.constructorType = syms.errType; 1.16 + } 1.17 + else { 1.18 + tree.constructorType = checkMethod(clazztype, 1.19 + tree.constructor, 1.20 + localEnv, 1.21 + tree.args, 1.22 + argtypes, 1.23 + typeargtypes, 1.24 + localEnv.info.varArgs); 1.25 + } 1.26 } 1.27 1.28 if (tree.constructor != null && tree.constructor.kind == MTH)
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/6840059/T6840059.java Tue Aug 11 01:12:40 2009 +0100 2.3 @@ -0,0 +1,40 @@ 2.4 +/* 2.5 + * Copyright 2009 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 6840059 2.30 + * @summary 6758789: Some method resolution diagnostic should be improved 2.31 + * @author Maurizio Cimadamore 2.32 + * 2.33 + * @compile/fail/ref=T6840059.out -XDrawDiagnostics T6840059.java 2.34 + */ 2.35 + 2.36 +class T6840059 { 2.37 + 2.38 + T6840059(Integer x) {} 2.39 + 2.40 + void test() { 2.41 + new T6840059(""){}; 2.42 + } 2.43 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javac/6840059/T6840059.out Tue Aug 11 01:12:40 2009 +0100 3.3 @@ -0,0 +1,3 @@ 3.4 +T6840059.java:38:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6840059, , java.lang.String, kindname.class, T6840059 3.5 +T6840059.java:38:25: compiler.err.cant.resolve.location.args: kindname.constructor, T6840059, , , kindname.class, T6840059 3.6 +2 errors