Mercurial > hg > openjdk > aarch64-port > langtools
changeset 2553:b0b6a6b4c648
Merge up to jdk8u40-b09
author | Edward Nevill edward.nevill@linaro.org |
---|---|
date | Fri, 10 Oct 2014 15:53:23 +0100 |
parents | 11feb6a350ba (current diff) 8bb38a350722 (diff) |
children | 96ab7045049e |
files | .hgtags src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java src/share/classes/com/sun/tools/javac/comp/Flow.java src/share/classes/com/sun/tools/javac/comp/Resolve.java src/share/classes/com/sun/tools/javac/jvm/Gen.java |
diffstat | 16 files changed, 421 insertions(+), 140 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Fri Sep 05 07:19:14 2014 -0400 +++ b/.hgtags Fri Oct 10 15:53:23 2014 +0100 @@ -326,3 +326,7 @@ df9cb52f5dd70d8da138276f4ee2427012d2d385 jdk8u40-b02 5183e8b58a03206ca65b4b211be85b3740a70c39 jdk8u40-b03 cde557bc48f5cd0c6b6aa70bdbc7563677379347 jdk8u40-b04 +a36fce70b505ec15be8353d40d417d331fcce740 jdk8u40-b05 +7c3d27120b92b6abbd2df910722405dfb02d4399 jdk8u40-b06 +2fa3858a281f9deae15bcc49224efd5b951b745d jdk8u40-b07 +d3515520e68e26c1012fca18eef190f8aff3a7a1 jdk8u40-b08
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Sep 05 07:19:14 2014 -0400 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Oct 10 15:53:23 2014 +0100 @@ -287,7 +287,7 @@ * @param env The current environment. */ boolean isAssignableAsBlankFinal(VarSymbol v, Env<AttrContext> env) { - Symbol owner = owner(env); + Symbol owner = env.info.scope.owner; // owner refers to the innermost variable, method or // initializer block declaration at this point. return @@ -302,41 +302,6 @@ ((v.flags() & STATIC) != 0) == Resolve.isStatic(env)); } - /** - * Return the innermost enclosing owner symbol in a given attribution context - */ - Symbol owner(Env<AttrContext> env) { - while (true) { - switch (env.tree.getTag()) { - case VARDEF: - //a field can be owner - VarSymbol vsym = ((JCVariableDecl)env.tree).sym; - if (vsym.owner.kind == TYP) { - return vsym; - } - break; - case METHODDEF: - //method def is always an owner - return ((JCMethodDecl)env.tree).sym; - case CLASSDEF: - //class def is always an owner - return ((JCClassDecl)env.tree).sym; - case BLOCK: - //static/instance init blocks are owner - Symbol blockSym = env.info.scope.owner; - if ((blockSym.flags() & BLOCK) != 0) { - return blockSym; - } - break; - case TOPLEVEL: - //toplevel is always an owner (for pkge decls) - return env.info.scope.owner; - } - Assert.checkNonNull(env.next); - env = env.next; - } - } - /** Check that variable can be assigned to. * @param pos The current source code position. * @param v The assigned varaible @@ -3660,7 +3625,7 @@ // and are subject to definite assignment checking. if ((env.info.enclVar == v || v.pos > tree.pos) && v.owner.kind == TYP && - canOwnInitializer(owner(env)) && + enclosingInitEnv(env) != null && v.owner == env.info.scope.owner.enclClass() && ((v.flags() & STATIC) != 0) == Resolve.isStatic(env) && (!env.tree.hasTag(ASSIGN) || @@ -3680,6 +3645,36 @@ } /** + * Returns the enclosing init environment associated with this env (if any). An init env + * can be either a field declaration env or a static/instance initializer env. + */ + Env<AttrContext> enclosingInitEnv(Env<AttrContext> env) { + while (true) { + switch (env.tree.getTag()) { + case VARDEF: + JCVariableDecl vdecl = (JCVariableDecl)env.tree; + if (vdecl.sym.owner.kind == TYP) { + //field + return env; + } + break; + case BLOCK: + if (env.next.tree.hasTag(CLASSDEF)) { + //instance/static initializer + return env; + } + break; + case METHODDEF: + case CLASSDEF: + case TOPLEVEL: + return null; + } + Assert.checkNonNull(env.next); + env = env.next; + } + } + + /** * Check for illegal references to static members of enum. In * an enum type, constructors and initializers may not * reference its static members unless they are constant. @@ -3732,17 +3727,6 @@ v.name != names._class; } - /** Can the given symbol be the owner of code which forms part - * if class initialization? This is the case if the symbol is - * a type or field, or if the symbol is the synthetic method. - * owning a block. - */ - private boolean canOwnInitializer(Symbol sym) { - return - (sym.kind & (VAR | TYP)) != 0 || - (sym.kind == MTH && (sym.flags() & BLOCK) != 0); - } - Warner noteWarner = new Warner(); /**
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Sep 05 07:19:14 2014 -0400 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Oct 10 15:53:23 2014 +0100 @@ -497,13 +497,11 @@ } } if (!progress) { - DeferredAttrContext dac = this; - while (dac != emptyDeferredAttrContext) { - if (dac.mode == AttrMode.SPECULATIVE) { - //unsticking does not take place during overload - break; + if (insideOverloadPhase()) { + for (DeferredAttrNode deferredNode: deferredAttrNodes) { + deferredNode.dt.tree.type = Type.noType; } - dac = dac.parent; + return; } //remove all variables that have already been instantiated //from the list of stuck variables @@ -519,6 +517,17 @@ } } } + + private boolean insideOverloadPhase() { + DeferredAttrContext dac = this; + if (dac == emptyDeferredAttrContext) { + return false; + } + if (dac.mode == AttrMode.SPECULATIVE) { + return true; + } + return dac.parent.insideOverloadPhase(); + } } /** @@ -579,6 +588,8 @@ return false; } } else { + Assert.check(!deferredAttrContext.insideOverloadPhase(), + "attribution shouldn't be happening here"); ResultInfo instResultInfo = resultInfo.dup(deferredAttrContext.inferenceContext.asInstType(resultInfo.pt)); dt.check(instResultInfo, dummyStuckPolicy, basicCompleter); @@ -1314,6 +1325,12 @@ site = env.enclClass.sym.type; } + while (site.hasTag(TYPEVAR)) { + site = site.getUpperBound(); + } + + site = types.capture(site); + List<Type> args = rs.dummyArgs(tree.args.length()); Name name = TreeInfo.name(tree.meth); @@ -1337,7 +1354,9 @@ @Override public Symbol process(MethodSymbol ms) { ArgumentExpressionKind kind = ArgumentExpressionKind.methodKind(ms, types); - return kind != ArgumentExpressionKind.POLY ? ms.getReturnType().tsym : null; + if (kind == ArgumentExpressionKind.POLY || ms.getReturnType().hasTag(TYPEVAR)) + return null; + return ms.getReturnType().tsym; } @Override public Symbol reduce(Symbol s1, Symbol s2) {
--- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Sep 05 07:19:14 2014 -0400 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Oct 10 15:53:23 2014 +0100 @@ -208,7 +208,7 @@ public void analyzeTree(Env<AttrContext> env, TreeMaker make) { new AliveAnalyzer().analyzeTree(env, make); - new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit).analyzeTree(env); + new AssignAnalyzer().analyzeTree(env); new FlowAnalyzer().analyzeTree(env, make); new CaptureAnalyzer().analyzeTree(env, make); } @@ -241,7 +241,7 @@ //related errors, which will allow for more errors to be detected Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); try { - new AssignAnalyzer(log, syms, lint, names, enforceThisDotInit) { + new AssignAnalyzer() { @Override protected boolean trackable(VarSymbol sym) { return !env.info.scope.includes(sym) && @@ -1373,12 +1373,12 @@ * effectively-final local variables/parameters. */ - public abstract static class AbstractAssignAnalyzer<P extends AbstractAssignAnalyzer.AbstractAssignPendingExit> + public abstract class AbstractAssignAnalyzer<P extends AbstractAssignAnalyzer<P>.AbstractAssignPendingExit> extends BaseAnalyzer<P> { /** The set of definitely assigned variables. */ - protected final Bits inits; + protected Bits inits; /** The set of definitely unassigned variables. */ @@ -1432,13 +1432,7 @@ /** The starting position of the analysed tree */ int startPos; - final Symtab syms; - - protected Names names; - - final boolean enforceThisDotInit; - - public static class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit { + public class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit { final Bits inits; final Bits uninits; @@ -1460,17 +1454,14 @@ } } - public AbstractAssignAnalyzer(Bits inits, Symtab syms, Names names, boolean enforceThisDotInit) { - this.inits = inits; + public AbstractAssignAnalyzer() { + this.inits = new Bits(); uninits = new Bits(); uninitsTry = new Bits(); initsWhenTrue = new Bits(true); initsWhenFalse = new Bits(true); uninitsWhenTrue = new Bits(true); uninitsWhenFalse = new Bits(true); - this.syms = syms; - this.names = names; - this.enforceThisDotInit = enforceThisDotInit; } private boolean isInitialConstructor = false; @@ -2439,26 +2430,15 @@ } } - public static class AssignAnalyzer - extends AbstractAssignAnalyzer<AssignAnalyzer.AssignPendingExit> { + public class AssignAnalyzer extends AbstractAssignAnalyzer<AssignAnalyzer.AssignPendingExit> { - Log log; - Lint lint; - - public static class AssignPendingExit - extends AbstractAssignAnalyzer.AbstractAssignPendingExit { + public class AssignPendingExit extends AbstractAssignAnalyzer<AssignPendingExit>.AbstractAssignPendingExit { public AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { super(tree, inits, uninits); } } - public AssignAnalyzer(Log log, Symtab syms, Lint lint, Names names, boolean enforceThisDotInit) { - super(new Bits(), syms, names, enforceThisDotInit); - this.log = log; - this.lint = lint; - } - @Override protected AssignPendingExit createNewPendingExit(JCTree tree, Bits inits, Bits uninits) {
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Sep 05 07:19:14 2014 -0400 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Oct 10 15:53:23 2014 +0100 @@ -3045,7 +3045,7 @@ /** * Should lookup stop at given phase with given result */ - protected boolean shouldStop(Symbol sym, MethodResolutionPhase phase) { + final boolean shouldStop(Symbol sym, MethodResolutionPhase phase) { return phase.ordinal() > maxPhase.ordinal() || sym.kind < ERRONEOUS || sym.kind == AMBIGUOUS; } @@ -4228,15 +4228,39 @@ VARARITY(true, true) { @Override public Symbol mergeResults(Symbol bestSoFar, Symbol sym) { - switch (sym.kind) { - case WRONG_MTH: - return (bestSoFar.kind == WRONG_MTH || bestSoFar.kind == WRONG_MTHS) ? - bestSoFar : - sym; - case ABSENT_MTH: - return bestSoFar; - default: - return sym; + //Check invariants (see {@code LookupHelper.shouldStop}) + Assert.check(bestSoFar.kind >= ERRONEOUS && bestSoFar.kind != AMBIGUOUS); + if (sym.kind < ERRONEOUS) { + //varargs resolution successful + return sym; + } else { + //pick best error + switch (bestSoFar.kind) { + case WRONG_MTH: + case WRONG_MTHS: + //Override previous errors if they were caused by argument mismatch. + //This generally means preferring current symbols - but we need to pay + //attention to the fact that the varargs lookup returns 'less' candidates + //than the previous rounds, and adjust that accordingly. + switch (sym.kind) { + case WRONG_MTH: + //if the previous round matched more than one method, return that + //result instead + return bestSoFar.kind == WRONG_MTHS ? + bestSoFar : sym; + case ABSENT_MTH: + //do not override erroneous symbol if the arity lookup did not + //match any method + return bestSoFar; + case WRONG_MTHS: + default: + //safe to override + return sym; + } + default: + //otherwise, return first error + return bestSoFar; + } } } };
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Sep 05 07:19:14 2014 -0400 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Oct 10 15:53:23 2014 +0100 @@ -74,6 +74,7 @@ private Name accessDollar; private final Types types; private final Lower lower; + private final Flow flow; /** Switch: GJ mode? */ @@ -125,6 +126,7 @@ stringBufferAppend = new HashMap<Type,Symbol>(); accessDollar = names. fromString("access" + target.syntheticNameChar()); + flow = Flow.instance(context); lower = Lower.instance(context); Options options = Options.instance(context); @@ -2516,9 +2518,7 @@ */ if (varDebugInfo && (cdef.sym.flags() & SYNTHETIC) == 0) { try { - LVTAssignAnalyzer lvtAssignAnalyzer = LVTAssignAnalyzer.make( - lvtRanges, syms, names); - lvtAssignAnalyzer.analyzeTree(localEnv); + new LVTAssignAnalyzer().analyzeTree(localEnv); } catch (Throwable e) { throw e; } @@ -2609,11 +2609,10 @@ } } - static class LVTAssignAnalyzer + class LVTAssignAnalyzer extends Flow.AbstractAssignAnalyzer<LVTAssignAnalyzer.LVTAssignPendingExit> { final LVTBits lvtInits; - final LVTRanges lvtRanges; /* This class is anchored to a context dependent tree. The tree can * vary inside the same instruction for example in the switch instruction @@ -2621,35 +2620,12 @@ * to a given case. The aim is to always anchor the bits to the tree * capable of closing a DA range. */ - static class LVTBits extends Bits { - - enum BitsOpKind { - INIT, - CLEAR, - INCL_BIT, - EXCL_BIT, - ASSIGN, - AND_SET, - OR_SET, - DIFF_SET, - XOR_SET, - INCL_RANGE, - EXCL_RANGE, - } + class LVTBits extends Bits { JCTree currentTree; - LVTAssignAnalyzer analyzer; private int[] oldBits = null; BitsState stateBeforeOp; - LVTBits() { - super(false); - } - - LVTBits(int[] bits, BitsState initState) { - super(bits, initState); - } - @Override public void clear() { generalOp(null, -1, BitsOpKind.CLEAR); @@ -2757,12 +2733,11 @@ if (currentTree != null && stateBeforeOp != BitsState.UNKNOWN && trackTree(currentTree)) { - List<VarSymbol> locals = - analyzer.lvtRanges - .getVars(analyzer.currentMethod, currentTree); + List<VarSymbol> locals = lvtRanges + .getVars(currentMethod, currentTree); locals = locals != null ? locals : List.<VarSymbol>nil(); - for (JCVariableDecl vardecl : analyzer.vardecls) { + for (JCVariableDecl vardecl : vardecls) { //once the first is null, the rest will be so. if (vardecl == null) { break; @@ -2772,7 +2747,7 @@ } } if (!locals.isEmpty()) { - analyzer.lvtRanges.setEntry(analyzer.currentMethod, + lvtRanges.setEntry(currentMethod, currentTree, locals); } } @@ -2790,7 +2765,7 @@ boolean trackVar(VarSymbol var) { return (var.owner.kind == MTH && (var.flags() & PARAMETER) == 0 && - analyzer.trackable(var)); + trackable(var)); } boolean trackTree(JCTree tree) { @@ -2806,7 +2781,8 @@ } - public class LVTAssignPendingExit extends Flow.AssignAnalyzer.AssignPendingExit { + public class LVTAssignPendingExit extends + Flow.AbstractAssignAnalyzer<LVTAssignPendingExit>.AbstractAssignPendingExit { LVTAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) { super(tree, inits, uninits); @@ -2819,16 +2795,10 @@ } } - private LVTAssignAnalyzer(LVTRanges lvtRanges, Symtab syms, Names names) { - super(new LVTBits(), syms, names, false); - lvtInits = (LVTBits)inits; - this.lvtRanges = lvtRanges; - } - - public static LVTAssignAnalyzer make(LVTRanges lvtRanges, Symtab syms, Names names) { - LVTAssignAnalyzer result = new LVTAssignAnalyzer(lvtRanges, syms, names); - result.lvtInits.analyzer = result; - return result; + private LVTAssignAnalyzer() { + flow.super(); + lvtInits = new LVTBits(); + inits = lvtInits; } @Override
--- a/src/share/classes/com/sun/tools/javac/util/Bits.java Fri Sep 05 07:19:14 2014 -0400 +++ b/src/share/classes/com/sun/tools/javac/util/Bits.java Fri Oct 10 15:53:23 2014 +0100 @@ -84,6 +84,20 @@ } + public enum BitsOpKind { + INIT, + CLEAR, + INCL_BIT, + EXCL_BIT, + ASSIGN, + AND_SET, + OR_SET, + DIFF_SET, + XOR_SET, + INCL_RANGE, + EXCL_RANGE, + } + private final static int wordlen = 32; private final static int wordshift = 5; private final static int wordmask = wordlen - 1;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8051958/T8051958.java Fri Oct 10 15:53:23 2014 +0100 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8051958 + * @summary Cannot assign a value to final variable in lambda + * @compile T8051958.java + */ + +class T8051958 { + Runnable inst_r = ()-> { + final int x; + x = 1; + }; + + Runnable static_r = ()-> { + final int x; + x = 1; + }; + + { + Runnable inst_r = ()-> { + final int x; + x = 1; + }; + } + + static { + Runnable static_r = ()-> { + final int x; + x = 1; + }; + } + + void instTest() { + Runnable static_r = ()-> { + final int x; + x = 1; + }; + } + + static void staticTest() { + Runnable static_r = ()-> { + final int x; + x = 1; + }; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.java Fri Oct 10 15:53:23 2014 +0100 @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8033483 + * @summary Should ignore nested lambda bodies during overload resolution + * @compile/fail/ref=IgnoreLambdaBodyDuringResolutionTest1.out -XDrawDiagnostics IgnoreLambdaBodyDuringResolutionTest1.java + */ + +class IgnoreLambdaBodyDuringResolutionTest1 { + interface SAM<T> { + T action(T t); + } + + <T> T m(SAM<T> op) { + return null; + } + + class B { + B x() { + return this; + } + } + + class C {} + + void foo(B arg) {} + void foo(C arg) {} + + void bar() { + foo(m(arg -> new B())); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.out Fri Oct 10 15:53:23 2014 +0100 @@ -0,0 +1,2 @@ +IgnoreLambdaBodyDuringResolutionTest1.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(IgnoreLambdaBodyDuringResolutionTest1.B), IgnoreLambdaBodyDuringResolutionTest1, kindname.method, foo(IgnoreLambdaBodyDuringResolutionTest1.C), IgnoreLambdaBodyDuringResolutionTest1 +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.java Fri Oct 10 15:53:23 2014 +0100 @@ -0,0 +1,34 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8033483 + * @summary Should ignore nested lambda bodies during overload resolution + * @compile/fail/ref=IgnoreLambdaBodyDuringResolutionTest2.out -XDrawDiagnostics IgnoreLambdaBodyDuringResolutionTest2.java + */ + +class IgnoreLambdaBodyDuringResolutionTest2 { + interface SAM<S> { + boolean test(S t); + } + + <I, T extends I> I bar(final T l) { + return null; + } + + class D<D1, D2> { + void foo() { + m(bar(e -> false)); + } + + void m(Class<D1> arg) {} + void m(SAM<D2> arg) {} + } + + class F { + void foo() { + m(bar((String e) -> false)); + } + + <F1> void m(Class<F1> arg) {} + <F2> void m(SAM<F2> arg) {} + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.out Fri Oct 10 15:53:23 2014 +0100 @@ -0,0 +1,6 @@ +IgnoreLambdaBodyDuringResolutionTest2.java:19:13: compiler.err.ref.ambiguous: m, kindname.method, m(java.lang.Class<D1>), IgnoreLambdaBodyDuringResolutionTest2.D, kindname.method, m(IgnoreLambdaBodyDuringResolutionTest2.SAM<D2>), IgnoreLambdaBodyDuringResolutionTest2.D +IgnoreLambdaBodyDuringResolutionTest2.java:19:18: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: I,T, (compiler.misc.not.a.functional.intf: java.lang.Object)) +IgnoreLambdaBodyDuringResolutionTest2.java:19:14: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Class<D1>, <any>, kindname.class, IgnoreLambdaBodyDuringResolutionTest2.D<D1,D2>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.assignment.exists: I,T, (compiler.misc.not.a.functional.intf: java.lang.Class))) +IgnoreLambdaBodyDuringResolutionTest2.java:28:13: compiler.err.ref.ambiguous: m, kindname.method, <F1>m(java.lang.Class<F1>), IgnoreLambdaBodyDuringResolutionTest2.F, kindname.method, <F2>m(IgnoreLambdaBodyDuringResolutionTest2.SAM<F2>), IgnoreLambdaBodyDuringResolutionTest2.F +IgnoreLambdaBodyDuringResolutionTest2.java:28:14: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: I,T, (compiler.misc.not.a.functional.intf: java.lang.Class)) +5 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8056014.java Fri Oct 10 15:53:23 2014 +0100 @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8056014 + * @summary Verify that full type inference is used when calling a method on a type variable. + * @compile T8056014.java + * @run main T8056014 + */ + +import java.util.*; + +public class T8056014 { + public static void main(String[] args) { + new T8056014().run(); + } + + void run() { + List<S> l = Arrays.asList(new S()); + C<S> c = new C<>(new S()); + foo(l.get(0).copy(1)); + foo(c.get(0).copy(1)); + } + + void foo(S d) { + } +} + +class B { + public B copy(long j) { + throw new AssertionError("Should not get here."); + } +} + +class S extends B { + public <T> T copy(int i) { + return null; + } +} + +class C<T extends B> { + final T t; + public C(T t) { + this.t = t; + } + public T get(int i) { + return t; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/T8056984.java Fri Oct 10 15:53:23 2014 +0100 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8056984 + * @summary Ensure that method resolution runs over a captured type variables when checking if + * deferred attribution is needed + * @compile T8056984.java + */ +class T8056984<T1 extends B&C, T2 extends T1> { + public T8056984(T1 t1, T2 t2) { + System.err.println(t1.hashCode()); + System.err.println(t2.hashCode()); + } +} +class B { +} +interface C { + public int hashCode(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/8055514/T8055514.java Fri Oct 10 15:53:23 2014 +0100 @@ -0,0 +1,26 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8055514 + * @summary Wrong, confusing error when non-static varargs referenced in static context + * @compile/fail/ref=T8055514.out -Xlint:varargs -Werror -XDrawDiagnostics T8055514.java + */ +class T8055514 { + void m(int... args) { } + + void m2(int... args) { } + static void m2(String s) { } + + void m3(int... args) { } + static void m3(String s) { } + static void m3(Runnable r) { } + + void m4(int... args) { } + void m4(int i1, int i2, int i3) { } + + static void test() { + m(1,2,3); //only one candidate (varargs) - varargs error wins + m2(1,2,3); //two candidates - only one applicable (varargs) - varargs error wins + m3(1,2,3); //three candidates - only one applicable (varargs) - varargs error wins + m4(1,2,3); //two candidates - both applicable - basic error wins + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/8055514/T8055514.out Fri Oct 10 15:53:23 2014 +0100 @@ -0,0 +1,5 @@ +T8055514.java:21:9: compiler.err.non-static.cant.be.ref: kindname.method, m(int...) +T8055514.java:22:9: compiler.err.non-static.cant.be.ref: kindname.method, m2(int...) +T8055514.java:23:9: compiler.err.non-static.cant.be.ref: kindname.method, m3(int...) +T8055514.java:24:9: compiler.err.non-static.cant.be.ref: kindname.method, m4(int,int,int) +4 errors