--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Fri Feb 15 08:28:42 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Fri Feb 15 16:37:19 2013 +0000
@@ -356,26 +356,11 @@
}
public Type getType(Type site) {
- if (capture(site) != site) {
- Type formalInterface = site.tsym.type;
- ListBuffer<Type> typeargs = ListBuffer.lb();
- List<Type> actualTypeargs = site.getTypeArguments();
- //simply replace the wildcards with its bound
- for (Type t : formalInterface.getTypeArguments()) {
- if (actualTypeargs.head.hasTag(WILDCARD)) {
- WildcardType wt = (WildcardType)actualTypeargs.head;
- typeargs.append(wt.type);
- } else {
- typeargs.append(actualTypeargs.head);
- }
- actualTypeargs = actualTypeargs.tail;
- }
- site = subst(formalInterface, formalInterface.getTypeArguments(), typeargs.toList());
- if (!chk.checkValidGenericType(site)) {
- //if the inferred functional interface type is not well-formed,
- //or if it's not a subtype of the original target, issue an error
- throw failure(diags.fragment("no.suitable.functional.intf.inst", site));
- }
+ site = removeWildcards(site);
+ if (!chk.checkValidGenericType(site)) {
+ //if the inferred functional interface type is not well-formed,
+ //or if it's not a subtype of the original target, issue an error
+ throw failure(diags.fragment("no.suitable.functional.intf.inst", site));
}
return memberType(site, descSym);
}
@@ -584,6 +569,27 @@
return false;
}
}
+
+ public Type removeWildcards(Type site) {
+ if (capture(site) != site) {
+ Type formalInterface = site.tsym.type;
+ ListBuffer<Type> typeargs = ListBuffer.lb();
+ List<Type> actualTypeargs = site.getTypeArguments();
+ //simply replace the wildcards with its bound
+ for (Type t : formalInterface.getTypeArguments()) {
+ if (actualTypeargs.head.hasTag(WILDCARD)) {
+ WildcardType wt = (WildcardType)actualTypeargs.head;
+ typeargs.append(wt.type);
+ } else {
+ typeargs.append(actualTypeargs.head);
+ }
+ actualTypeargs = actualTypeargs.tail;
+ }
+ return subst(formalInterface, formalInterface.getTypeArguments(), typeargs.toList());
+ } else {
+ return site;
+ }
+ }
// </editor-fold>
/**
@@ -2600,16 +2606,17 @@
candidates = candidates.prepend((MethodSymbol)s);
}
}
- return prune(candidates, ownerComparator);
+ return prune(candidates);
}
- public List<MethodSymbol> prune(List<MethodSymbol> methods, Comparator<MethodSymbol> cmp) {
+ public List<MethodSymbol> prune(List<MethodSymbol> methods) {
ListBuffer<MethodSymbol> methodsMin = ListBuffer.lb();
for (MethodSymbol m1 : methods) {
boolean isMin_m1 = true;
for (MethodSymbol m2 : methods) {
if (m1 == m2) continue;
- if (cmp.compare(m2, m1) < 0) {
+ if (m2.owner != m1.owner &&
+ asSuper(m2.owner.type, m1.owner) != null) {
isMin_m1 = false;
break;
}
@@ -2619,12 +2626,6 @@
}
return methodsMin.toList();
}
-
- Comparator<MethodSymbol> ownerComparator = new Comparator<MethodSymbol>() {
- public int compare(MethodSymbol s1, MethodSymbol s2) {
- return s1.owner.isSubClass(s2.owner, Types.this) ? -1 : 1;
- }
- };
// where
private class MethodFilter implements Filter<Symbol> {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Feb 15 08:28:42 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Feb 15 16:37:19 2013 +0000
@@ -2532,8 +2532,7 @@
try {
//attribute member reference qualifier - if this is a constructor
//reference, the expected kind must be a type
- Type exprType = attribTree(that.expr,
- env, new ResultInfo(that.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType));
+ Type exprType = attribTree(that.expr, env, memberReferenceQualifierResult(that));
if (that.getMode() == JCMemberReference.ReferenceMode.NEW) {
exprType = chk.checkConstructorRefType(that.expr, exprType);
@@ -2622,8 +2621,11 @@
}
}
+ that.sym = refSym.baseSymbol();
+ that.kind = lookupHelper.referenceKind(that.sym);
+
if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
- if (refSym.isStatic() && TreeInfo.isStaticSelector(that.expr, names) &&
+ if (that.sym.isStatic() && TreeInfo.isStaticSelector(that.expr, names) &&
exprType.getTypeArguments().nonEmpty()) {
//static ref with class type-args
log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
@@ -2632,14 +2634,19 @@
return;
}
- if (refSym.isStatic() && !TreeInfo.isStaticSelector(that.expr, names) &&
- !lookupHelper.referenceKind(refSym).isUnbound()) {
+ if (that.sym.isStatic() && !TreeInfo.isStaticSelector(that.expr, names) &&
+ !that.kind.isUnbound()) {
//no static bound mrefs
log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
diags.fragment("static.bound.mref"));
result = that.type = types.createErrorType(target);
return;
}
+
+ if (!refSym.isStatic() && that.kind == JCMemberReference.ReferenceKind.SUPER) {
+ // Check that super-qualified symbols are not abstract (JLS)
+ rs.checkNonAbstract(that.pos(), that.sym);
+ }
}
if (desc.getReturnType() == Type.recoveryType) {
@@ -2680,6 +2687,12 @@
return;
}
}
+ //where
+ ResultInfo memberReferenceQualifierResult(JCMemberReference tree) {
+ //if this is a constructor reference, the expected kind must be a type
+ return new ResultInfo(tree.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType);
+ }
+
@SuppressWarnings("fallthrough")
void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Feb 15 08:28:42 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Feb 15 16:37:19 2013 +0000
@@ -2232,10 +2232,13 @@
void checkFunctionalInterface(JCTree tree, Type funcInterface) {
ClassType c = new ClassType(Type.noType, List.<Type>nil(), null);
ClassSymbol csym = new ClassSymbol(0, names.empty, c, syms.noSymbol);
- c.interfaces_field = List.of(funcInterface);
+ c.interfaces_field = List.of(types.removeWildcards(funcInterface));
c.supertype_field = syms.objectType;
c.tsym = csym;
csym.members_field = new Scope(csym);
+ Symbol descSym = types.findDescriptorSymbol(funcInterface.tsym);
+ Type descType = types.findDescriptorType(funcInterface);
+ csym.members_field.enter(new MethodSymbol(PUBLIC, descSym.name, descType, csym));
csym.completer = null;
checkImplementations(tree, csym, csym);
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Feb 15 08:28:42 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Feb 15 16:37:19 2013 +0000
@@ -68,6 +68,7 @@
final JCDiagnostic.Factory diags;
final Enter enter;
final Infer infer;
+ final Resolve rs;
final Log log;
final Symtab syms;
final TreeMaker make;
@@ -87,6 +88,7 @@
diags = JCDiagnostic.Factory.instance(context);
enter = Enter.instance(context);
infer = Infer.instance(context);
+ rs = Resolve.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
make = TreeMaker.instance(context);
@@ -463,10 +465,12 @@
ResultInfo resultInfo;
InferenceContext inferenceContext;
+ Env<AttrContext> env;
public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
this.resultInfo = resultInfo;
this.inferenceContext = deferredAttrContext.inferenceContext;
+ this.env = dt.env.dup(dt.tree, dt.env.info.dup());
dt.tree.accept(this);
dt.speculativeCache.put(deferredAttrContext.msym, stuckTree, deferredAttrContext.phase);
return Type.noType;
@@ -511,12 +515,30 @@
return;
} else {
try {
- //TODO: we should speculative determine if there's a match
- //based on arity - if yes, method is applicable.
types.findDescriptorType(pt);
} catch (Types.FunctionDescriptorLookupError ex) {
checkContext.report(null, ex.getDiagnostic());
}
+ JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), env,
+ attr.memberReferenceQualifierResult(tree));
+ ListBuffer<Type> argtypes = ListBuffer.lb();
+ for (Type t : types.findDescriptorType(pt).getParameterTypes()) {
+ argtypes.append(syms.errType);
+ }
+ JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree);
+ mref2.expr = exprTree;
+ Pair<Symbol, ?> lookupRes =
+ rs.resolveMemberReference(tree, env, mref2, exprTree.type, tree.name, argtypes.toList(), null, true);
+ switch (lookupRes.fst.kind) {
+ //note: as argtypes are erroneous types, type-errors must
+ //have been caused by arity mismatch
+ case Kinds.ABSENT_MTH:
+ case Kinds.WRONG_MTH:
+ case Kinds.WRONG_MTHS:
+ case Kinds.STATICERR:
+ case Kinds.MISSING_ENCL:
+ checkContext.report(null, diags.fragment("incompatible.arg.types.in.mref"));
+ }
}
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Feb 15 08:28:42 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Feb 15 16:37:19 2013 +0000
@@ -2501,10 +2501,10 @@
//merge results
Pair<Symbol, ReferenceLookupHelper> res;
- if (unboundSym.kind != MTH) {
+ if (!lookupSuccess(unboundSym)) {
res = new Pair<Symbol, ReferenceLookupHelper>(boundSym, boundLookupHelper);
env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
- } else if (boundSym.kind == MTH) {
+ } else if (lookupSuccess(boundSym)) {
res = new Pair<Symbol, ReferenceLookupHelper>(ambiguityError(boundSym, unboundSym), boundLookupHelper);
env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
} else {
@@ -2514,6 +2514,10 @@
return res;
}
+ //private
+ boolean lookupSuccess(Symbol s) {
+ return s.kind == MTH || s.kind == AMBIGUOUS;
+ }
/**
* Helper for defining custom method-like lookup logic; a lookup helper
@@ -2706,9 +2710,11 @@
UnboundMethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
- super(referenceTree, name,
- site.isRaw() ? types.asSuper(argtypes.head, site.tsym) : site,
- argtypes.tail, typeargtypes, maxPhase);
+ super(referenceTree, name, site, argtypes.tail, typeargtypes, maxPhase);
+ Type asSuperSite = types.asSuper(argtypes.head, site.tsym);
+ if (site.isRaw() && !asSuperSite.isErroneous()) {
+ this.site = asSuperSite;
+ }
}
@Override
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Feb 15 08:28:42 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Feb 15 16:37:19 2013 +0000
@@ -2867,7 +2867,7 @@
* | Identifier "=" AnnotationValue
*/
JCExpression annotationFieldValue() {
- if (token.kind == IDENTIFIER) {
+ if (LAX_IDENTIFIER.accepts(token.kind)) {
mode = EXPR;
JCExpression t1 = term1();
if (t1.hasTag(IDENT) && token.kind == EQ) {
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Feb 15 08:28:42 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Feb 15 16:37:19 2013 +0000
@@ -724,6 +724,9 @@
compiler.misc.incompatible.arg.types.in.lambda=\
incompatible parameter types in lambda expression
+compiler.misc.incompatible.arg.types.in.mref=\
+ incompatible parameter types in method reference
+
compiler.err.new.not.allowed.in.annotation=\
''new'' not allowed in an annotation
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInMethodRef.java Fri Feb 15 16:37:19 2013 +0000
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013, 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.
+ */
+
+// key: compiler.err.cant.apply.symbol
+// key: compiler.misc.infer.no.conforming.assignment.exists
+// key: compiler.misc.incompatible.arg.types.in.mref
+
+class IncompatibleArgTypesInMethodRef {
+ interface SAM<X> {
+ void m(X x);
+ }
+
+ void g(String s, Integer i) { }
+
+ <Z> void m(SAM<Z> s) { }
+
+ void test() {
+ m(this::g);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/FunctionalInterfaceAnno02.java Fri Feb 15 16:37:19 2013 +0000
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, 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 8007535
+ * @summary Compiler crashes on FunctionalInterface used on interface with two inherited methods with same signatures
+ * @compile FunctionalInterfaceAnno02.java
+ */
+class FunctionalInterfaceAnno02 {
+ interface Foo<T, N extends Number> {
+ void m(T arg);
+ void m(N arg);
+ }
+
+ @FunctionalInterface
+ interface Baz extends Foo<Integer, Integer> { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/IdentifierTest.java Fri Feb 15 16:37:19 2013 +0000
@@ -0,0 +1,182 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007401 8007427
+ * @author sogoel
+ * @summary Test generation of warnings when '_' is used an identifier
+ * @compile/fail/ref=IdentifierTest.out -Werror -XDrawDiagnostics IdentifierTest.java
+ */
+
+import java.util.List;
+
+/*
+ * This test checks for the generation of warnings when '_' is used as an
+ * identifier in following cases:
+ * package name, class name, class member names including constructor
+ * cass members access using class object or this
+ * loops: for, enhanced-for, while, do-while
+ * arrays,
+ * switch,
+ * annotations, element=value pair
+ * try-catch,
+ * enum
+ * break + identifier
+ * continue + identifier
+ * type-bounds
+ * Above cases for identifier occurrences have been identified from JLS v3.
+ *
+ */
+
+// Test class
+public class IdentifierTest {
+ class _UnderscorePrefix {}
+ class Underscore_Infix {}
+ class UnderscorePostfix_ {}
+ class __ {}
+
+ static final int _prefix = 10;
+ List<String> postfix_;
+
+ // Test: class with name as '_'
+ class _ {
+ String in_fix;
+ //Test: Constructor, "_", local variable, value
+ public _() {
+ String _ = "_";
+ in_fix = _;
+ }
+
+ public void testClassMembersAccess(String[] _args) {
+ // Instance creation
+ _ _ = new _();
+ //Method invocation
+ _.testTryCatch();
+ //Field access
+ _.in_fix = "__";
+ }
+
+ // Test: try-catch
+ public void testTryCatch() {
+ try {
+ int _ = 30/0;
+ } catch (ArithmeticException _) {
+ System.out.println("Got Arithmentic exception " + _);
+ }
+ }
+ }
+
+ // Test: class member access using class object '_', use of this.
+ class TestMisc {
+ int _;
+ void _ () {
+ this._ = 5;
+ }
+
+ public void testClassMemberAccess(String[] args) {
+ // Instance creation
+ TestMisc _ = new TestMisc();
+ //Field access
+ _._ = 10;
+ //Method access
+ _._();
+ }
+ }
+
+ //Test: Type Bounds
+ class TestTypeBounds {
+ //Type bounds
+ <_ extends Object> void test(_ t) {}
+ }
+
+ // Test: enum and switch case
+ static class TestEnum {
+ // Enum
+ enum _ {
+ _MONDAY, _TUESDAY, _WEDNESDAY, _THURSDAY, _FRIDAY,
+ _SATURDAY, _SUNDAY;
+ }
+
+ void foo() {
+ // switch-case
+ for(_ _day : _.values()) {
+ switch(_day) {
+ case _SATURDAY:
+ case _SUNDAY:
+ System.out.println("Weekend is here!");
+ break;
+ default:
+ System.out.println("Weekday is here!");
+ break;
+ }
+ }
+ }
+ }
+
+ // Test: Annotation
+ static class TestAnno {
+ // Annotation with name as _
+ @interface _ {
+ String _name();
+ int _id();
+ }
+ // Element-Value pair
+ @_(_name ="m",_id=1)
+ public void m(int arg) {}
+
+ //Annotation with _ as one of the elements
+ @interface MyAnno {
+ int _();
+ }
+ // Element Value pair
+ @MyAnno(_='1')
+ public void m2() {}
+ }
+
+ // Test: for loop, while loop, do-while loop, increment/decrement op, condition, print
+ public void testLoop() {
+ // for loop
+ for(int _ = 0; _ < 5; ++_) {
+ System.out.println("_=" + _ + " ");
+ }
+
+ // while loop
+ int _ = 0;
+ while(_ <= 5) {
+ _++;
+ }
+
+ //do-while loop
+ do {
+ --_;
+ } while(_ > 0);
+ }
+
+ // Test: Array and enhanced for loop
+ public void testArraysEnhancedForLoop() {
+ // Arrays
+ String _[] = {"A","B","C","D"};
+
+ for(String _s : _ ) {
+ System.out.println("_s="+_s);
+ }
+ }
+
+ // Test: Labels in break, continue
+ public void testLabels() {
+ // break/continue with labels
+ int j = 0;
+ _:
+ for (int i = 0; i <= 5; i++) {
+ while( j > 4 ) {
+ j++;
+ continue _;
+ }
+ break _;
+ }
+ }
+}
+
+//interface
+interface _ {
+ void mI();
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/IdentifierTest.out Fri Feb 15 16:37:19 2013 +0000
@@ -0,0 +1,47 @@
+IdentifierTest.java:40:11: compiler.warn.underscore.as.identifier
+IdentifierTest.java:43:16: compiler.warn.underscore.as.identifier
+IdentifierTest.java:44:20: compiler.warn.underscore.as.identifier
+IdentifierTest.java:45:22: compiler.warn.underscore.as.identifier
+IdentifierTest.java:50:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:50:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:50:23: compiler.warn.underscore.as.identifier
+IdentifierTest.java:52:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:54:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:60:21: compiler.warn.underscore.as.identifier
+IdentifierTest.java:61:42: compiler.warn.underscore.as.identifier
+IdentifierTest.java:62:67: compiler.warn.underscore.as.identifier
+IdentifierTest.java:69:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:70:14: compiler.warn.underscore.as.identifier
+IdentifierTest.java:71:18: compiler.warn.underscore.as.identifier
+IdentifierTest.java:76:22: compiler.warn.underscore.as.identifier
+IdentifierTest.java:78:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:78:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:80:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:80:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:87:10: compiler.warn.underscore.as.identifier
+IdentifierTest.java:87:38: compiler.warn.underscore.as.identifier
+IdentifierTest.java:93:14: compiler.warn.underscore.as.identifier
+IdentifierTest.java:100:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:100:26: compiler.warn.underscore.as.identifier
+IdentifierTest.java:117:20: compiler.warn.underscore.as.identifier
+IdentifierTest.java:122:10: compiler.warn.underscore.as.identifier
+IdentifierTest.java:127:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:130:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:137:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:137:24: compiler.warn.underscore.as.identifier
+IdentifierTest.java:137:33: compiler.warn.underscore.as.identifier
+IdentifierTest.java:138:39: compiler.warn.underscore.as.identifier
+IdentifierTest.java:142:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:143:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:144:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:149:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:150:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:156:16: compiler.warn.underscore.as.identifier
+IdentifierTest.java:158:25: compiler.warn.underscore.as.identifier
+IdentifierTest.java:167:5: compiler.warn.underscore.as.identifier
+IdentifierTest.java:171:26: compiler.warn.underscore.as.identifier
+IdentifierTest.java:173:19: compiler.warn.underscore.as.identifier
+IdentifierTest.java:179:11: compiler.warn.underscore.as.identifier
+- compiler.err.warnings.and.werror
+1 error
+44 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv26.java Fri Feb 15 16:37:19 2013 +0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2013, 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 8006749
+ * @summary compiler does not allow Object protected methods to be used in lambda
+ * @compile LambdaConv26.java
+ */
+public class LambdaConv26 {
+ interface I {
+ Object clone();
+ }
+
+ Object m() { return null; }
+
+ void test() {
+ I i1 = ()->null;
+ I i2 = this::m;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference62.java Fri Feb 15 16:37:19 2013 +0000
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007285
+ * @summary AbstractMethodError instead of compile-time error when method reference with super and abstract
+ * @compile/fail/ref=MethodReference62.out -XDrawDiagnostics MethodReference62.java
+ */
+class MethodReference62 {
+ interface SAM {
+ int m();
+ }
+
+ static abstract class Sup {
+ abstract int foo() ;
+ }
+
+ static abstract class Sub extends Sup {
+ abstract int foo() ;
+ void test() {
+ SAM s = super::foo;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference62.out Fri Feb 15 16:37:19 2013 +0000
@@ -0,0 +1,2 @@
+MethodReference62.java:19:21: compiler.err.abstract.cant.be.accessed.directly: kindname.method, foo(), MethodReference62.Sup
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType60.java Fri Feb 15 16:37:19 2013 +0000
@@ -0,0 +1,51 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007462
+ * @summary Fix provisional applicability for method references
+ * @compile/fail/ref=TargetType60.out -XDrawDiagnostics TargetType60.java
+ */
+class TargetType60 {
+
+ interface Sam0 {
+ void m();
+ }
+
+ interface Sam1<X> {
+ void m(X x);
+ }
+
+ interface Sam2<X,Y> {
+ void m(X x, Y y);
+ }
+
+ void m0() { }
+ void m1(String s) { }
+ void m2(String s1, String s2) { }
+
+ void m01() { }
+ void m01(String s) { }
+
+ void m012() { }
+ void m012(String s) { }
+ void m012(String s1, String s2) { }
+
+ static String g(Sam0 s) { return null; }
+ static <U> U g(Sam1<U> s) { return null; }
+ static <U> U g(Sam2<U,String> s) { return null; }
+
+ void testBound() {
+ String s1 = g(this::m0); //ok - resolves to g(Sam0)
+ String s2 = g(this::m1); //ok - resolves to g(Sam1)
+ String s3 = g(this::m2); //ok - resolves to g(Sam2)
+ String s4 = g(this::m01);//ambiguous (g(Sam0), g(Sam1) apply)
+ String s5 = g(this::m012);//ambiguous (g(Sam0), g(Sam1), g(Sam2) apply)
+ }
+
+ static void testUnbound() {
+ TargetType60 s1 = g(TargetType60::m0); //ok - resolves to g(Sam1)
+ TargetType60 s2 = g(TargetType60::m1); //ok - resolves to g(Sam2)
+ TargetType60 s3 = g(TargetType60::m2); //none is applicable
+ TargetType60 s4 = g(TargetType60::m01);//ambiguous (g(Sam1), g(Sam2) apply)
+ TargetType60 s5 = g(TargetType60::m012);//ambiguous (g(Sam1), g(Sam2) apply)
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType60.out Fri Feb 15 16:37:19 2013 +0000
@@ -0,0 +1,6 @@
+TargetType60.java:40:21: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType60.Sam0), TargetType60, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60
+TargetType60.java:41:21: compiler.err.ref.ambiguous: g, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>g(TargetType60.Sam2<U,java.lang.String>), TargetType60
+TargetType60.java:47:27: compiler.err.cant.apply.symbols: kindname.method, g, @1308,{(compiler.misc.inapplicable.method: kindname.method, TargetType60, g(TargetType60.Sam0), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.String,java.lang.String, compiler.misc.no.args, kindname.class, TargetType60, (compiler.misc.arg.length.mismatch))))),(compiler.misc.inapplicable.method: kindname.method, TargetType60, <U>g(TargetType60.Sam1<U>), (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.arg.types.in.mref))),(compiler.misc.inapplicable.method: kindname.method, TargetType60, <U>g(TargetType60.Sam2<U,java.lang.String>), (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.arg.types.in.mref)))}
+TargetType60.java:48:27: compiler.err.ref.ambiguous: g, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>g(TargetType60.Sam2<U,java.lang.String>), TargetType60
+TargetType60.java:49:27: compiler.err.ref.ambiguous: g, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>g(TargetType60.Sam2<U,java.lang.String>), TargetType60
+5 errors