Tue, 13 May 2014 16:14:54 +0100
8037379: fix for JDK-8029569 doesn't cover all possible cases
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue May 13 16:11:43 2014 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue May 13 16:14:54 2014 +0100 1.3 @@ -2769,7 +2769,7 @@ 1.4 targetError = false; 1.5 } 1.6 1.7 - JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, 1.8 + JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym.baseSymbol()).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, 1.9 that, exprType.tsym, exprType, that.name, argtypes, typeargtypes); 1.10 1.11 JCDiagnostic.DiagnosticType diagKind = targetError ?
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue May 13 16:11:43 2014 +0100 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue May 13 16:14:54 2014 +0100 2.3 @@ -1432,7 +1432,7 @@ 2.4 return bestSoFar; 2.5 } else if (useVarargs && (sym.flags() & VARARGS) == 0) { 2.6 return bestSoFar.kind >= ERRONEOUS ? 2.7 - new BadVarargsMethod((ResolveError)bestSoFar) : 2.8 + new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) : 2.9 bestSoFar; 2.10 } 2.11 Assert.check(sym.kind < AMBIGUOUS); 2.12 @@ -2200,7 +2200,7 @@ 2.13 List<Type> typeargtypes, 2.14 LogResolveHelper logResolveHelper) { 2.15 if (sym.kind >= AMBIGUOUS) { 2.16 - ResolveError errSym = (ResolveError)sym; 2.17 + ResolveError errSym = (ResolveError)sym.baseSymbol(); 2.18 sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol); 2.19 argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes); 2.20 if (logResolveHelper.resolveDiagnosticNeeded(site, argtypes, typeargtypes)) { 2.21 @@ -2589,7 +2589,7 @@ 2.22 sym = super.access(env, pos, location, sym); 2.23 } else { 2.24 final JCDiagnostic details = sym.kind == WRONG_MTH ? 2.25 - ((InapplicableSymbolError)sym).errCandidate().snd : 2.26 + ((InapplicableSymbolError)sym.baseSymbol()).errCandidate().snd : 2.27 null; 2.28 sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) { 2.29 @Override 2.30 @@ -2997,12 +2997,12 @@ 2.31 return true; 2.32 case WRONG_MTH: 2.33 InapplicableSymbolError errSym = 2.34 - (InapplicableSymbolError)s; 2.35 + (InapplicableSymbolError)s.baseSymbol(); 2.36 return new Template(MethodCheckDiag.ARITY_MISMATCH.regex()) 2.37 .matches(errSym.errCandidate().snd); 2.38 case WRONG_MTHS: 2.39 InapplicableSymbolsError errSyms = 2.40 - (InapplicableSymbolsError)s; 2.41 + (InapplicableSymbolsError)s.baseSymbol(); 2.42 return errSyms.filterCandidates(errSyms.mapCandidates()).isEmpty(); 2.43 case WRONG_STATICNESS: 2.44 return false;
3.1 --- a/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java Tue May 13 16:11:43 2014 +0100 3.2 +++ b/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.java Tue May 13 16:14:54 2014 +0100 3.3 @@ -1,30 +1,8 @@ 3.4 /* 3.5 - * Copyright (c) 2013, 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 8029569 3.30 + * @test /nodynamiccopyright/ 3.31 + * @bug 8029569 8037379 3.32 * @summary internal javac cast exception when resolving varargs ambiguity 3.33 + * fix for JDK-8029569 doesn't cover all possible cases 3.34 * @compile/fail/ref=VarargsAmbiguityCrashTest.out -XDrawDiagnostics VarargsAmbiguityCrashTest.java 3.35 */ 3.36
4.1 --- a/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out Tue May 13 16:11:43 2014 +0100 4.2 +++ b/test/tools/javac/T8029569/VarargsAmbiguityCrashTest.out Tue May 13 16:14:54 2014 +0100 4.3 @@ -1,2 +1,2 @@ 4.4 -VarargsAmbiguityCrashTest.java:33:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Exception...), VarargsAmbiguityCrashTest, kindname.method, m2(java.lang.Long,java.lang.Exception...), VarargsAmbiguityCrashTest 4.5 +VarargsAmbiguityCrashTest.java:11:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Exception...), VarargsAmbiguityCrashTest, kindname.method, m2(java.lang.Long,java.lang.Exception...), VarargsAmbiguityCrashTest 4.6 1 error