Mon, 10 Dec 2012 12:10:50 +0000
8004094: Javac compiler error - synthetic method accessor generated with duplicate name
Summary: method clash check logic should skip methods marked with ACC_SYNTHETIC
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Dec 04 17:19:42 2012 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Dec 10 12:10:50 2012 +0000 1.3 @@ -1833,13 +1833,15 @@ 1.4 for (Scope.Entry e1 = t1.tsym.members().elems; e1 != null; e1 = e1.sibling) { 1.5 Symbol s1 = e1.sym; 1.6 Type st1 = null; 1.7 - if (s1.kind != MTH || !s1.isInheritedIn(site.tsym, types)) continue; 1.8 + if (s1.kind != MTH || !s1.isInheritedIn(site.tsym, types) || 1.9 + (s1.flags() & SYNTHETIC) != 0) continue; 1.10 Symbol impl = ((MethodSymbol)s1).implementation(site.tsym, types, false); 1.11 if (impl != null && (impl.flags() & ABSTRACT) == 0) continue; 1.12 for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name); e2.scope != null; e2 = e2.next()) { 1.13 Symbol s2 = e2.sym; 1.14 if (s1 == s2) continue; 1.15 - if (s2.kind != MTH || !s2.isInheritedIn(site.tsym, types)) continue; 1.16 + if (s2.kind != MTH || !s2.isInheritedIn(site.tsym, types) || 1.17 + (s2.flags() & SYNTHETIC) != 0) continue; 1.18 if (st1 == null) st1 = types.memberType(t1, s1); 1.19 Type st2 = types.memberType(t2, s2); 1.20 if (types.overrideEquivalent(st1, st2)) {
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/generics/8004094/B.java Mon Dec 10 12:10:50 2012 +0000 2.3 @@ -0,0 +1,47 @@ 2.4 +/* 2.5 + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 +abstract class A { 2.27 + 2.28 + private static String s = null; 2.29 + 2.30 + static void test() { 2.31 + new Object() { 2.32 + void m() { 2.33 + Object o = s; 2.34 + } 2.35 + }; 2.36 + } 2.37 +} 2.38 + 2.39 +public abstract class B<T> extends A { 2.40 + 2.41 + private static Integer i = null; 2.42 + 2.43 + static void test() { 2.44 + new Object() { 2.45 + void m() { 2.46 + Object o = i; 2.47 + } 2.48 + }; 2.49 + } 2.50 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javac/generics/8004094/T8004094.java Mon Dec 10 12:10:50 2012 +0000 3.3 @@ -0,0 +1,32 @@ 3.4 +/* 3.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/* 3.28 + * @test 3.29 + * @bug 8004094 3.30 + * @summary Javac compiler error - synthetic method accessor generated with duplicate name 3.31 + * 3.32 + * @compile B.java T8004094.java 3.33 + */ 3.34 + 3.35 +public class T8004094 extends B<Object> { }