8003280: Add lambda tests
authormcimadamore
Sat, 17 Nov 2012 19:01:03 +0000
changeset 14547 86d8d242b0c4
parent 14546 7e2a1569de76
child 14548 aa687b312c97
8003280: Add lambda tests Summary: Turn on lambda expression, method reference and default method support Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/code/Flags.java
langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
langtools/src/share/classes/com/sun/tools/javac/code/Types.java
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java
langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java
langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java
langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java
langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java
langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java
langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java
langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java
langtools/src/share/classes/com/sun/tools/javac/util/Warner.java
langtools/test/tools/javac/conditional/Conditional.java
langtools/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java
langtools/test/tools/javac/defaultMethods/Neg01.java
langtools/test/tools/javac/defaultMethods/Neg02.java
langtools/test/tools/javac/defaultMethods/Neg03.java
langtools/test/tools/javac/defaultMethods/Neg04.java
langtools/test/tools/javac/defaultMethods/Neg05.java
langtools/test/tools/javac/defaultMethods/Neg06.java
langtools/test/tools/javac/defaultMethods/Neg07.java
langtools/test/tools/javac/defaultMethods/Neg08.java
langtools/test/tools/javac/defaultMethods/Neg09.java
langtools/test/tools/javac/defaultMethods/Neg10.java
langtools/test/tools/javac/defaultMethods/Neg11.java
langtools/test/tools/javac/defaultMethods/Neg12.java
langtools/test/tools/javac/defaultMethods/Neg12.out
langtools/test/tools/javac/defaultMethods/Neg13.java
langtools/test/tools/javac/defaultMethods/Neg14.java
langtools/test/tools/javac/defaultMethods/Neg15.java
langtools/test/tools/javac/defaultMethods/Neg16.java
langtools/test/tools/javac/defaultMethods/Pos01.java
langtools/test/tools/javac/defaultMethods/Pos02.java
langtools/test/tools/javac/defaultMethods/Pos04.java
langtools/test/tools/javac/defaultMethods/Pos05.java
langtools/test/tools/javac/defaultMethods/Pos06.java
langtools/test/tools/javac/defaultMethods/Pos07.java
langtools/test/tools/javac/defaultMethods/Pos08.java
langtools/test/tools/javac/defaultMethods/Pos10.java
langtools/test/tools/javac/defaultMethods/Pos11.java
langtools/test/tools/javac/defaultMethods/Pos12.java
langtools/test/tools/javac/defaultMethods/Pos13.java
langtools/test/tools/javac/defaultMethods/Pos14.java
langtools/test/tools/javac/defaultMethods/Pos15.java
langtools/test/tools/javac/defaultMethods/Pos16.java
langtools/test/tools/javac/defaultMethods/TestDefaultBody.java
langtools/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java
langtools/test/tools/javac/defaultMethods/fd/FDTest.java
langtools/test/tools/javac/defaultMethods/separate/Separate.java
langtools/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java
langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java
langtools/test/tools/javac/diags/examples/CantAccessArgTypeInFunctionalDesc.java
langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java
langtools/test/tools/javac/diags/examples/CantAccessReturnTypeInFunctionalDesc.java
langtools/test/tools/javac/diags/examples/CantAccessThrownTypesInFunctionalDesc.java
langtools/test/tools/javac/diags/examples/CantApplySymbolFragment.java
langtools/test/tools/javac/diags/examples/CantApplySymbolsFragment.java
langtools/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java
langtools/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java
langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java
langtools/test/tools/javac/diags/examples/CantReturnValueForVoid.java
langtools/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java
langtools/test/tools/javac/diags/examples/CyclicInference.java
langtools/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java
langtools/test/tools/javac/diags/examples/IncompatibleAbstracts.java
langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java
langtools/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java
langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java
langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java
langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java
langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java
langtools/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java
langtools/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java
langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java
langtools/test/tools/javac/diags/examples/MissingReturnValue.java
langtools/test/tools/javac/diags/examples/MissingReturnValueFragment.java
langtools/test/tools/javac/diags/examples/NoAbstracts.java
langtools/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java
langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java
langtools/test/tools/javac/diags/examples/NotAFunctionalIntf.java
langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java
langtools/test/tools/javac/diags/examples/OverriddenDefault.java
langtools/test/tools/javac/diags/examples/PotentialLambdaFound.java
langtools/test/tools/javac/diags/examples/RedundantSupertype.java
langtools/test/tools/javac/diags/examples/RefAmbiguousFragment.java
langtools/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java
langtools/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java
langtools/test/tools/javac/diags/examples/UnexpectedLambda.java
langtools/test/tools/javac/diags/examples/UnexpectedMref.java
langtools/test/tools/javac/diags/examples/UnexpectedReturnValue.java
langtools/test/tools/javac/generics/7022054/T7022054pos1.java
langtools/test/tools/javac/generics/7022054/T7022054pos1.out
langtools/test/tools/javac/generics/7022054/T7022054pos2.java
langtools/test/tools/javac/generics/7022054/T7022054pos2.out
langtools/test/tools/javac/lambda/BadAccess.java
langtools/test/tools/javac/lambda/BadAccess.out
langtools/test/tools/javac/lambda/BadAccess02.java
langtools/test/tools/javac/lambda/BadAccess02.out
langtools/test/tools/javac/lambda/BadAccess03.java
langtools/test/tools/javac/lambda/BadAccess03.out
langtools/test/tools/javac/lambda/BadBreakContinue.java
langtools/test/tools/javac/lambda/BadBreakContinue.out
langtools/test/tools/javac/lambda/BadConv03.java
langtools/test/tools/javac/lambda/BadConv03.out
langtools/test/tools/javac/lambda/BadConv04.java
langtools/test/tools/javac/lambda/BadConv04.out
langtools/test/tools/javac/lambda/BadExpressionLambda.java
langtools/test/tools/javac/lambda/BadExpressionLambda.out
langtools/test/tools/javac/lambda/BadLambdaExpr.java
langtools/test/tools/javac/lambda/BadLambdaPos.java
langtools/test/tools/javac/lambda/BadLambdaPos.out
langtools/test/tools/javac/lambda/BadMethodCall.java
langtools/test/tools/javac/lambda/BadMethodCall.out
langtools/test/tools/javac/lambda/BadRecovery.java
langtools/test/tools/javac/lambda/BadRecovery.out
langtools/test/tools/javac/lambda/BadReturn.java
langtools/test/tools/javac/lambda/BadReturn.out
langtools/test/tools/javac/lambda/BadStatementInLambda.java
langtools/test/tools/javac/lambda/BadStatementInLambda.out
langtools/test/tools/javac/lambda/BadStatementInLambda02.java
langtools/test/tools/javac/lambda/BadStatementInLambda02.out
langtools/test/tools/javac/lambda/BadTargetType.java
langtools/test/tools/javac/lambda/BadTargetType.out
langtools/test/tools/javac/lambda/Conditional01.java
langtools/test/tools/javac/lambda/Conditional02.java
langtools/test/tools/javac/lambda/Conditional03.java
langtools/test/tools/javac/lambda/Conformance01.java
langtools/test/tools/javac/lambda/Defender01.java
langtools/test/tools/javac/lambda/DisjunctiveTypeTest.java
langtools/test/tools/javac/lambda/EffectivelyFinal01.java
langtools/test/tools/javac/lambda/EffectivelyFinal01.out
langtools/test/tools/javac/lambda/EffectivelyFinalTest.java
langtools/test/tools/javac/lambda/EffectivelyFinalTest01.out
langtools/test/tools/javac/lambda/EffectivelyFinalTest02.out
langtools/test/tools/javac/lambda/ErroneousArg.java
langtools/test/tools/javac/lambda/ErroneousArg.out
langtools/test/tools/javac/lambda/ErroneousLambdaExpr.java
langtools/test/tools/javac/lambda/InnerConstructor.java
langtools/test/tools/javac/lambda/LambdaCapture01.java
langtools/test/tools/javac/lambda/LambdaCapture02.java
langtools/test/tools/javac/lambda/LambdaCapture03.java
langtools/test/tools/javac/lambda/LambdaCapture04.java
langtools/test/tools/javac/lambda/LambdaCapture05.java
langtools/test/tools/javac/lambda/LambdaCapture06.java
langtools/test/tools/javac/lambda/LambdaConv01.java
langtools/test/tools/javac/lambda/LambdaConv03.java
langtools/test/tools/javac/lambda/LambdaConv05.java
langtools/test/tools/javac/lambda/LambdaConv06.java
langtools/test/tools/javac/lambda/LambdaConv08.java
langtools/test/tools/javac/lambda/LambdaConv09.java
langtools/test/tools/javac/lambda/LambdaConv09.out
langtools/test/tools/javac/lambda/LambdaConv10.java
langtools/test/tools/javac/lambda/LambdaConv10.out
langtools/test/tools/javac/lambda/LambdaConv11.java
langtools/test/tools/javac/lambda/LambdaConv12.java
langtools/test/tools/javac/lambda/LambdaConv13.java
langtools/test/tools/javac/lambda/LambdaConv16.java
langtools/test/tools/javac/lambda/LambdaConv17.java
langtools/test/tools/javac/lambda/LambdaConv18.java
langtools/test/tools/javac/lambda/LambdaConv18.out
langtools/test/tools/javac/lambda/LambdaConv19.java
langtools/test/tools/javac/lambda/LambdaConv20.java
langtools/test/tools/javac/lambda/LambdaConv21.java
langtools/test/tools/javac/lambda/LambdaConv21.out
langtools/test/tools/javac/lambda/LambdaConv22.java
langtools/test/tools/javac/lambda/LambdaConv23.java
langtools/test/tools/javac/lambda/LambdaConv24.java
langtools/test/tools/javac/lambda/LambdaConversionTest.java
langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java
langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out
langtools/test/tools/javac/lambda/LambdaExpr01.java
langtools/test/tools/javac/lambda/LambdaExpr02.java
langtools/test/tools/javac/lambda/LambdaExpr04.java
langtools/test/tools/javac/lambda/LambdaExpr05.java
langtools/test/tools/javac/lambda/LambdaExpr06.java
langtools/test/tools/javac/lambda/LambdaExpr07.java
langtools/test/tools/javac/lambda/LambdaExpr08.java
langtools/test/tools/javac/lambda/LambdaExpr09.java
langtools/test/tools/javac/lambda/LambdaExpr10.java
langtools/test/tools/javac/lambda/LambdaExpr10.out
langtools/test/tools/javac/lambda/LambdaExpr11.java
langtools/test/tools/javac/lambda/LambdaExpr12.java
langtools/test/tools/javac/lambda/LambdaExpr13.java
langtools/test/tools/javac/lambda/LambdaExpr14.java
langtools/test/tools/javac/lambda/LambdaExpr15.java
langtools/test/tools/javac/lambda/LambdaExpr16.java
langtools/test/tools/javac/lambda/LambdaExpr17.java
langtools/test/tools/javac/lambda/LambdaExpr18.java
langtools/test/tools/javac/lambda/LambdaExpr19.java
langtools/test/tools/javac/lambda/LambdaExpr19.out
langtools/test/tools/javac/lambda/LambdaExpr20.java
langtools/test/tools/javac/lambda/LambdaExprNotVoid.java
langtools/test/tools/javac/lambda/LambdaExprNotVoid.out
langtools/test/tools/javac/lambda/LambdaParserTest.java
langtools/test/tools/javac/lambda/LambdaScope01.java
langtools/test/tools/javac/lambda/LambdaScope02.java
langtools/test/tools/javac/lambda/LambdaScope03.java
langtools/test/tools/javac/lambda/LambdaScope04.java
langtools/test/tools/javac/lambda/LambdaScope04.out
langtools/test/tools/javac/lambda/LocalBreakAndContinue.java
langtools/test/tools/javac/lambda/MethodReference01.java
langtools/test/tools/javac/lambda/MethodReference02.java
langtools/test/tools/javac/lambda/MethodReference03.java
langtools/test/tools/javac/lambda/MethodReference04.java
langtools/test/tools/javac/lambda/MethodReference04.out
langtools/test/tools/javac/lambda/MethodReference05.java
langtools/test/tools/javac/lambda/MethodReference06.java
langtools/test/tools/javac/lambda/MethodReference07.java
langtools/test/tools/javac/lambda/MethodReference08.java
langtools/test/tools/javac/lambda/MethodReference08.out
langtools/test/tools/javac/lambda/MethodReference09.java
langtools/test/tools/javac/lambda/MethodReference09.out
langtools/test/tools/javac/lambda/MethodReference10.java
langtools/test/tools/javac/lambda/MethodReference11.java
langtools/test/tools/javac/lambda/MethodReference12.java
langtools/test/tools/javac/lambda/MethodReference13.java
langtools/test/tools/javac/lambda/MethodReference14.java
langtools/test/tools/javac/lambda/MethodReference15.java
langtools/test/tools/javac/lambda/MethodReference16.java
langtools/test/tools/javac/lambda/MethodReference17.java
langtools/test/tools/javac/lambda/MethodReference18.java
langtools/test/tools/javac/lambda/MethodReference19.java
langtools/test/tools/javac/lambda/MethodReference20.java
langtools/test/tools/javac/lambda/MethodReference20.out
langtools/test/tools/javac/lambda/MethodReference21.java
langtools/test/tools/javac/lambda/MethodReference21.out
langtools/test/tools/javac/lambda/MethodReference22.java
langtools/test/tools/javac/lambda/MethodReference22.out
langtools/test/tools/javac/lambda/MethodReference23.java
langtools/test/tools/javac/lambda/MethodReference23.out
langtools/test/tools/javac/lambda/MethodReference24.java
langtools/test/tools/javac/lambda/MethodReference25.java
langtools/test/tools/javac/lambda/MethodReference26.java
langtools/test/tools/javac/lambda/MethodReference26.out
langtools/test/tools/javac/lambda/MethodReference27.java
langtools/test/tools/javac/lambda/MethodReference28.java
langtools/test/tools/javac/lambda/MethodReference28.out
langtools/test/tools/javac/lambda/MethodReference29.java
langtools/test/tools/javac/lambda/MethodReference30.java
langtools/test/tools/javac/lambda/MethodReference31.java
langtools/test/tools/javac/lambda/MethodReference32.java
langtools/test/tools/javac/lambda/MethodReference32.out
langtools/test/tools/javac/lambda/MethodReference33.java
langtools/test/tools/javac/lambda/MethodReference34.java
langtools/test/tools/javac/lambda/MethodReference35.java
langtools/test/tools/javac/lambda/MethodReference36.java
langtools/test/tools/javac/lambda/MethodReference37.java
langtools/test/tools/javac/lambda/MethodReference37.out
langtools/test/tools/javac/lambda/MethodReference38.java
langtools/test/tools/javac/lambda/MethodReference38.out
langtools/test/tools/javac/lambda/MethodReference39.java
langtools/test/tools/javac/lambda/MethodReference39.out
langtools/test/tools/javac/lambda/MethodReference40.java
langtools/test/tools/javac/lambda/MethodReference40.out
langtools/test/tools/javac/lambda/MethodReference41.java
langtools/test/tools/javac/lambda/MethodReference42.java
langtools/test/tools/javac/lambda/MethodReference43.java
langtools/test/tools/javac/lambda/MethodReference44.java
langtools/test/tools/javac/lambda/MethodReference45.java
langtools/test/tools/javac/lambda/MethodReference45.out
langtools/test/tools/javac/lambda/MethodReference46.java
langtools/test/tools/javac/lambda/MethodReference47.java
langtools/test/tools/javac/lambda/MethodReference47.out
langtools/test/tools/javac/lambda/MethodReference48.java
langtools/test/tools/javac/lambda/MethodReference49.java
langtools/test/tools/javac/lambda/MethodReference50.java
langtools/test/tools/javac/lambda/MethodReference50.out
langtools/test/tools/javac/lambda/MethodReference51.java
langtools/test/tools/javac/lambda/MethodReference51.out
langtools/test/tools/javac/lambda/MethodReference52.java
langtools/test/tools/javac/lambda/MethodReference52.out
langtools/test/tools/javac/lambda/MethodReference53.java
langtools/test/tools/javac/lambda/MethodReference53.out
langtools/test/tools/javac/lambda/MethodReference54.java
langtools/test/tools/javac/lambda/MethodReference54.out
langtools/test/tools/javac/lambda/MethodReferenceParserTest.java
langtools/test/tools/javac/lambda/MostSpecific01.java
langtools/test/tools/javac/lambda/MostSpecific01.out
langtools/test/tools/javac/lambda/MostSpecific02.java
langtools/test/tools/javac/lambda/MostSpecific02.out
langtools/test/tools/javac/lambda/MostSpecific03.java
langtools/test/tools/javac/lambda/MostSpecific03.out
langtools/test/tools/javac/lambda/MostSpecific04.java
langtools/test/tools/javac/lambda/MostSpecific05.java
langtools/test/tools/javac/lambda/MostSpecific06.java
langtools/test/tools/javac/lambda/MostSpecific06.out
langtools/test/tools/javac/lambda/MostSpecific07.java
langtools/test/tools/javac/lambda/MostSpecific07.out
langtools/test/tools/javac/lambda/NakedThis.java
langtools/test/tools/javac/lambda/SourceLevelTest.java
langtools/test/tools/javac/lambda/SourceLevelTest.out
langtools/test/tools/javac/lambda/TargetType01.java
langtools/test/tools/javac/lambda/TargetType02.java
langtools/test/tools/javac/lambda/TargetType03.java
langtools/test/tools/javac/lambda/TargetType04.java
langtools/test/tools/javac/lambda/TargetType04.out
langtools/test/tools/javac/lambda/TargetType05.java
langtools/test/tools/javac/lambda/TargetType06.java
langtools/test/tools/javac/lambda/TargetType06.out
langtools/test/tools/javac/lambda/TargetType07.java
langtools/test/tools/javac/lambda/TargetType08.java
langtools/test/tools/javac/lambda/TargetType10.java
langtools/test/tools/javac/lambda/TargetType10.out
langtools/test/tools/javac/lambda/TargetType11.java
langtools/test/tools/javac/lambda/TargetType11.out
langtools/test/tools/javac/lambda/TargetType12.java
langtools/test/tools/javac/lambda/TargetType13.java
langtools/test/tools/javac/lambda/TargetType13.out
langtools/test/tools/javac/lambda/TargetType14.java
langtools/test/tools/javac/lambda/TargetType14.out
langtools/test/tools/javac/lambda/TargetType15.java
langtools/test/tools/javac/lambda/TargetType16.java
langtools/test/tools/javac/lambda/TargetType16.out
langtools/test/tools/javac/lambda/TargetType17.java
langtools/test/tools/javac/lambda/TargetType17.out
langtools/test/tools/javac/lambda/TargetType18.java
langtools/test/tools/javac/lambda/TargetType19.java
langtools/test/tools/javac/lambda/TargetType19.out
langtools/test/tools/javac/lambda/TargetType20.java
langtools/test/tools/javac/lambda/TargetType20.out
langtools/test/tools/javac/lambda/TargetType21.java
langtools/test/tools/javac/lambda/TargetType21.out
langtools/test/tools/javac/lambda/TargetType22.java
langtools/test/tools/javac/lambda/TargetType22.out
langtools/test/tools/javac/lambda/TargetType23.java
langtools/test/tools/javac/lambda/TargetType23.out
langtools/test/tools/javac/lambda/TargetType24.java
langtools/test/tools/javac/lambda/TargetType24.out
langtools/test/tools/javac/lambda/TargetType25.java
langtools/test/tools/javac/lambda/TargetType26.java
langtools/test/tools/javac/lambda/TargetType26.out
langtools/test/tools/javac/lambda/TargetType27.java
langtools/test/tools/javac/lambda/TargetType27.out
langtools/test/tools/javac/lambda/TargetType28.java
langtools/test/tools/javac/lambda/TargetType28.out
langtools/test/tools/javac/lambda/TargetType29.java
langtools/test/tools/javac/lambda/TargetType30.java
langtools/test/tools/javac/lambda/TargetType31.java
langtools/test/tools/javac/lambda/TargetType32.java
langtools/test/tools/javac/lambda/TargetType33.java
langtools/test/tools/javac/lambda/TargetType33.out
langtools/test/tools/javac/lambda/TargetType34.java
langtools/test/tools/javac/lambda/TargetType35.java
langtools/test/tools/javac/lambda/TargetType36.java
langtools/test/tools/javac/lambda/TargetType37.java
langtools/test/tools/javac/lambda/TargetType38.java
langtools/test/tools/javac/lambda/TargetType38.out
langtools/test/tools/javac/lambda/TargetType39.java
langtools/test/tools/javac/lambda/TargetType39.out
langtools/test/tools/javac/lambda/TargetType40.java
langtools/test/tools/javac/lambda/TargetType40.out
langtools/test/tools/javac/lambda/TargetType41.java
langtools/test/tools/javac/lambda/TargetType41.out
langtools/test/tools/javac/lambda/TargetType42.java
langtools/test/tools/javac/lambda/TargetType43.java
langtools/test/tools/javac/lambda/TargetType43.out
langtools/test/tools/javac/lambda/TargetType44.java
langtools/test/tools/javac/lambda/TargetType44.out
langtools/test/tools/javac/lambda/TargetType45.java
langtools/test/tools/javac/lambda/TargetType45.out
langtools/test/tools/javac/lambda/TargetType46.java
langtools/test/tools/javac/lambda/TargetType46.out
langtools/test/tools/javac/lambda/TargetType47.java
langtools/test/tools/javac/lambda/TargetType48.java
langtools/test/tools/javac/lambda/TargetType49.java
langtools/test/tools/javac/lambda/TargetType49.out
langtools/test/tools/javac/lambda/TargetType50.java
langtools/test/tools/javac/lambda/TargetType50.out
langtools/test/tools/javac/lambda/TestInvokeDynamic.java
langtools/test/tools/javac/lambda/TestSelfRef.java
langtools/test/tools/javac/lambda/VoidCompatibility.java
langtools/test/tools/javac/lambda/VoidCompatibility.out
langtools/test/tools/javac/lambda/abort/Abort.java
langtools/test/tools/javac/lambda/badMemberRefBytecode/Main.java
langtools/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java
langtools/test/tools/javac/lambda/badMemberRefBytecode/Use.java
langtools/test/tools/javac/lambda/funcInterfaces/Helper.java
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java
langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out
langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.java
langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.out
langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.java
langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.out
langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.java
langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.out
langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java
langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out
langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java
langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out
langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java
langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java
langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out
langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java
langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java
langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java
langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java
langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java
langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java
langtools/test/tools/javac/lambda/lambdaExpression/SamConversion.java
langtools/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java
langtools/test/tools/javac/lambda/methodReference/BridgeMethod.java
langtools/test/tools/javac/lambda/methodReference/MethodRef1.java
langtools/test/tools/javac/lambda/methodReference/MethodRef2.java
langtools/test/tools/javac/lambda/methodReference/MethodRef3.java
langtools/test/tools/javac/lambda/methodReference/MethodRef4.java
langtools/test/tools/javac/lambda/methodReference/MethodRef5.java
langtools/test/tools/javac/lambda/methodReference/MethodRef6.java
langtools/test/tools/javac/lambda/methodReference/MethodRef7.java
langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.java
langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.out
langtools/test/tools/javac/lambda/methodReference/SamConversion.java
langtools/test/tools/javac/lambda/methodReference/SamConversionComboTest.java
langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java
langtools/test/tools/javac/lambda/speculative/A.java
langtools/test/tools/javac/lambda/speculative/DiamondFinder.java
langtools/test/tools/javac/lambda/speculative/Main.java
langtools/test/tools/javac/lambda/speculative/Main.out
langtools/test/tools/javac/lambda/typeInference/InferenceTest11.java
langtools/test/tools/javac/lambda/typeInference/InferenceTest2.java
langtools/test/tools/javac/lambda/typeInference/InferenceTest2b.java
langtools/test/tools/javac/lambda/typeInference/InferenceTest3.java
langtools/test/tools/javac/lambda/typeInference/InferenceTest4.java
langtools/test/tools/javac/lambda/typeInference/InferenceTest5.java
langtools/test/tools/javac/lambda/typeInference/InferenceTest789.java
langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java
langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out
langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java
langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out
langtools/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java
langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java	Sat Nov 17 19:01:03 2012 +0000
@@ -67,6 +67,7 @@
         if ((mask&NATIVE) != 0) flags.add(Flag.NATIVE);
         if ((mask&INTERFACE) != 0) flags.add(Flag.INTERFACE);
         if ((mask&ABSTRACT) != 0) flags.add(Flag.ABSTRACT);
+        if ((mask&DEFAULT) != 0) flags.add(Flag.DEFAULT);
         if ((mask&STRICTFP) != 0) flags.add(Flag.STRICTFP);
         if ((mask&BRIDGE) != 0) flags.add(Flag.BRIDGE);
         if ((mask&SYNTHETIC) != 0) flags.add(Flag.SYNTHETIC);
@@ -261,7 +262,7 @@
      * Flag that marks class as auxiliary, ie a non-public class following
      * the public class in a source file, that could block implicit compilation.
      */
-    public static final long AUXILIARY = 1L<<43;
+    public static final long AUXILIARY = 1L<<44;
 
     /** Modifier masks.
      */
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Sat Nov 17 19:01:03 2012 +0000
@@ -438,7 +438,8 @@
     }
 
     public Set<Modifier> getModifiers() {
-        return Flags.asModifierSet(flags());
+        long flags = flags();
+        return Flags.asModifierSet((flags & DEFAULT) != 0 ? flags & ~ABSTRACT : flags);
     }
 
     public Name getSimpleName() {
@@ -475,6 +476,7 @@
         public String toString() { return other.toString(); }
         public Symbol location() { return other.location(); }
         public Symbol location(Type site, Types types) { return other.location(site, types); }
+        public Symbol baseSymbol() { return other; }
         public Type erasure(Types types) { return other.erasure(types); }
         public Type externalType(Types types) { return other.externalType(types); }
         public boolean isLocal() { return other.isLocal(); }
@@ -1192,7 +1194,7 @@
 
             // check for an inherited implementation
             if ((flags() & ABSTRACT) != 0 ||
-                    (other.flags() & ABSTRACT) == 0 ||
+                    ((other.flags() & ABSTRACT) == 0 && (other.flags() & DEFAULT) == 0) ||
                     !other.isOverridableIn(origin) ||
                     !this.isMemberOf(origin, types))
                 return false;
@@ -1202,7 +1204,7 @@
             Type ot = types.memberType(origin.type, other);
             return
                 types.isSubSignature(mt, ot) &&
-                (!checkResult || types.resultSubtype(mt, ot, Warner.noWarnings));
+                (!checkResult || types.resultSubtype(mt, ot, types.noWarnings));
         }
 
         private boolean isOverridableIn(TypeSymbol origin) {
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Sat Nov 17 19:01:03 2012 +0000
@@ -83,6 +83,8 @@
     final Name capturedName;
     private final FunctionDescriptorLookupError functionDescriptorLookupError;
 
+    public final Warner noWarnings;
+
     // <editor-fold defaultstate="collapsed" desc="Instantiating">
     public static Types instance(Context context) {
         Types instance = context.get(typesKey);
@@ -106,6 +108,7 @@
         messages = JavacMessages.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
         functionDescriptorLookupError = new FunctionDescriptorLookupError();
+        noWarnings = new Warner(null);
     }
     // </editor-fold>
 
@@ -296,7 +299,7 @@
      * convertions to s?
      */
     public boolean isConvertible(Type t, Type s) {
-        return isConvertible(t, s, Warner.noWarnings);
+        return isConvertible(t, s, noWarnings);
     }
     // </editor-fold>
 
@@ -394,15 +397,10 @@
 
             @Override
             public boolean accepts(Symbol sym) {
-                    return sym.kind == Kinds.MTH &&
-                            (sym.flags() & ABSTRACT) != 0 &&
-                            !overridesObjectMethod(origin, sym) &&
-                            notOverridden(sym);
-            }
-
-            private boolean notOverridden(Symbol msym) {
-                Symbol impl = ((MethodSymbol)msym).implementation(origin, Types.this, false);
-                return impl == null || (impl.flags() & ABSTRACT) != 0;
+                return sym.kind == Kinds.MTH &&
+                        (sym.flags() & (ABSTRACT | DEFAULT)) == ABSTRACT &&
+                        !overridesObjectMethod(origin, sym) &&
+                        (interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0;
             }
         };
 
@@ -593,7 +591,7 @@
      * Is t an unchecked subtype of s?
      */
     public boolean isSubtypeUnchecked(Type t, Type s) {
-        return isSubtypeUnchecked(t, s, Warner.noWarnings);
+        return isSubtypeUnchecked(t, s, noWarnings);
     }
     /**
      * Is t an unchecked subtype of s?
@@ -1196,7 +1194,7 @@
 
     // <editor-fold defaultstate="collapsed" desc="isCastable">
     public boolean isCastable(Type t, Type s) {
-        return isCastable(t, s, Warner.noWarnings);
+        return isCastable(t, s, noWarnings);
     }
 
     /**
@@ -1259,7 +1257,7 @@
                     return true;
 
                 if (s.tag == TYPEVAR) {
-                    if (isCastable(t, s.getUpperBound(), Warner.noWarnings)) {
+                    if (isCastable(t, s.getUpperBound(), noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
                     } else {
@@ -1269,7 +1267,7 @@
 
                 if (t.isCompound()) {
                     Warner oldWarner = warnStack.head;
-                    warnStack.head = Warner.noWarnings;
+                    warnStack.head = noWarnings;
                     if (!visit(supertype(t), s))
                         return false;
                     for (Type intf : interfaces(t)) {
@@ -1368,7 +1366,7 @@
                 case BOT:
                     return true;
                 case TYPEVAR:
-                    if (isCastable(s, t, Warner.noWarnings)) {
+                    if (isCastable(s, t, noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
                     } else {
@@ -1396,7 +1394,7 @@
                 case TYPEVAR:
                     if (isSubtype(t, s)) {
                         return true;
-                    } else if (isCastable(t.bound, s, Warner.noWarnings)) {
+                    } else if (isCastable(t.bound, s, noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
                     } else {
@@ -1535,7 +1533,7 @@
             TypeVar tv = (TypeVar) t;
             return !isCastable(tv.bound,
                                relaxBound(s),
-                               Warner.noWarnings);
+                               noWarnings);
         }
         if (s.tag != WILDCARD)
             s = upperBound(s);
@@ -1838,7 +1836,7 @@
 
     // <editor-fold defaultstate="collapsed" desc="isAssignable">
     public boolean isAssignable(Type t, Type s) {
-        return isAssignable(t, s, Warner.noWarnings);
+        return isAssignable(t, s, noWarnings);
     }
 
     /**
@@ -2149,9 +2147,9 @@
             }
         };
 
-    public boolean isDirectSuperInterface(Type t, TypeSymbol tsym) {
-        for (Type t2 : interfaces(tsym.type)) {
-            if (isSameType(t, t2)) return true;
+    public boolean isDirectSuperInterface(TypeSymbol isym, TypeSymbol origin) {
+        for (Type i2 : interfaces(origin.type)) {
+            if (isym == i2.tsym) return true;
         }
         return false;
     }
@@ -2224,7 +2222,9 @@
      * Return list of bounds of the given type variable.
      */
     public List<Type> getBounds(TypeVar t) {
-        if (t.bound.isErroneous() || !t.bound.isCompound())
+                if (t.bound.hasTag(NONE))
+            return List.nil();
+        else if (t.bound.isErroneous() || !t.bound.isCompound())
             return List.of(t.bound);
         else if ((erasure(t).tsym.flags() & INTERFACE) == 0)
             return interfaces(t).prepend(supertype(t));
@@ -2319,10 +2319,6 @@
         return false;
     }
 
-    public boolean overridesObjectMethod(Symbol msym) {
-        return ((MethodSymbol)msym).implementation(syms.objectType.tsym, this, true) != null;
-    }
-
     // <editor-fold defaultstate="collapsed" desc="Determining method implementation in given site">
     class ImplementationCache {
 
@@ -2471,11 +2467,7 @@
 
     //where
     public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) {
-        return interfaceCandidates(site, ms, false);
-    }
-
-    public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms, boolean intfOnly) {
-        Filter<Symbol> filter = new MethodFilter(ms, site, intfOnly);
+        Filter<Symbol> filter = new MethodFilter(ms, site);
         List<MethodSymbol> candidates = List.nil();
         for (Symbol s : membersClosure(site, false).getElements(filter)) {
             if (!site.tsym.isInterface() && !s.owner.isInterface()) {
@@ -2514,17 +2506,14 @@
 
                 Symbol msym;
                 Type site;
-                boolean intfOnly;
-
-                MethodFilter(Symbol msym, Type site, boolean intfOnly) {
+
+                MethodFilter(Symbol msym, Type site) {
                     this.msym = msym;
                     this.site = site;
-                    this.intfOnly = intfOnly;
                 }
 
                 public boolean accepts(Symbol s) {
                     return s.kind == Kinds.MTH &&
-                            (!intfOnly || s.owner.isInterface()) &&
                             s.name == msym.name &&
                             s.isInheritedIn(site.tsym, Types.this) &&
                             overrideEquivalent(memberType(site, s), memberType(site, msym));
@@ -3462,11 +3451,11 @@
      */
     public boolean returnTypeSubstitutable(Type r1, Type r2) {
         if (hasSameArgs(r1, r2))
-            return resultSubtype(r1, r2, Warner.noWarnings);
+            return resultSubtype(r1, r2, noWarnings);
         else
             return covariantReturnType(r1.getReturnType(),
                                        erasure(r2.getReturnType()),
-                                       Warner.noWarnings);
+                                       noWarnings);
     }
 
     public boolean returnTypeSubstitutable(Type r1,
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Sat Nov 17 19:01:03 2012 +0000
@@ -133,7 +133,7 @@
         allowCovariantReturns = source.allowCovariantReturns();
         allowAnonOuterThis = source.allowAnonOuterThis();
         allowStringsInSwitch = source.allowStringsInSwitch();
-        allowPoly = source.allowPoly() && options.isSet("allowPoly");
+        allowPoly = source.allowPoly();
         allowLambda = source.allowLambda();
         allowDefaultMethods = source.allowDefaultMethods();
         sourceName = source.name;
@@ -179,14 +179,14 @@
      */
     boolean allowCovariantReturns;
 
+    /** Switch: support lambda expressions ?
+     */
+    boolean allowLambda;
+
     /** Switch: support default methods ?
      */
     boolean allowDefaultMethods;
 
-    /** Switch: support lambda expressions ?
-     */
-    boolean allowLambda;
-
     /** Switch: allow references to surrounding object from anonymous
      * objects during constructor call?
      */
@@ -524,6 +524,10 @@
         protected ResultInfo dup(Type newPt) {
             return new ResultInfo(pkind, newPt, checkContext);
         }
+
+        protected ResultInfo dup(CheckContext newContext) {
+            return new ResultInfo(pkind, pt, newContext);
+        }
     }
 
     class RecoveryInfo extends ResultInfo {
@@ -540,7 +544,7 @@
                 }
                 @Override
                 public void report(DiagnosticPosition pos, JCDiagnostic details) {
-                    //do nothing
+                    chk.basicHandler.report(pos, details);
                 }
             });
         }
@@ -595,8 +599,10 @@
             this.env = env;
             this.resultInfo = resultInfo;
             tree.accept(this);
-            if (tree == breakTree)
+            if (tree == breakTree &&
+                    resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
                 throw new BreakAttr(env);
+            }
             return result;
         } catch (CompletionFailure ex) {
             tree.type = syms.errType;
@@ -903,7 +909,7 @@
 
             localEnv.info.lint = lint;
 
-            if (isDefaultMethod && types.overridesObjectMethod(m)) {
+            if (isDefaultMethod && types.overridesObjectMethod(m.enclClass(), m)) {
                 log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location());
             }
 
@@ -1390,13 +1396,14 @@
 
         if (!standaloneConditional && resultInfo.pt.hasTag(VOID)) {
             //cannot get here (i.e. it means we are returning from void method - which is already an error)
+            resultInfo.checkContext.report(tree, diags.fragment("conditional.target.cant.be.void"));
             result = tree.type = types.createErrorType(resultInfo.pt);
             return;
         }
 
         ResultInfo condInfo = standaloneConditional ?
                 unknownExprInfo :
-                new ResultInfo(VAL, pt(), new Check.NestedCheckContext(resultInfo.checkContext) {
+                resultInfo.dup(new Check.NestedCheckContext(resultInfo.checkContext) {
                     //this will use enclosing check context to check compatibility of
                     //subexpression against target type; if we are in a method check context,
                     //depending on whether boxing is allowed, we could have incompatibilities
@@ -1419,11 +1426,11 @@
         result = check(tree, owntype, VAL, resultInfo);
     }
     //where
-        @SuppressWarnings("fallthrough")
         private boolean isBooleanOrNumeric(Env<AttrContext> env, JCExpression tree) {
             switch (tree.getTag()) {
                 case LITERAL: return ((JCLiteral)tree).typetag.isSubRangeOf(DOUBLE) ||
-                              ((JCLiteral)tree).typetag == BOOLEAN;
+                              ((JCLiteral)tree).typetag == BOOLEAN ||
+                              ((JCLiteral)tree).typetag == BOT;
                 case LAMBDA: case REFERENCE: return false;
                 case PARENS: return isBooleanOrNumeric(env, ((JCParens)tree).expr);
                 case CONDEXPR:
@@ -1612,19 +1619,23 @@
             // it conforms to result type of enclosing method.
             if (tree.expr != null) {
                 if (env.info.returnResult.pt.hasTag(VOID)) {
-                    log.error(tree.expr.pos(),
-                              "cant.ret.val.from.meth.decl.void");
+                    env.info.returnResult.checkContext.report(tree.expr.pos(),
+                              diags.fragment("unexpected.ret.val"));
                 }
                 attribTree(tree.expr, env, env.info.returnResult);
             } else if (!env.info.returnResult.pt.hasTag(VOID)) {
-                log.error(tree.pos(), "missing.ret.val");
+                env.info.returnResult.checkContext.report(tree.pos(),
+                              diags.fragment("missing.ret.val"));
             }
         }
         result = null;
     }
 
     public void visitThrow(JCThrow tree) {
-        attribExpr(tree.expr, env, syms.throwableType);
+        Type owntype = attribExpr(tree.expr, env, allowPoly ? Type.noType : syms.throwableType);
+        if (allowPoly) {
+            chk.checkType(tree, owntype, syms.throwableType);
+        }
         result = null;
     }
 
@@ -2068,7 +2079,7 @@
                             resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt());
                     Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type;
                     if (!inferred.isErroneous() &&
-                        types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), Warner.noWarnings)) {
+                        types.isAssignable(inferred, pt().hasTag(NONE) ? syms.objectType : pt(), types.noWarnings)) {
                         String key = types.isSameType(clazztype, inferred) ?
                             "diamond.redundant.args" :
                             "diamond.redundant.args.1";
@@ -2172,7 +2183,7 @@
         }
         //create an environment for attribution of the lambda expression
         final Env<AttrContext> localEnv = lambdaEnv(that, env);
-        boolean needsRecovery = resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext ||
+        boolean needsRecovery =
                 resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK;
         try {
             List<Type> explicitParamTypes = null;
@@ -2182,10 +2193,16 @@
                 explicitParamTypes = TreeInfo.types(that.params);
             }
 
-            Type target = infer.instantiateFunctionalInterface(that, pt(), explicitParamTypes, resultInfo.checkContext);
-            Type lambdaType = (target == Type.recoveryType) ?
-                    fallbackDescriptorType(that) :
-                    types.findDescriptorType(target);
+            Type target;
+            Type lambdaType;
+            if (pt() != Type.recoveryType) {
+                target = infer.instantiateFunctionalInterface(that, pt(), explicitParamTypes, resultInfo.checkContext);
+                lambdaType = types.findDescriptorType(target);
+                chk.checkFunctionalInterface(that, target);
+            } else {
+                target = Type.recoveryType;
+                lambdaType = fallbackDescriptorType(that);
+            }
 
             if (!TreeInfo.isExplicitLambda(that)) {
                 //add param type info in the AST
@@ -2250,7 +2267,7 @@
             checkLambdaCompatible(that, lambdaType, resultInfo.checkContext, isSpeculativeRound);
 
             if (!isSpeculativeRound) {
-                checkAccessibleFunctionalDescriptor(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType);
+                checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType, target);
             }
             result = check(that, target, VAL, resultInfo);
         } catch (Types.FunctionDescriptorLookupError ex) {
@@ -2285,17 +2302,22 @@
             return null;
         }
 
-        private void checkAccessibleFunctionalDescriptor(final DiagnosticPosition pos,
-                final Env<AttrContext> env, final InferenceContext inferenceContext, final Type desc) {
-            if (inferenceContext.free(desc)) {
-                inferenceContext.addFreeTypeListener(List.of(desc), new FreeTypeListener() {
+        private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env, final InferenceContext inferenceContext, final Type... ts) {
+            checkAccessibleTypes(pos, env, inferenceContext, List.from(ts));
+        }
+
+        private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env, final InferenceContext inferenceContext, final List<Type> ts) {
+            if (inferenceContext.free(ts)) {
+                inferenceContext.addFreeTypeListener(ts, new FreeTypeListener() {
                     @Override
                     public void typesInferred(InferenceContext inferenceContext) {
-                        checkAccessibleFunctionalDescriptor(pos, env, inferenceContext, inferenceContext.asInstType(desc, types));
+                        checkAccessibleTypes(pos, env, inferenceContext, inferenceContext.asInstTypes(ts, types));
                     }
                 });
             } else {
-                chk.checkAccessibleFunctionalDescriptor(pos, env, desc);
+                for (Type t : ts) {
+                    rs.checkAccessibleType(env, t);
+                }
             }
         }
 
@@ -2411,15 +2433,20 @@
                 typeargtypes = attribTypes(that.typeargs, localEnv);
             }
 
-            Type target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext);
-            Type desc = (target == Type.recoveryType) ?
-                    fallbackDescriptorType(that) :
-                    types.findDescriptorType(target);
+            Type target;
+            Type desc;
+            if (pt() != Type.recoveryType) {
+                target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext);
+                desc = types.findDescriptorType(target);
+                chk.checkFunctionalInterface(that, target);
+            } else {
+                target = Type.recoveryType;
+                desc = fallbackDescriptorType(that);
+            }
 
             List<Type> argtypes = desc.getParameterTypes();
 
             boolean allowBoxing =
-                    resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext ||
                     resultInfo.checkContext.deferredAttrContext().phase.isBoxingRequired();
             Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = rs.resolveMemberReference(that.pos(), localEnv, that,
                     that.expr.type, that.name, argtypes, typeargtypes, allowBoxing);
@@ -2455,18 +2482,25 @@
                 JCDiagnostic diag = diags.create(diagKind, log.currentSource(), that,
                         "invalid.mref", Kinds.kindName(that.getMode()), detailsDiag);
 
-                if (targetError) {
-                    resultInfo.checkContext.report(that, diag);
+                if (targetError && target == Type.recoveryType) {
+                    //a target error doesn't make sense during recovery stage
+                    //as we don't know what actual parameter types are
+                    result = that.type = target;
+                    return;
                 } else {
-                    log.report(diag);
+                    if (targetError) {
+                        resultInfo.checkContext.report(that, diag);
+                    } else {
+                        log.report(diag);
+                    }
+                    result = that.type = types.createErrorType(target);
+                    return;
                 }
-                result = that.type = types.createErrorType(target);
-                return;
             }
 
             if (desc.getReturnType() == Type.recoveryType) {
                 // stop here
-                result = that.type = types.createErrorType(target);
+                result = that.type = target;
                 return;
             }
 
@@ -2492,7 +2526,7 @@
                     resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
             checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound);
             if (!isSpeculativeRound) {
-                checkAccessibleFunctionalDescriptor(that, localEnv, resultInfo.checkContext.inferenceContext(), desc);
+                checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, target);
             }
             result = check(that, target, VAL, resultInfo);
         } catch (Types.FunctionDescriptorLookupError ex) {
@@ -2526,7 +2560,7 @@
 
         if (!returnType.hasTag(VOID) && !resType.hasTag(VOID)) {
             if (resType.isErroneous() ||
-                    new LambdaReturnContext(checkContext).compatible(resType, returnType, Warner.noWarnings)) {
+                    new LambdaReturnContext(checkContext).compatible(resType, returnType, types.noWarnings)) {
                 incompatibleReturnType = null;
             }
         }
@@ -3039,15 +3073,52 @@
                      Symbol sym,
                      Env<AttrContext> env,
                      ResultInfo resultInfo) {
-            Type pt = resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD) ?
-                    resultInfo.pt.map(deferredAttr.new DeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase)) :
-                    resultInfo.pt;
-
-            DeferredAttr.DeferredTypeMap recoveryMap =
-                    deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase);
-
+            return (resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD)) ?
+                    checkMethodId(tree, site, sym, env, resultInfo) :
+                    checkIdInternal(tree, site, sym, resultInfo.pt, env, resultInfo);
+        }
+
+        Type checkMethodId(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            boolean isPolymorhicSignature =
+                sym.kind == MTH && ((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types);
+            return isPolymorhicSignature ?
+                    checkSigPolyMethodId(tree, site, sym, env, resultInfo) :
+                    checkMethodIdInternal(tree, site, sym, env, resultInfo);
+        }
+
+        Type checkSigPolyMethodId(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            //recover original symbol for signature polymorphic methods
+            checkMethodIdInternal(tree, site, sym.baseSymbol(), env, resultInfo);
+            env.info.pendingResolutionPhase = Resolve.MethodResolutionPhase.BASIC;
+            return sym.type;
+        }
+
+        Type checkMethodIdInternal(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            Type pt = resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase));
+            Type owntype = checkIdInternal(tree, site, sym, pt, env, resultInfo);
+            resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase));
+            return owntype;
+        }
+
+        Type checkIdInternal(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Type pt,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
             if (pt.isErroneous()) {
-                Type.map(resultInfo.pt.getParameterTypes(), recoveryMap);
                 return types.createErrorType(site);
             }
             Type owntype; // The computed type of this identifier occurrence.
@@ -3132,7 +3203,6 @@
                 break;
             }
             case PCK: case ERR:
-                Type.map(resultInfo.pt.getParameterTypes(), recoveryMap);
                 owntype = sym.type;
                 break;
             default:
@@ -3288,21 +3358,21 @@
             }
         }
 
-        if (env.info.defaultSuperCallSite != null &&
-                !types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true).contains(sym)) {
-            Symbol ovSym = null;
-            for (MethodSymbol msym : types.interfaceCandidates(env.enclClass.type, (MethodSymbol)sym, true)) {
-                if (msym.overrides(sym, msym.enclClass(), types, true)) {
-                    for (Type i : types.interfaces(env.enclClass.type)) {
-                        if (i.tsym.isSubClass(msym.owner, types)) {
-                            ovSym = i.tsym;
-                            break;
-                        }
-                    }
+        if (env.info.defaultSuperCallSite != null) {
+            for (Type sup : types.interfaces(env.enclClass.type).prepend(types.supertype((env.enclClass.type)))) {
+                if (!sup.tsym.isSubClass(sym.enclClass(), types) ||
+                        types.isSameType(sup, env.info.defaultSuperCallSite)) continue;
+                List<MethodSymbol> icand_sup =
+                        types.interfaceCandidates(sup, (MethodSymbol)sym);
+                if (icand_sup.nonEmpty() &&
+                        icand_sup.head != sym &&
+                        icand_sup.head.overrides(sym, icand_sup.head.enclClass(), types, true)) {
+                    log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite,
+                        diags.fragment("overridden.default", sym, sup));
+                    break;
                 }
             }
-            log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite,
-                    diags.fragment("overridden.default", sym, ovSym));
+            env.info.defaultSuperCallSite = null;
         }
 
         // Compute the identifier's instantiated type.
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Sat Nov 17 19:01:03 2012 +0000
@@ -120,8 +120,7 @@
         allowCovariantReturns = source.allowCovariantReturns();
         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
         allowDefaultMethods = source.allowDefaultMethods();
-        allowStrictMethodClashCheck = source.allowStrictMethodClashCheck() &&
-                options.isSet("strictMethodClashCheck"); //pre-lambda guard
+        allowStrictMethodClashCheck = source.allowStrictMethodClashCheck();
         complexInference = options.isSet("complexinference");
         warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
         suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
@@ -451,8 +450,6 @@
         public Infer.InferenceContext inferenceContext();
 
         public DeferredAttr.DeferredAttrContext deferredAttrContext();
-
-        public boolean allowBoxing();
     }
 
     /**
@@ -487,10 +484,6 @@
         public DeferredAttrContext deferredAttrContext() {
             return enclosingContext.deferredAttrContext();
         }
-
-        public boolean allowBoxing() {
-            return enclosingContext.allowBoxing();
-        }
     }
 
     /**
@@ -515,10 +508,6 @@
         public DeferredAttrContext deferredAttrContext() {
             return deferredAttr.emptyDeferredAttrContext;
         }
-
-        public boolean allowBoxing() {
-            return true;
-        }
     };
 
     /** Check that a given type is assignable to a given proto-type.
@@ -625,7 +614,7 @@
              a = types.upperBound(a);
              return types.isSubtype(a, bound);
          } else if (a.isExtendsBound()) {
-             return types.isCastable(bound, types.upperBound(a), Warner.noWarnings);
+             return types.isCastable(bound, types.upperBound(a), types.noWarnings);
          } else if (a.isSuperBound()) {
              return !types.notSoftSubtype(types.lowerBound(a), bound);
          }
@@ -909,19 +898,21 @@
                                   "unchecked.generic.array.creation",
                                   argtype);
             }
-            Type elemtype = types.elemtype(argtype);
-            switch (tree.getTag()) {
-                case APPLY:
-                    ((JCMethodInvocation) tree).varargsElement = elemtype;
-                    break;
-                case NEWCLASS:
-                    ((JCNewClass) tree).varargsElement = elemtype;
-                    break;
-                case REFERENCE:
-                    ((JCMemberReference) tree).varargsElement = elemtype;
-                    break;
-                default:
-                    throw new AssertionError(""+tree);
+            if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) {
+                Type elemtype = types.elemtype(argtype);
+                switch (tree.getTag()) {
+                    case APPLY:
+                        ((JCMethodInvocation) tree).varargsElement = elemtype;
+                        break;
+                    case NEWCLASS:
+                        ((JCNewClass) tree).varargsElement = elemtype;
+                        break;
+                    case REFERENCE:
+                        ((JCMemberReference) tree).varargsElement = elemtype;
+                        break;
+                    default:
+                        throw new AssertionError(""+tree);
+                }
             }
          }
          return owntype;
@@ -937,65 +928,6 @@
                 return;
         }
 
-        void checkAccessibleFunctionalDescriptor(DiagnosticPosition pos, Env<AttrContext> env, Type desc) {
-            AccessChecker accessChecker = new AccessChecker(env);
-            //check args accessibility (only if implicit parameter types)
-            for (Type arg : desc.getParameterTypes()) {
-                if (!accessChecker.visit(arg)) {
-                    log.error(pos, "cant.access.arg.type.in.functional.desc", arg);
-                    return;
-                }
-            }
-            //check return type accessibility
-            if (!accessChecker.visit(desc.getReturnType())) {
-                log.error(pos, "cant.access.return.in.functional.desc", desc.getReturnType());
-                return;
-            }
-            //check thrown types accessibility
-            for (Type thrown : desc.getThrownTypes()) {
-                if (!accessChecker.visit(thrown)) {
-                    log.error(pos, "cant.access.thrown.in.functional.desc", thrown);
-                    return;
-                }
-            }
-        }
-
-        class AccessChecker extends Types.UnaryVisitor<Boolean> {
-
-            Env<AttrContext> env;
-
-            AccessChecker(Env<AttrContext> env) {
-                this.env = env;
-            }
-
-            Boolean visit(List<Type> ts) {
-                for (Type t : ts) {
-                    if (!visit(t))
-                        return false;
-                }
-                return true;
-            }
-
-            public Boolean visitType(Type t, Void s) {
-                return true;
-            }
-
-            @Override
-            public Boolean visitArrayType(ArrayType t, Void s) {
-                return visit(t.elemtype);
-            }
-
-            @Override
-            public Boolean visitClassType(ClassType t, Void s) {
-                return rs.isAccessible(env, t, true) &&
-                        visit(t.getTypeArguments());
-            }
-
-            @Override
-            public Boolean visitWildcardType(WildcardType t, Void s) {
-                return visit(t.type);
-            }
-        };
     /**
      * Check that type 't' is a valid instantiation of a generic class
      * (see JLS 4.5)
@@ -1919,8 +1851,8 @@
                         types.isSameType(rt1, rt2) ||
                         !rt1.isPrimitiveOrVoid() &&
                         !rt2.isPrimitiveOrVoid() &&
-                        (types.covariantReturnType(rt1, rt2, Warner.noWarnings) ||
-                         types.covariantReturnType(rt2, rt1, Warner.noWarnings)) ||
+                        (types.covariantReturnType(rt1, rt2, types.noWarnings) ||
+                         types.covariantReturnType(rt2, rt1, types.noWarnings)) ||
                          checkCommonOverriderIn(s1,s2,site);
                     if (!compat) {
                         log.error(pos, "types.incompatible.diff.ret",
@@ -1965,8 +1897,8 @@
                     boolean compat =
                         !rt13.isPrimitiveOrVoid() &&
                         !rt23.isPrimitiveOrVoid() &&
-                        (types.covariantReturnType(rt13, rt1, Warner.noWarnings) &&
-                         types.covariantReturnType(rt23, rt2, Warner.noWarnings));
+                        (types.covariantReturnType(rt13, rt1, types.noWarnings) &&
+                         types.covariantReturnType(rt23, rt2, types.noWarnings));
                     if (compat)
                         return true;
                 }
@@ -2280,19 +2212,33 @@
         c.flags_field |= ACYCLIC;
     }
 
+    /**
+     * Check that functional interface methods would make sense when seen
+     * from the perspective of the implementing class
+     */
+    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.supertype_field = syms.objectType;
+        c.tsym = csym;
+        csym.members_field = new Scope(csym);
+        csym.completer = null;
+        checkImplementations(tree, csym, csym);
+    }
+
     /** Check that all methods which implement some
      *  method conform to the method they implement.
      *  @param tree         The class definition whose members are checked.
      */
     void checkImplementations(JCClassDecl tree) {
-        checkImplementations(tree, tree.sym);
+        checkImplementations(tree, tree.sym, tree.sym);
     }
 //where
         /** Check that all methods which implement some
          *  method in `ic' conform to the method they implement.
          */
-        void checkImplementations(JCClassDecl tree, ClassSymbol ic) {
-            ClassSymbol origin = tree.sym;
+        void checkImplementations(JCTree tree, ClassSymbol origin, ClassSymbol ic) {
             for (List<Type> l = types.closure(ic.type); l.nonEmpty(); l = l.tail) {
                 ClassSymbol lc = (ClassSymbol)l.head.tsym;
                 if ((allowGenerics || origin != lc) && (lc.flags() & ABSTRACT) != 0) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Sat Nov 17 19:01:03 2012 +0000
@@ -38,14 +38,13 @@
 import javax.tools.JavaFileObject;
 
 import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Queue;
 import java.util.Set;
 import java.util.WeakHashMap;
 
-import static com.sun.tools.javac.code.TypeTag.DEFERRED;
-import static com.sun.tools.javac.code.TypeTag.NONE;
+import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /**
@@ -137,19 +136,6 @@
             }
 
             /**
-             * Clone a speculative cache entry as a fresh entry associated
-             * with a new method (this maybe required to fixup speculative cache
-             * misses after Resolve.access())
-             */
-            void dupAllTo(Symbol from, Symbol to) {
-                Assert.check(cache.get(to) == null);
-                List<Entry> entries = cache.get(from);
-                if (entries != null) {
-                    cache.put(to, entries);
-                }
-            }
-
-            /**
              * Retrieve a speculative cache entry corresponding to given symbol
              * and resolution phase
              */
@@ -194,7 +180,7 @@
             DeferredAttrContext deferredAttrContext =
                     resultInfo.checkContext.deferredAttrContext();
             Assert.check(deferredAttrContext != emptyDeferredAttrContext);
-            List<Type> stuckVars = stuckVars(tree, resultInfo);
+            List<Type> stuckVars = stuckVars(tree, env, resultInfo);
             if (stuckVars.nonEmpty()) {
                 deferredAttrContext.addDeferredAttrNode(this, resultInfo, stuckVars);
                 return Type.noType;
@@ -275,6 +261,10 @@
             @Override
             public void visitClassDef(JCClassDecl tree) {
                 ClassSymbol csym = tree.sym;
+                //if something went wrong during method applicability check
+                //it is possible that nested expressions inside argument expression
+                //are left unchecked - in such cases there's nothing to clean up.
+                if (csym == null) return;
                 enter.typeEnvs.remove(csym);
                 chk.compiled.remove(csym.flatname);
                 syms.classes.remove(csym.flatname);
@@ -333,7 +323,7 @@
          */
         void complete() {
             while (!deferredAttrNodes.isEmpty()) {
-                Set<Type> stuckVars = new HashSet<Type>();
+                Set<Type> stuckVars = new LinkedHashSet<Type>();
                 boolean progress = false;
                 //scan a defensive copy of the node list - this is because a deferred
                 //attribution round can add new nodes to the list
@@ -407,7 +397,7 @@
 
     /** an empty deferred attribution context - all methods throw exceptions */
     final DeferredAttrContext emptyDeferredAttrContext =
-            new DeferredAttrContext(null, null, null, null) {
+            new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, null) {
                 @Override
                 void addDeferredAttrNode(DeferredType dt, ResultInfo ri, List<Type> stuckVars) {
                     Assert.error("Empty deferred context!");
@@ -471,13 +461,13 @@
     public class RecoveryDeferredTypeMap extends DeferredTypeMap {
 
         public RecoveryDeferredTypeMap(AttrMode mode, Symbol msym, MethodResolutionPhase phase) {
-            super(mode, msym, phase);
+            super(mode, msym, phase != null ? phase : MethodResolutionPhase.BOX);
         }
 
         @Override
         protected Type typeOf(DeferredType dt) {
             Type owntype = super.typeOf(dt);
-            return owntype.hasTag(NONE) ?
+            return owntype == Type.noType ?
                         recover(dt) : owntype;
         }
 
@@ -495,16 +485,7 @@
          */
         private Type recover(DeferredType dt) {
             dt.check(attr.new RecoveryInfo(deferredAttrContext));
-            switch (TreeInfo.skipParens(dt.tree).getTag()) {
-                case LAMBDA:
-                case REFERENCE:
-                case CONDEXPR:
-                    //propagate those deferred types to the
-                    //diagnostic formatter
-                    return dt;
-                default:
-                    return super.apply(dt);
-            }
+            return super.apply(dt);
         }
     }
 
@@ -513,11 +494,11 @@
      * an AST node can be type-checked
      */
     @SuppressWarnings("fallthrough")
-    List<Type> stuckVars(JCTree tree, ResultInfo resultInfo) {
-        if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
+    List<Type> stuckVars(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
+                if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
             return List.nil();
         } else {
-            StuckChecker sc = new StuckChecker(resultInfo);
+            StuckChecker sc = new StuckChecker(resultInfo, env);
             sc.scan(tree);
             return List.from(sc.stuckVars);
         }
@@ -534,7 +515,8 @@
         Type pt;
         Filter<JCTree> treeFilter;
         Infer.InferenceContext inferenceContext;
-        Set<Type> stuckVars = new HashSet<Type>();
+        Set<Type> stuckVars = new LinkedHashSet<Type>();
+        Env<AttrContext> env;
 
         final Filter<JCTree> argsFilter = new Filter<JCTree>() {
             public boolean accepts(JCTree t) {
@@ -563,10 +545,11 @@
             }
         };
 
-        StuckChecker(ResultInfo resultInfo) {
+        StuckChecker(ResultInfo resultInfo, Env<AttrContext> env) {
             this.pt = resultInfo.pt;
             this.inferenceContext = resultInfo.checkContext.inferenceContext();
             this.treeFilter = argsFilter;
+            this.env = env;
         }
 
         @Override
@@ -616,6 +599,7 @@
             if (!types.isFunctionalInterface(pt.tsym)) {
                 return;
             }
+
             Type descType = types.findDescriptorType(pt);
             List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
             stuckVars.addAll(freeArgVars);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Sat Nov 17 19:01:03 2012 +0000
@@ -272,9 +272,7 @@
         Source source = Source.instance(context);
         allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis();
         allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis();
-        Options options = Options.instance(context);
-        allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses() &&
-                options.isSet("allowEffectivelyFinalInInnerClasses"); //pre-lambda guard
+        allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses();
     }
 
     /**
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Sat Nov 17 19:01:03 2012 +0000
@@ -501,10 +501,10 @@
                 }
                 for (Type t : funcInterfaceContext.undetvars) {
                     UndetVar uv = (UndetVar)t;
-                    minimizeInst(uv, Warner.noWarnings);
+                    minimizeInst(uv, types.noWarnings);
                     if (uv.inst == null &&
                             Type.filter(uv.getBounds(InferenceBound.UPPER), boundFilter).nonEmpty()) {
-                        maximizeInst(uv, Warner.noWarnings);
+                        maximizeInst(uv, types.noWarnings);
                     }
                 }
 
@@ -801,7 +801,7 @@
             for (Type t : varsToSolve) {
                 UndetVar uv = (UndetVar)asFree(t, types);
                 if (uv.inst == null) {
-                    infer.minimizeInst(uv, Warner.noWarnings);
+                    infer.minimizeInst(uv, types.noWarnings);
                     if (uv.inst != null) {
                         progress = true;
                     }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Sat Nov 17 19:01:03 2012 +0000
@@ -682,7 +682,7 @@
     /** Look up a method in a given scope.
      */
     private MethodSymbol lookupMethod(DiagnosticPosition pos, Name name, Type qual, List<Type> args) {
-        return rs.resolveInternalMethod(pos, attrEnv, qual, name, args, null);
+        return rs.resolveInternalMethod(pos, attrEnv, qual, name, args, List.<Type>nil());
     }
 
     /** Look up a constructor.
@@ -3636,13 +3636,13 @@
         boolean qualifiedSuperAccess =
             tree.selected.hasTag(SELECT) &&
             TreeInfo.name(tree.selected) == names._super &&
-            !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type, currentClass);
+            !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type.tsym, currentClass);
         tree.selected = translate(tree.selected);
         if (tree.name == names._class) {
             result = classOf(tree.selected);
         }
         else if (tree.name == names._super &&
-                types.isDirectSuperInterface(tree.selected.type, currentClass)) {
+                types.isDirectSuperInterface(tree.selected.type.tsym, currentClass)) {
             //default super call!! Not a classic qualified super call
             TypeSymbol supSym = tree.selected.type.tsym;
             Assert.checkNonNull(types.asSuper(currentClass.type, supSym));
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Sat Nov 17 19:01:03 2012 +0000
@@ -427,6 +427,60 @@
             return c != null;
         }
 
+    /**
+     * Performs a recursive scan of a type looking for accessibility problems
+     * from current attribution environment
+     */
+    void checkAccessibleType(Env<AttrContext> env, Type t) {
+        accessibilityChecker.visit(t, env);
+    }
+
+    /**
+     * Accessibility type-visitor
+     */
+    Types.SimpleVisitor<Void, Env<AttrContext>> accessibilityChecker =
+            new Types.SimpleVisitor<Void, Env<AttrContext>>() {
+
+        void visit(List<Type> ts, Env<AttrContext> env) {
+            for (Type t : ts) {
+                visit(t, env);
+            }
+        }
+
+        public Void visitType(Type t, Env<AttrContext> env) {
+            return null;
+        }
+
+        @Override
+        public Void visitArrayType(ArrayType t, Env<AttrContext> env) {
+            visit(t.elemtype, env);
+            return null;
+        }
+
+        @Override
+        public Void visitClassType(ClassType t, Env<AttrContext> env) {
+            visit(t.getTypeArguments(), env);
+            if (!isAccessible(env, t, true)) {
+                accessBase(new AccessError(t.tsym), env.tree.pos(), env.enclClass.sym, t, t.tsym.name, true);
+            }
+            return null;
+        }
+
+        @Override
+        public Void visitWildcardType(WildcardType t, Env<AttrContext> env) {
+            visit(t.type, env);
+            return null;
+        }
+
+        @Override
+        public Void visitMethodType(MethodType t, Env<AttrContext> env) {
+            visit(t.getParameterTypes(), env);
+            visit(t.getReturnType(), env);
+            visit(t.getThrownTypes(), env);
+            return null;
+        }
+    };
+
     /** Try to instantiate the type of a method so that it fits
      *  given type arguments and argument types. If succesful, return
      *  the method's instantiated type, else return null.
@@ -750,10 +804,6 @@
         public boolean compatible(Type found, Type req, Warner warn) {
             return types.isSubtypeUnchecked(found, inferenceContext.asFree(req, types), warn);
         }
-
-        public boolean allowBoxing() {
-            return false;
-        }
     }
 
     /**
@@ -770,10 +820,6 @@
         public boolean compatible(Type found, Type req, Warner warn) {
             return types.isConvertible(found, inferenceContext.asFree(req, types), warn);
         }
-
-        public boolean allowBoxing() {
-            return true;
-        }
     }
 
     /**
@@ -792,7 +838,7 @@
 
         DeferredAttr.DeferredAttrContext deferredAttrContext;
 
-        public MethodResultInfo(Type pt, MethodCheckContext checkContext, DeferredAttr.DeferredAttrContext deferredAttrContext) {
+        public MethodResultInfo(Type pt, CheckContext checkContext, DeferredAttr.DeferredAttrContext deferredAttrContext) {
             attr.super(VAL, pt, checkContext);
             this.deferredAttrContext = deferredAttrContext;
         }
@@ -809,7 +855,12 @@
 
         @Override
         protected MethodResultInfo dup(Type newPt) {
-            return new MethodResultInfo(newPt, (MethodCheckContext)checkContext, deferredAttrContext);
+            return new MethodResultInfo(newPt, checkContext, deferredAttrContext);
+        }
+
+        @Override
+        protected ResultInfo dup(CheckContext newContext) {
+            return new MethodResultInfo(pt, newContext, deferredAttrContext);
         }
     }
 
@@ -1020,7 +1071,7 @@
         Assert.check(sym.kind < AMBIGUOUS);
         try {
             Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
-                               allowBoxing, useVarargs, Warner.noWarnings);
+                               allowBoxing, useVarargs, types.noWarnings);
             if (!operator)
                 currentResolutionContext.addApplicableCandidate(sym, mt);
         } catch (InapplicableMethodException ex) {
@@ -1921,28 +1972,31 @@
                         (typeargtypes == null || !Type.isErroneous(typeargtypes));
         }
         public List<Type> getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name name, List<Type> argtypes) {
-            if (syms.operatorNames.contains(name)) {
-                return argtypes;
-            } else {
-                Symbol msym = errSym.kind == WRONG_MTH ?
-                        ((InapplicableSymbolError)errSym).errCandidate().sym : accessedSym;
-
-                List<Type> argtypes2 = Type.map(argtypes,
-                        deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, msym, currentResolutionContext.step));
-
-                if (msym != accessedSym) {
-                    //fixup deferred type caches - this 'hack' is required because the symbol
-                    //returned by InapplicableSymbolError.access() will hide the candidate
-                    //method symbol that can be used for lookups in the speculative cache,
-                    //causing problems in Attr.checkId()
-                    for (Type t : argtypes) {
-                        if (t.hasTag(DEFERRED)) {
-                            DeferredType dt = (DeferredType)t;
-                            dt.speculativeCache.dupAllTo(msym, accessedSym);
-                        }
+            return (syms.operatorNames.contains(name)) ?
+                    argtypes :
+                    Type.map(argtypes, new ResolveDeferredRecoveryMap(accessedSym));
+        }
+
+        class ResolveDeferredRecoveryMap extends DeferredAttr.RecoveryDeferredTypeMap {
+
+            public ResolveDeferredRecoveryMap(Symbol msym) {
+                deferredAttr.super(AttrMode.SPECULATIVE, msym, currentResolutionContext.step);
+            }
+
+            @Override
+            protected Type typeOf(DeferredType dt) {
+                Type res = super.typeOf(dt);
+                if (!res.isErroneous()) {
+                    switch (TreeInfo.skipParens(dt.tree).getTag()) {
+                        case LAMBDA:
+                        case REFERENCE:
+                            return dt;
+                        case CONDEXPR:
+                            return res == Type.recoveryType ?
+                                    dt : res;
                     }
                 }
-                return argtypes2;
+                return res;
             }
         }
     };
@@ -2069,7 +2123,6 @@
                 } else if (allowMethodHandles) {
                     MethodSymbol msym = (MethodSymbol)sym;
                     if (msym.isSignaturePolymorphic(types)) {
-                        env.info.pendingResolutionPhase = BASIC;
                         return findPolymorphicSignatureInstance(env, sym, argtypes);
                     }
                 }
@@ -2086,7 +2139,7 @@
      *  @param argtypes  The required argument types
      */
     Symbol findPolymorphicSignatureInstance(Env<AttrContext> env,
-                                            Symbol spMethod,
+                                            final Symbol spMethod,
                                             List<Type> argtypes) {
         Type mtype = infer.instantiatePolymorphicSignatureInstance(env,
                 (MethodSymbol)spMethod, currentResolutionContext, argtypes);
@@ -2098,7 +2151,12 @@
 
         // create the desired method
         long flags = ABSTRACT | HYPOTHETICAL | spMethod.flags() & Flags.AccessFlags;
-        Symbol msym = new MethodSymbol(flags, spMethod.name, mtype, spMethod.owner);
+        Symbol msym = new MethodSymbol(flags, spMethod.name, mtype, spMethod.owner) {
+            @Override
+            public Symbol baseSymbol() {
+                return spMethod;
+            }
+        };
         polymorphicSignatureScope.enter(msym);
         return msym;
     }
@@ -2707,7 +2765,7 @@
         }
         if (allowDefaultMethods && c.isInterface() &&
                 name == names._super && !isStatic(env) &&
-                types.isDirectSuperInterface(c.type, env.enclClass.sym)) {
+                types.isDirectSuperInterface(c, env.enclClass.sym)) {
             //this might be a default super call if one of the superinterfaces is 'c'
             for (Type t : pruneInterfaces(env.enclClass.type)) {
                 if (t.tsym == c) {
@@ -3150,7 +3208,7 @@
                         "cant.apply.symbols",
                         name == names.init ? KindName.CONSTRUCTOR : absentKind(kind),
                         name == names.init ? site.tsym.name : name,
-                        argtypes);
+                        methodArguments(argtypes));
                 return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site));
             } else {
                 return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos,
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Sat Nov 17 19:01:03 2012 +0000
@@ -133,7 +133,7 @@
     JCExpression coerce(JCExpression tree, Type target) {
         Type btarget = target.baseType();
         if (tree.type.isPrimitive() == target.isPrimitive()) {
-            return types.isAssignable(tree.type, btarget, Warner.noWarnings)
+            return types.isAssignable(tree.type, btarget, types.noWarnings)
                 ? tree
                 : cast(tree, btarget);
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Sat Nov 17 19:01:03 2012 +0000
@@ -941,18 +941,6 @@
 
             new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) {
                 protected void read(Symbol sym, int attrLen) {
-                    if (currentOwner.isInterface() &&
-                            (sym.flags_field & ABSTRACT) == 0 && !name.equals(names.clinit)) {
-                        if (majorVersion > Target.JDK1_8.majorVersion ||
-                                //todo replace with Target.Version when available
-                                (majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) {
-                            currentOwner.flags_field |= DEFAULT;
-                            sym.flags_field |= DEFAULT | ABSTRACT;
-                        } else {
-                            //protect against ill-formed classfiles
-                            throw new CompletionFailure(currentOwner, "default method found in pre JDK 8 classfile");
-                        }
-                    }
                     if (readAllOfClassFile || saveParameterNames)
                         ((MethodSymbol)sym).code = readCode(sym);
                     else
@@ -1753,6 +1741,17 @@
         long flags = adjustMethodFlags(nextChar());
         Name name = readName(nextChar());
         Type type = readType(nextChar());
+        if (currentOwner.isInterface() &&
+                (flags & ABSTRACT) == 0 && !name.equals(names.clinit)) {
+            if (majorVersion > Target.JDK1_8.majorVersion ||
+                    (majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) {
+                currentOwner.flags_field |= DEFAULT;
+                flags |= DEFAULT | ABSTRACT;
+            } else {
+                //protect against ill-formed classfiles
+                throw new CompletionFailure(currentOwner, "default method found in pre JDK 8 classfile");
+            }
+        }
         if (name == names.init && currentOwner.hasOuterInstance()) {
             // Sometimes anonymous classes don't have an outer
             // instance, however, there is no reliable way to tell so
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java	Sat Nov 17 19:01:03 2012 +0000
@@ -95,10 +95,7 @@
      *  package.  Return the object's index in the pool.
      */
     public int put(Object value) {
-        if (value instanceof MethodSymbol)
-            value = new Method((MethodSymbol)value);
-        else if (value instanceof VarSymbol)
-            value = new Variable((VarSymbol)value);
+        value = makePoolValue(value);
 //      assert !(value instanceof Type.TypeVar);
         Integer index = indices.get(value);
         if (index == null) {
@@ -115,6 +112,18 @@
         return index.intValue();
     }
 
+    Object makePoolValue(Object o) {
+        if (o instanceof DynamicMethodSymbol) {
+            return new DynamicMethod((DynamicMethodSymbol)o);
+        } else if (o instanceof MethodSymbol) {
+            return new Method((MethodSymbol)o);
+        } else if (o instanceof VarSymbol) {
+            return new Variable((VarSymbol)o);
+        } else {
+            return o;
+        }
+    }
+
     /** Return the given object's index in the pool,
      *  or -1 if object is not in there.
      */
@@ -145,6 +154,36 @@
         }
     }
 
+    static class DynamicMethod extends Method {
+
+        DynamicMethod(DynamicMethodSymbol m) {
+            super(m);
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (!super.equals(other)) return false;
+            if (!(other instanceof DynamicMethod)) return false;
+            DynamicMethodSymbol dm1 = (DynamicMethodSymbol)m;
+            DynamicMethodSymbol dm2 = (DynamicMethodSymbol)((DynamicMethod)other).m;
+            return dm1.bsm == dm2.bsm &&
+                        dm1.bsmKind == dm2.bsmKind &&
+                        Arrays.equals(dm1.staticArgs, dm2.staticArgs);
+        }
+
+        @Override
+        public int hashCode() {
+            int hash = super.hashCode();
+            DynamicMethodSymbol dm = (DynamicMethodSymbol)m;
+            hash += dm.bsmKind * 7 +
+                    dm.bsm.hashCode() * 11;
+            for (int i = 0; i < dm.staticArgs.length; i++) {
+                hash += (dm.staticArgs[i].hashCode() * 23);
+            }
+            return hash;
+        }
+    }
+
     static class Variable extends DelegatedSymbol {
         VarSymbol v;
         Variable(VarSymbol v) {
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Sat Nov 17 19:01:03 2012 +0000
@@ -121,12 +121,9 @@
         this.allowDiamond = source.allowDiamond();
         this.allowMulticatch = source.allowMulticatch();
         this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true);
-        this.allowLambda = source.allowLambda() &&
-                fac.options.isSet("allowLambda"); //pre-lambda guard
-        this.allowMethodReferences = source.allowMethodReferences() &&
-                fac.options.isSet("allowMethodReferences"); //pre-lambda guard
-        this.allowDefaultMethods = source.allowDefaultMethods() &&
-                fac.options.isSet("allowDefaultMethods"); //pre-lambda guard
+        this.allowLambda = source.allowLambda();
+        this.allowMethodReferences = source.allowMethodReferences();
+        this.allowDefaultMethods = source.allowDefaultMethods();
         this.keepDocComments = keepDocComments;
         docComments = newDocCommentTable(keepDocComments, fac);
         this.keepLineMap = keepLineMap;
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Sat Nov 17 19:01:03 2012 +0000
@@ -170,19 +170,6 @@
 compiler.misc.cant.apply.symbols=\
     no suitable {0} found for {1}({2})
 
-
-# 0: type
-compiler.err.cant.access.arg.type.in.functional.desc=\
-    cannot access parameter type {0} in target functional descriptor
-
-# 0: type
-compiler.err.cant.access.return.in.functional.desc=\
-    cannot access return type {0} in target functional descriptor
-
-# 0: type
-compiler.err.cant.access.thrown.in.functional.desc=\
-    cannot access thrown type {0} in target functional descriptor
-
 # 0: symbol kind, 1: symbol
 compiler.misc.no.abstracts=\
     no abstract method found in {0} {1}
@@ -257,9 +244,6 @@
 compiler.err.cant.ref.before.ctor.called=\
     cannot reference {0} before supertype constructor has been called
 
-compiler.err.cant.ret.val.from.meth.decl.void=\
-    cannot return a value from method whose result type is void
-
 compiler.err.cant.select.static.class.from.param.type=\
     cannot select a static class from a parameterized type
 
@@ -661,8 +645,8 @@
 compiler.misc.missing.ret.val=\
     missing return value
 
-compiler.err.missing.ret.val=\
-    missing return value
+compiler.misc.unexpected.ret.val=\
+    unexpected return value
 
 # 0: set of modifier
 compiler.err.mod.not.allowed.here=\
@@ -708,6 +692,9 @@
 compiler.misc.incompatible.type.in.conditional=\
     bad type in conditional expression; {0}
 
+compiler.misc.conditional.target.cant.be.void=\
+    target-type for conditional expression cannot be void
+
 # 0: type
 compiler.misc.incompatible.ret.type.in.lambda=\
     bad return type in lambda expression\n\
@@ -960,7 +947,7 @@
 
 # 0: symbol, 1: type
 compiler.misc.overridden.default=\
-    method {0} is overridden in {2}
+    method {0} is overridden in {1}
 
 # 0: symbol, 1: symbol
 compiler.misc.redundant.supertype=\
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1110,7 +1110,7 @@
     public void visitReference(JCMemberReference tree) {
         try {
             printExpr(tree.expr);
-            print("#");
+            print("::");
             if (tree.typeargs != null) {
                 print("<");
                 printExprs(tree.typeargs);
--- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Sat Nov 17 19:01:03 2012 +0000
@@ -525,7 +525,8 @@
                     bound = ((ErrorType)bound).getOriginalType();
                 //retrieve the bound list - if the type variable
                 //has not been attributed the bound is not set
-                List<Type> bounds = bound != null ?
+                List<Type> bounds = (bound != null) &&
+                        (bound.hasTag(CLASS) || bound.hasTag(TYPEVAR)) ?
                     types.getBounds(t) :
                     List.<Type>nil();
 
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Warner.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Warner.java	Sat Nov 17 19:01:03 2012 +0000
@@ -39,7 +39,6 @@
  * deletion without notice.</b>
  */
 public class Warner {
-    public static final Warner noWarnings = new Warner();
 
     private DiagnosticPosition pos = null;
     protected boolean warned = false;
--- a/langtools/test/tools/javac/conditional/Conditional.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/conditional/Conditional.java	Sat Nov 17 19:01:03 2012 +0000
@@ -27,8 +27,8 @@
  * @summary Conditional operator applies assignment conversion
  * @author Tim Hanson, BEA
  *
- * @compile -XDallowPoly Conditional.java
- * @compile/fail Conditional.java
+ * @compile Conditional.java
+ * @compile/fail -source 7 Conditional.java
  */
 
 import java.util.*;
--- a/langtools/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,7 @@
  * @test
  * @summary check that default methods don't cause ClassReader to complete classes recursively
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods pkg/Foo.java
+ * @compile pkg/Foo.java
  * @compile ClassReaderTest.java
  */
 
--- a/langtools/test/tools/javac/defaultMethods/Neg01.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary negative test for ambiguous defaults
- * @compile/fail/ref=Neg01.out -XDallowDefaultMethods -XDrawDiagnostics Neg01.java
+ * @compile/fail/ref=Neg01.out -XDrawDiagnostics Neg01.java
  */
 
 class Neg01 {
--- a/langtools/test/tools/javac/defaultMethods/Neg02.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that ill-formed MI hierarchies do not compile
- * @compile/fail/ref=Neg02.out -XDallowDefaultMethods -XDrawDiagnostics Neg02.java
+ * @compile/fail/ref=Neg02.out -XDrawDiagnostics Neg02.java
  */
 
 class Neg02 {
--- a/langtools/test/tools/javac/defaultMethods/Neg03.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that re-abstraction works properly
- * @compile/fail/ref=Neg03.out -XDallowDefaultMethods -XDrawDiagnostics Neg03.java
+ * @compile/fail/ref=Neg03.out -XDrawDiagnostics Neg03.java
  */
 
 class Neg03 {
--- a/langtools/test/tools/javac/defaultMethods/Neg04.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg04.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default method must have most specific return type
- * @compile/fail/ref=Neg04.out -XDallowDefaultMethods -XDrawDiagnostics Neg04.java
+ * @compile/fail/ref=Neg04.out -XDrawDiagnostics Neg04.java
  */
 
 class Neg04 {
--- a/langtools/test/tools/javac/defaultMethods/Neg05.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg05.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that abstract methods are compatible with inherited defaults
- * @compile/fail/ref=Neg05.out -XDallowDefaultMethods -XDrawDiagnostics Neg05.java
+ * @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java
  */
 
 class Neg05 {
--- a/langtools/test/tools/javac/defaultMethods/Neg06.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg06.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary flow analysis is not run on inlined default bodies
- * @compile/fail/ref=Neg06.out -XDallowDefaultMethods -XDrawDiagnostics Neg06.java
+ * @compile/fail/ref=Neg06.out -XDrawDiagnostics Neg06.java
  */
 
 class Neg06 {
--- a/langtools/test/tools/javac/defaultMethods/Neg07.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg07.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg07.out -XDallowDefaultMethods -XDrawDiagnostics Neg07.java
+ * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java
  */
 
 class Neg07 {
--- a/langtools/test/tools/javac/defaultMethods/Neg08.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg08.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg08.out -XDallowDefaultMethods -XDrawDiagnostics Neg08.java
+ * @compile/fail/ref=Neg08.out -XDrawDiagnostics Neg08.java
  */
 class Neg08 {
     interface I {
--- a/langtools/test/tools/javac/defaultMethods/Neg09.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg09.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg09.java
+ * @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg09.java
  */
 import java.util.List;
 
--- a/langtools/test/tools/javac/defaultMethods/Neg10.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg10.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg10.java
+ * @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg10.java
  */
 class Neg10 {
     interface I<X extends Exception> {
--- a/langtools/test/tools/javac/defaultMethods/Neg11.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg11.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default overrides are properly type-checked
- * @compile/fail/ref=Neg11.out -XDallowDefaultMethods -XDrawDiagnostics Neg11.java
+ * @compile/fail/ref=Neg11.out -XDrawDiagnostics Neg11.java
  */
 class Neg11 {
     interface I {
--- a/langtools/test/tools/javac/defaultMethods/Neg12.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg12.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that abstract methods are discarded in overload resolution diags
- * @compile/fail/ref=Neg12.out -XDallowDefaultMethods -XDrawDiagnostics Neg12.java
+ * @compile/fail/ref=Neg12.out -XDrawDiagnostics Neg12.java
  */
 class Neg12 {
 
--- a/langtools/test/tools/javac/defaultMethods/Neg12.out	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg12.out	Sat Nov 17 19:01:03 2012 +0000
@@ -1,4 +1,4 @@
 Neg12.java:21:12: compiler.err.does.not.override.abstract: Neg12.D, m(java.lang.String), Neg12.I2
-Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, ,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))}
+Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, compiler.misc.no.args,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))}
 Neg12.java:25:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Integer, compiler.misc.no.args, kindname.class, Neg12.B, (compiler.misc.arg.length.mismatch)
 3 errors
--- a/langtools/test/tools/javac/defaultMethods/Neg13.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg13.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that default method overriding object members are flagged as error
- * @compile/fail/ref=Neg13.out -XDallowDefaultMethods -XDrawDiagnostics Neg13.java
+ * @compile/fail/ref=Neg13.out -XDrawDiagnostics Neg13.java
  */
 interface Neg13 {
     default protected Object clone() { return null; } //protected not allowed here
--- a/langtools/test/tools/javac/defaultMethods/Neg14.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg14.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that a class cannot have two sibling interfaces with a default and abstract method
- * @compile/fail/ref=Neg14.out -XDallowDefaultMethods -XDrawDiagnostics Neg14.java
+ * @compile/fail/ref=Neg14.out -XDrawDiagnostics Neg14.java
  */
 class Neg14 {
     interface IA { int m(); }
--- a/langtools/test/tools/javac/defaultMethods/Neg15.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg15.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that level skipping in default super calls is correctly rejected
- * @compile/fail/ref=Neg15.out -XDallowDefaultMethods -XDrawDiagnostics Neg15.java
+ * @compile/fail/ref=Neg15.out -XDrawDiagnostics Neg15.java
  */
 class Neg15 {
     interface I { default void m() {  } }
--- a/langtools/test/tools/javac/defaultMethods/Neg16.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Neg16.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,7 +1,7 @@
 /*
  * @test /nodynamiccopyright/
  * @summary check that level skipping in default super calls is correctly rejected
- * @compile/fail/ref=Neg16.out -XDallowDefaultMethods -XDrawDiagnostics Neg16.java
+ * @compile/fail/ref=Neg16.out -XDrawDiagnostics Neg16.java
  */
 class Neg16 {
     interface I { default void m() {  } }
--- a/langtools/test/tools/javac/defaultMethods/Pos01.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,14 +24,12 @@
 /*
  * @test
  * @summary basic test for default methods
- * @ignore awaits lambda support
  * @author  Maurizio Cimadamore
- * @compile -XDallowLambda -XDallowPoly -XDallowDefaultMethods Pos01.java
  */
 
 import java.util.*;
 
-class Pos01 {
+public class Pos01 {
 
     interface Mapper<T> {
         T map(T in);
--- a/langtools/test/tools/javac/defaultMethods/Pos02.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,7 @@
  * @test
  * @summary test for explicit resolution of ambiguous default methods
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos02.java
+ * @compile Pos02.java
  */
 
 class Pos02 {
--- a/langtools/test/tools/javac/defaultMethods/Pos04.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos04.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,7 @@
  * @test
  * @summary test for overriding with default method
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos04.java
+ * @compile Pos04.java
  */
 
 class Pos04 {
--- a/langtools/test/tools/javac/defaultMethods/Pos05.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos05.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,7 @@
  * @test
  * @summary check that indirectly inherited default methods are discovered during resolution
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos05.java
+ * @compile Pos05.java
  */
 
 class Pos05  {
--- a/langtools/test/tools/javac/defaultMethods/Pos06.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos06.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,7 @@
  * @test
  * @summary check that well-formed MI hierarchies behaves well w.r.t. method resolution (i.e. no ambiguities)
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos06.java
+ * @compile Pos06.java
  */
 
 class Pos06 {
--- a/langtools/test/tools/javac/defaultMethods/Pos07.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos07.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,7 @@
  * @test
  * @summary check that compilation order does not matter
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos07.java
+ * @compile Pos07.java
  */
 
 class Pos07 {
--- a/langtools/test/tools/javac/defaultMethods/Pos08.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos08.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,7 @@
  * @test
  * @summary check that common overrider solves default method conflicts
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos08.java
+ * @compile Pos08.java
  */
 
 class Pos08 {
--- a/langtools/test/tools/javac/defaultMethods/Pos10.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos10.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,7 @@
  * @test
  * @summary check that type-variables in generic extension decl can be accessed from default impl
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods Pos10.java
+ * @compile Pos10.java
  */
 
 class Pos10 {
--- a/langtools/test/tools/javac/defaultMethods/Pos11.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos11.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,7 @@
  * @test
  * @summary complex test with conflict resolution via overriding
  * @author  Brian Goetz
- * @compile -XDallowDefaultMethods Pos11.java
+ * @compile Pos11.java
  */
 
 class Pos11 {
--- a/langtools/test/tools/javac/defaultMethods/Pos12.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos12.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary check that 'this' can be used from within an extension method
- * @compile -XDallowDefaultMethods Pos12.java
+ * @compile Pos12.java
  */
 
 interface Pos12 {
--- a/langtools/test/tools/javac/defaultMethods/Pos13.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos13.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary qualified 'this' inside default method causes StackOverflowException
- * @compile -XDallowDefaultMethods Pos13.java
+ * @compile Pos13.java
  */
 
 public class Pos13 {
--- a/langtools/test/tools/javac/defaultMethods/Pos14.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos14.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary check that overload resolution selects most specific signature
- * @compile -XDallowDefaultMethods Pos14.java
+ * @compile Pos14.java
  */
 
 class Pos14 {
--- a/langtools/test/tools/javac/defaultMethods/Pos15.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos15.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary check that overload resolution selects most specific signature
- * @compile -XDallowDefaultMethods Pos15.java
+ * @compile Pos15.java
  */
 
 class Pos15 {
--- a/langtools/test/tools/javac/defaultMethods/Pos16.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/Pos16.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,7 @@
 /*
  * @test
  * @summary 'class wins' should not short-circuit overload resolution
- * @compile -XDallowDefaultMethods Pos16.java
+ * @compile Pos16.java
  */
 
 class Pos16 {
--- a/langtools/test/tools/javac/defaultMethods/TestDefaultBody.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/TestDefaultBody.java	Sat Nov 17 19:01:03 2012 +0000
@@ -23,10 +23,7 @@
 
 /*
  * @test
- * @ignore awaits for VM support
  * @summary  check that code attributed for default methods is correctly generated
- * @compile -XDallowDefaultMethods TestDefaultBody.java
- * @run main TestDefaultBody
  */
 
 import com.sun.tools.classfile.AccessFlags;
--- a/langtools/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,8 +25,6 @@
  * @test
  * @ignore awaits for VM support
  * @summary  check that javac does not generate bridge methods for defaults
- * @compile -XDallowDefaultMethods TestNoBridgeOnDefaults.java
- * @run main TestNoBridgeOnDefaults
  */
 
 import com.sun.tools.classfile.ClassFile;
--- a/langtools/test/tools/javac/defaultMethods/fd/FDTest.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/fd/FDTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -82,7 +82,7 @@
 
     void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
         JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source));
+                null, null, Arrays.asList(source));
         try {
             ct.analyze();
         } catch (Throwable ex) {
--- a/langtools/test/tools/javac/defaultMethods/separate/Separate.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/separate/Separate.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,8 +25,8 @@
  * @test
  * @summary smoke test for separate compilation of default methods
  * @author  Maurizio Cimadamore
- * @compile -XDallowDefaultMethods pkg1/A.java
- * @compile -XDallowDefaultMethods Separate.java
+ * @compile  pkg1/A.java
+ * @compile  Separate.java
  */
 
 import pkg1.A;
--- a/langtools/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java	Sat Nov 17 19:01:03 2012 +0000
@@ -323,7 +323,7 @@
 
     void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
         JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source));
+                null, null, Arrays.asList(source));
         try {
             ct.analyze();
         } catch (Throwable ex) {
--- a/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java	Sat Nov 17 19:01:03 2012 +0000
@@ -54,7 +54,7 @@
         }
 
         List<String> getOptions() {
-            return Arrays.asList("-XDallowDefaultMethods", "-source", versionString);
+            return Arrays.asList("-source", versionString);
         }
     }
 
--- a/langtools/test/tools/javac/diags/examples/CantAccessArgTypeInFunctionalDesc.java	Fri Nov 16 18:27:36 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, 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.access.arg.type.in.functional.desc
-// key: compiler.err.report.access
-// options: -XDallowLambda
-
-interface SAM_InaccessibleArg {
-    void m(Foo.Bar bar);
-    static class Foo { private class Bar { } }
-}
-
-class CantAccessArgTypeInFunctionalDesc {
-    SAM_InaccessibleArg s = x-> { };
-}
--- a/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.cant.access.inner.cls.constr
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantAccessInnerClsConstructor {
 
--- a/langtools/test/tools/javac/diags/examples/CantAccessReturnTypeInFunctionalDesc.java	Fri Nov 16 18:27:36 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012, 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.access.return.in.functional.desc
-// options: -XDallowLambda
-
-interface SAM_InaccessibleRet {
-    Foo.Bar m();
-    static class Foo { private class Bar { } }
-}
-
-class CantAccessReturnTypeInFunctionalDesc {
-    SAM_InaccessibleRet s = ()->null;
-}
--- a/langtools/test/tools/javac/diags/examples/CantAccessThrownTypesInFunctionalDesc.java	Fri Nov 16 18:27:36 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2012, 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.access.thrown.in.functional.desc
-// options: -XDallowLambda
-
-interface SAM_InaccessibleThrown {
-    void m() throws Foo.Bar;
-    static class Foo { private class Bar extends Exception { } }
-}
-
-class CantAccessThrownTypesInFunctionalDesc {
-    SAM_InaccessibleThrown s = ()-> { };
-}
--- a/langtools/test/tools/javac/diags/examples/CantApplySymbolFragment.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/CantApplySymbolFragment.java	Sat Nov 17 19:01:03 2012 +0000
@@ -26,7 +26,6 @@
 // key: compiler.misc.no.conforming.assignment.exists
 // key: compiler.misc.cant.apply.symbol
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantApplySymbolFragment {
 
--- a/langtools/test/tools/javac/diags/examples/CantApplySymbolsFragment.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/CantApplySymbolsFragment.java	Sat Nov 17 19:01:03 2012 +0000
@@ -28,7 +28,6 @@
 // key: compiler.misc.inapplicable.method
 // key: compiler.misc.cant.apply.symbols
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantApplySymbolsFragment {
 
--- a/langtools/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.cant.ref.non.effectively.final.var
 // key: compiler.misc.inner.cls
 // key: compiler.misc.lambda
-// options: -XDallowLambda -XDallowEffectivelyFinalInInnerClasses
 
 class CantRefNonEffectivelyFinalVar {
     void test() {
--- a/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.misc.cant.resolve.location.args
 // key: compiler.misc.location
 // key: compiler.err.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantResolveLocationArgsFragment {
 
--- a/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.misc.cant.resolve.location.args.params
 // key: compiler.misc.location
 // key: compiler.err.invalid.mref
-// options: -XDallowMethodReferences
 
 class CantResolveLocationArgsParamsFragment {
 
--- a/langtools/test/tools/javac/diags/examples/CantReturnValueForVoid.java	Fri Nov 16 18:27:36 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, 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.ret.val.from.meth.decl.void
-
-class CantReturnValueForVoid {
-    void m() {
-        return 3;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012, 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.prob.found.req
+// key: compiler.misc.incompatible.ret.type.in.lambda
+// key: compiler.misc.conditional.target.cant.be.void
+
+class ConditionalTargetCantBeVoid {
+
+    interface SAM {
+        void m();
+    }
+
+    void test(boolean cond, Object o1, Object o2) {
+        SAM s = ()-> cond ? o1 : o2;
+    }
+}
--- a/langtools/test/tools/javac/diags/examples/CyclicInference.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/CyclicInference.java	Sat Nov 17 19:01:03 2012 +0000
@@ -23,7 +23,6 @@
 
 // key: compiler.err.cant.apply.symbol
 // key: compiler.misc.cyclic.inference
-// options: -XDallowLambda -XDallowPoly
 
 class CyclicInference {
     interface SAM<X> {
--- a/langtools/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java	Sat Nov 17 19:01:03 2012 +0000
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.default.overrides.object.member
-// options: -XDallowDefaultMethods
 
 interface DefaultOverridesObjectMember {
     default String toString() { return ""; }
--- a/langtools/test/tools/javac/diags/examples/IncompatibleAbstracts.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleAbstracts.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.not.a.functional.intf.1
 // key: compiler.misc.incompatible.abstracts
-// options: -XDallowLambda
 
 class IncompatibleAbstracts {
 
--- a/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java	Sat Nov 17 19:01:03 2012 +0000
@@ -23,7 +23,6 @@
 
 // key: compiler.err.prob.found.req
 // key: compiler.misc.incompatible.arg.types.in.lambda
-// options: -XDallowLambda -XDallowPoly
 
 class IncompatibleArgTypesInLambda {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java	Sat Nov 17 19:01:03 2012 +0000
@@ -26,7 +26,6 @@
 // key: compiler.misc.incompatible.descs.in.functional.intf
 // key: compiler.misc.descriptor
 // key: compiler.misc.descriptor.throws
-// options: -XDallowLambda
 
 class IncompatibleDescsInFunctionalIntf {
     interface A {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.inconvertible.types
 // key: compiler.misc.incompatible.ret.type.in.lambda
-// options: -XDallowLambda -XDallowPoly
 
 class IncompatibleRetTypeInLambda {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.inconvertible.types
 // key: compiler.misc.incompatible.ret.type.in.mref
-// options: -XDallowMethodReferences -XDallowPoly
 
 class IncompatibleRetTypeInMref {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java	Sat Nov 17 19:01:03 2012 +0000
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.incompatible.thrown.types.in.lambda
-// options: -XDallowLambda
 
 class IncompatibleThrownTypesInLambda {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java	Sat Nov 17 19:01:03 2012 +0000
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.incompatible.thrown.types.in.mref
-// options: -XDallowMethodReferences
 
 class IncompatibleThrownTypesInMref {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.incompatible.type.in.conditional
 // key: compiler.misc.inconvertible.types
-// options: -XDallowPoly
 
 class IncompatibleTypesInConditional {
 
--- a/langtools/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java	Sat Nov 17 19:01:03 2012 +0000
@@ -23,7 +23,6 @@
 
 // key: compiler.err.prob.found.req
 // key: compiler.misc.invalid.generic.desc.in.functional.intf
-// options: -XDallowLambda
 
 class InvalidGenericDescInFunctionalIntf {
 
--- a/langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/LocalVarNeedsFinal.java	Sat Nov 17 19:01:03 2012 +0000
@@ -22,6 +22,7 @@
  */
 
 // key: compiler.err.local.var.accessed.from.icls.needs.final
+// options: -Xlint:-options -source 7
 
 class LocalVarNeedsFinal {
     Runnable m() {
--- a/langtools/test/tools/javac/diags/examples/MissingReturnValue.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/MissingReturnValue.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -21,7 +21,8 @@
  * questions.
  */
 
-// key: compiler.err.missing.ret.val
+// key: compiler.err.prob.found.req
+// key: compiler.misc.missing.ret.val
 
 class MissingReturnValue {
     int m() {
--- a/langtools/test/tools/javac/diags/examples/MissingReturnValueFragment.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/MissingReturnValueFragment.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.incompatible.ret.type.in.lambda
 // key: compiler.misc.missing.ret.val
-// options: -XDallowLambda
 
 class MissingReturnValueFragment {
     interface SAM {
--- a/langtools/test/tools/javac/diags/examples/NoAbstracts.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/NoAbstracts.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.not.a.functional.intf.1
 // key: compiler.misc.no.abstracts
-// options: -XDallowLambda
 
 class NoAbstracts {
 
--- a/langtools/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java	Sat Nov 17 19:01:03 2012 +0000
@@ -23,7 +23,6 @@
 
 // key: compiler.err.prob.found.req
 // key: compiler.misc.no.suitable.functional.intf.inst
-// options: -XDallowLambda
 
 class NoSuitableFunctionalIntfInst {
 
--- a/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.non-static.cant.be.ref
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class NonStaticCantBeRefFragment {
 
--- a/langtools/test/tools/javac/diags/examples/NotAFunctionalIntf.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotAFunctionalIntf.java	Sat Nov 17 19:01:03 2012 +0000
@@ -23,7 +23,6 @@
 
 // key: compiler.err.prob.found.req
 // key: compiler.misc.not.a.functional.intf
-// options: -XDallowLambda
 
 class NotAFunctionalIntf {
 
--- a/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.not.def.access.class.intf.cant.access
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class NotDefAccessClassIntfCantAccessFragment {
 
--- a/langtools/test/tools/javac/diags/examples/OverriddenDefault.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/OverriddenDefault.java	Sat Nov 17 19:01:03 2012 +0000
@@ -23,7 +23,6 @@
 
 // key: compiler.err.illegal.default.super.call
 // key: compiler.misc.overridden.default
-// options: -XDallowDefaultMethods
 
 class OverriddenDefault {
     interface I { default void m() {  } }
@@ -33,4 +32,4 @@
     static class C implements J, K {
         void foo() { K.super.m(); }
     }
-}
\ No newline at end of file
+}
--- a/langtools/test/tools/javac/diags/examples/PotentialLambdaFound.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/PotentialLambdaFound.java	Sat Nov 17 19:01:03 2012 +0000
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.note.potential.lambda.found
-// options: -XDallowLambda -XDidentifyLambdaCandidate=true
+// options: -XDidentifyLambdaCandidate=true
 
 class PotentialLambdaFound {
 
--- a/langtools/test/tools/javac/diags/examples/RedundantSupertype.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/RedundantSupertype.java	Sat Nov 17 19:01:03 2012 +0000
@@ -23,7 +23,6 @@
 
 // key: compiler.err.illegal.default.super.call
 // key: compiler.misc.redundant.supertype
-// options: -XDallowDefaultMethods
 
 class RedundantSupertype {
     interface I { default void m() {  } }
--- a/langtools/test/tools/javac/diags/examples/RefAmbiguousFragment.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/RefAmbiguousFragment.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,6 @@
 // key: compiler.err.prob.found.req
 // key: compiler.misc.ref.ambiguous
 // key: compiler.misc.invalid.mref
-// options: -XDallowMethodReferences
 
 class RefAmbiguousFragment {
 
--- a/langtools/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java	Sat Nov 17 19:01:03 2012 +0000
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.types.incompatible.abstract.default
-// options: -XDallowDefaultMethods
 
 class TypesIncompatibleAbstractDefault {
     interface A {
--- a/langtools/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java	Sat Nov 17 19:01:03 2012 +0000
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.types.incompatible.unrelated.defaults
-// options: -XDallowDefaultMethods
 
 class TypesIncompatibleUnrelatedDefaults {
     interface A {
--- a/langtools/test/tools/javac/diags/examples/UnexpectedLambda.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/UnexpectedLambda.java	Sat Nov 17 19:01:03 2012 +0000
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.unexpected.lambda
-// options: -XDallowLambda
 
 class UnexpectedLambda {
     { (()-> { })++; }
--- a/langtools/test/tools/javac/diags/examples/UnexpectedMref.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/diags/examples/UnexpectedMref.java	Sat Nov 17 19:01:03 2012 +0000
@@ -22,7 +22,6 @@
  */
 
 // key: compiler.err.unexpected.mref
-// options: -XDallowMethodReferences
 
 class UnexpectedLambda {
     { (Foo::bar)++; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/UnexpectedReturnValue.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, 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.prob.found.req
+// key: compiler.misc.unexpected.ret.val
+
+class UnexpectedReturnValue {
+    void m() {
+        return 3;
+    }
+}
--- a/langtools/test/tools/javac/generics/7022054/T7022054pos1.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos1.java	Sat Nov 17 19:01:03 2012 +0000
@@ -27,7 +27,7 @@
  *
  * @summary  Invalid compiler error on covariant overriding methods with the same erasure
  * @compile -source 7 T7022054pos1.java
- * @compile/fail -XDstrictMethodClashCheck T7022054pos1.java
+ * @compile/fail/ref=T7022054pos1.out -XDrawDiagnostics T7022054pos1.java
  *
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos1.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+T7022054pos1.java:39:25: compiler.err.name.clash.same.erasure.no.override: <X>m(java.lang.String), T7022054pos1.B, m(java.lang.String), T7022054pos1.A, <X>m(java.lang.String), T7022054pos1.B
+1 error
--- a/langtools/test/tools/javac/generics/7022054/T7022054pos2.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos2.java	Sat Nov 17 19:01:03 2012 +0000
@@ -27,7 +27,7 @@
  *
  * @summary  Invalid compiler error on covariant overriding methods with the same erasure
  * @compile -source 7 T7022054pos2.java
- * @compile/fail -XDstrictMethodClashCheck T7022054pos2.java
+ * @compile/fail/ref=T7022054pos2.out -XDrawDiagnostics T7022054pos2.java
  */
 
 class T7022054pos2 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos2.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+T7022054pos2.java:38:32: compiler.err.name.clash.same.erasure.no.hide: <X>m(java.lang.String), T7022054pos2.B, m(java.lang.String), T7022054pos2.A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-static variables are not accessible from static lambdas
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadAccess.out -XDrawDiagnostics BadAccess.java
+ */
+
+public class BadAccess {
+
+    int i;
+    static int I;
+
+    interface SAM {
+        int m();
+    }
+
+    static void test1() {
+        int l = 0; //effectively final
+        final int L = 0;
+        SAM s = ()-> i + I + l + L;
+    }
+
+    void test2() {
+        int l = 0; //effectively final
+        final int L = 0;
+        SAM s = ()-> i + I + l + L;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+BadAccess.java:22:22: compiler.err.non-static.cant.be.ref: kindname.variable, i
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check lambda can access only effectively-final locals
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadAccess02.out -XDrawDiagnostics BadAccess02.java
+ */
+
+public class BadAccess02 {
+
+    interface SAM {
+        int m(int h);
+    }
+
+    static void test1() {
+        int l = 0; //effectively final
+        int j = 0; //non-effectively final
+        j = 2;
+        final int L = 0;
+        SAM s = (int h) -> { int k = 0; return h + j + l + L; };
+    }
+
+    void test2() {
+        int l = 0; //effectively final
+        int j = 0; //non-effectively final
+        j = 2;
+        final int L = 0;
+        SAM s = (int h) -> { int k = 0; return h + k + j + l + L; };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess02.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+BadAccess02.java:21:52: compiler.err.cant.ref.non.effectively.final.var: j, (compiler.misc.lambda)
+BadAccess02.java:29:56: compiler.err.cant.ref.non.effectively.final.var: j, (compiler.misc.lambda)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check lambda cannot assign non-effectively final locals
+ * @compile/fail/ref=BadAccess03.out -XDrawDiagnostics BadAccess03.java
+ */
+
+class BadAccess03 {
+    void test() {
+        int k = 0;
+        int n = 2; //effectively final variable
+        Runnable r = ()-> { k = n; }; //error
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadAccess03.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+BadAccess03.java:13:29: compiler.err.cant.ref.non.effectively.final.var: k, (compiler.misc.lambda)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadBreakContinue.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,44 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that break/continue is disallowed in lambda expressions
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadBreakContinue.out -XDrawDiagnostics BadBreakContinue.java
+ */
+
+class BadBreakContinue {
+
+    static interface SAM {
+       void m();
+    }
+
+    SAM s1 = ()-> { break; };
+    SAM s2 = ()-> { continue; };
+    SAM s3 = ()-> {
+        SAM s3_1 = ()-> { break; };
+        SAM s3_2 = ()-> { continue; };
+    };
+
+    void testLabelled() {
+        loop: while (true) {
+            SAM s1 = ()-> { break loop; };
+            SAM s2 = ()-> { continue loop; };
+            SAM s3 = ()-> {
+                SAM s3_1 = ()-> { break loop; };
+                SAM s3_2 = ()-> { continue loop; };
+            };
+        }
+    }
+
+    void testNonLabelled() {
+        while (true) {
+            SAM s1 = ()-> { break; };
+            SAM s2 = ()-> { continue; };
+            SAM s3 = ()-> {
+                SAM s3_1 = ()-> { break; };
+                SAM s3_2 = ()-> { continue; };
+            };
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadBreakContinue.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,13 @@
+BadBreakContinue.java:16:21: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:17:21: compiler.err.cont.outside.loop
+BadBreakContinue.java:19:27: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:20:27: compiler.err.cont.outside.loop
+BadBreakContinue.java:25:29: compiler.err.undef.label: loop
+BadBreakContinue.java:26:29: compiler.err.undef.label: loop
+BadBreakContinue.java:28:35: compiler.err.undef.label: loop
+BadBreakContinue.java:29:35: compiler.err.undef.label: loop
+BadBreakContinue.java:36:29: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:37:29: compiler.err.cont.outside.loop
+BadBreakContinue.java:39:35: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:40:35: compiler.err.cont.outside.loop
+12 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadConv03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  NPE while checking if subinterface is a SAM type
+ * @compile/fail/ref=BadConv03.out -XDrawDiagnostics BadConv03.java
+ */
+
+class BadConv03 {
+
+    interface A {
+        void a();
+    }
+
+    interface B extends A { //not a SAM (2 non-override equivalent abstracts!)
+        void a(int i);
+    }
+
+    B b = ()-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadConv03.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+BadConv03.java:19:11: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, BadConv03.B))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadConv04.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that ill-formed SAM type generates right diagnostic when SAM converted
+ * @compile/fail/ref=BadConv04.out -XDrawDiagnostics BadConv04.java
+ */
+
+class BadConv04 {
+
+    interface I1 {
+        int m();
+    }
+
+    interface I2 {
+        long m();
+    }
+
+    interface SAM extends I1, I2 {}
+
+    SAM s = ()-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadConv04.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+BadConv04.java:19:5: compiler.err.types.incompatible.diff.ret: BadConv04.I2, BadConv04.I1, m()
+BadConv04.java:21:13: compiler.err.prob.found.req: (compiler.misc.incompatible.descs.in.functional.intf: kindname.interface, BadConv04.SAM,{(compiler.misc.descriptor: m, , long, ),(compiler.misc.descriptor: m, , int, )})
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadExpressionLambda.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that a conditonal can't be void
+ * @compile/fail/ref=BadExpressionLambda.out -XDrawDiagnostics BadExpressionLambda.java
+ */
+
+class BadExpressionLambda {
+
+    interface SAM {
+        void invoke();
+    }
+
+    public static void m() {}
+
+    void test() {
+        SAM sam1 = () -> m(); //ok
+        SAM sam2 = () -> true ? m() : m(); //not ok
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadExpressionLambda.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+BadExpressionLambda.java:19:31: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.conditional.target.cant.be.void))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadLambdaExpr.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  compile crashes on partial lambda expressions
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+
+public class BadLambdaExpr {
+
+    static int checkCount = 0;
+
+    enum ParameterListKind {
+        ZERO_ARY("()"),
+        UNARY("(#P)"),
+        TWO_ARY("(#P, #P)"),
+        THREE_ARY("(#P, #P, #P)");
+
+        String parametersTemplateStr;
+
+        ParameterListKind(String parametersTemplateStr) {
+            this.parametersTemplateStr = parametersTemplateStr;
+        }
+
+        String getParameterString(ParameterKind pk) {
+            return parametersTemplateStr.replaceAll("#P", pk.parameterStr);
+        }
+    }
+
+    enum ParameterKind {
+        IMPLICIT("a"),
+        EXPLIICT("A a");
+
+        String parameterStr;
+
+        ParameterKind(String parameterStr) {
+            this.parameterStr = parameterStr;
+        }
+    }
+
+    enum ArrowKind {
+        NONE(""),
+        SEMI("-"),
+        FULL("->");
+
+        String arrowStr;
+
+        ArrowKind(String arrowStr) {
+            this.arrowStr = arrowStr;
+        }
+    }
+
+    enum ExprKind {
+        NONE("#P#A"),
+        METHOD_CALL("m(#P#A)"),
+        CONSTR_CALL("new Foo(#P#A)");
+
+        String expressionTemplate;
+
+        ExprKind(String expressionTemplate) {
+            this.expressionTemplate = expressionTemplate;
+        }
+
+        String expressionString(ParameterListKind plk, ParameterKind pk,
+                ArrowKind ak) {
+            return expressionTemplate.replaceAll("#P", plk.getParameterString(pk))
+                    .replaceAll("#A", ak.arrowStr);
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (ParameterListKind plk : ParameterListKind.values()) {
+            for (ParameterKind pk : ParameterKind.values()) {
+                for (ArrowKind ak : ArrowKind.values()) {
+                    for (ExprKind ek : ExprKind.values()) {
+                        new BadLambdaExpr(plk, pk, ak, ek).run(comp, fm);
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    ParameterListKind plk;
+    ParameterKind pk;
+    ArrowKind ak;
+    ExprKind ek;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    BadLambdaExpr(ParameterListKind plk, ParameterKind pk, ArrowKind ak, ExprKind ek) {
+        this.plk = plk;
+        this.pk = pk;
+        this.ak = ak;
+        this.ek = ek;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "class Test {\n" +
+                          "   SAM s = #E;\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#E", ek.expressionString(plk, pk, ak));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.parse();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when parsing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        boolean errorExpected =
+                ak != ArrowKind.NONE ||
+                plk != ParameterListKind.UNARY ||
+                pk != ParameterKind.IMPLICIT;
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("bad diag for source:\n" +
+                source.getCharContent(true));
+        }
+        checkCount++;
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        @Override
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadLambdaPos.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda is only allowed in argument/cast/assignment context
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadLambdaPos.out -XDrawDiagnostics BadLambdaPos.java
+ */
+
+interface SAM {
+    void m(Integer x);
+}
+
+class Test {
+    void test(Object x) {}
+
+    void test1() {
+        test((int x)-> { } + (int x)-> { } );
+        test((int x)-> { } instanceof Object );
+    }
+
+    void test2() {
+        int i2 = (int x)-> { } + (int x)-> { };
+        boolean b = (int x)-> { } instanceof Object;
+    }
+
+    void test3() {
+        test((Object)(int x)-> { });
+        Object o = (Object)(int x)-> { };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadLambdaPos.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,9 @@
+BadLambdaPos.java:18:14: compiler.err.unexpected.lambda
+BadLambdaPos.java:18:30: compiler.err.unexpected.lambda
+BadLambdaPos.java:19:14: compiler.err.unexpected.lambda
+BadLambdaPos.java:23:18: compiler.err.unexpected.lambda
+BadLambdaPos.java:23:34: compiler.err.unexpected.lambda
+BadLambdaPos.java:24:21: compiler.err.unexpected.lambda
+BadLambdaPos.java:28:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+BadLambdaPos.java:29:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+8 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadMethodCall.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that diagnostics on nested erroneous deferred types are flushed
+ * @compile/fail/ref=BadMethodCall.out -XDrawDiagnostics BadMethodCall.java
+ */
+import java.util.*;
+
+class BadMethodCall {
+    <I> List<I> id(List<I> z) { return null; };
+
+    List<String> cons(String s, List<String> ls) { return null; }
+
+    void test(List<Object> lo) { Object t = cons(id(""),lo); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadMethodCall.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+BadMethodCall.java:15:50: compiler.err.cant.apply.symbol: kindname.method, id, java.util.List<I>, java.lang.String, kindname.class, BadMethodCall, (compiler.misc.infer.no.conforming.assignment.exists: I, (compiler.misc.inconvertible.types: java.lang.String, java.util.List<I>))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadRecovery.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that recovery of speculative types is not attempted if receiver is erroneous
+ * @compile/fail/ref=BadRecovery.out -XDrawDiagnostics BadRecovery.java
+ */
+class BadRecovery {
+
+    interface SAM1 {
+        void m(Object o);
+    }
+
+    void m(SAM1 m) { };
+
+    void test() {
+        m((receiver, t) -> { receiver.someMemberOfReceiver(()->{ Object x = f; }); });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadRecovery.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+BadRecovery.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, BadRecovery.SAM1, @369, kindname.class, BadRecovery, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))
+BadRecovery.java:17:77: compiler.err.cant.resolve.location: kindname.variable, f, , , (compiler.misc.location: kindname.class, BadRecovery, null)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadReturn.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,38 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that incompatible return types in lambdas are flagged with error
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadReturn.out -XDrawDiagnostics BadReturn.java
+ */
+
+class BadReturn {
+
+    interface SAM {
+        Comparable<?> m();
+    }
+
+    static void testNeg1() {
+        SAM s = ()-> {
+            if (true) {
+                return "";
+            } else {
+                return System.out.println("");
+            }};
+    }
+
+    static void testNeg2() {
+        SAM s = ()-> { return System.out.println(""); };
+    }
+
+    static void testPos() {
+        SAM s = ()-> {
+            if (false) {
+                return 10;
+            }
+            else {
+                return true;
+            }};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadReturn.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+BadReturn.java:21:42: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
+BadReturn.java:26:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadStatementInLambda.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that the compiler emits meaningful diagnostics when the lambda body contains bad statements
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadStatementInLambda.out -XDrawDiagnostics BadStatementInLambda.java
+ */
+
+class BadStatementInLambda {
+
+    interface SAM{
+        Object m();
+    }
+
+    SAM t1 = ()-> { null; };
+    SAM t2 = ()-> { 1; };
+    SAM t3 = ()-> { 1 + 5; };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadStatementInLambda.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,4 @@
+BadStatementInLambda.java:16:21: compiler.err.not.stmt
+BadStatementInLambda.java:17:21: compiler.err.not.stmt
+BadStatementInLambda.java:18:23: compiler.err.not.stmt
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadStatementInLambda02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that the compiler emits meaningful diagnostics when the lambda body contains bad statements
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadStatementInLambda02.out -XDrawDiagnostics BadStatementInLambda02.java
+ */
+
+class BadStatementInLambda02 {
+
+    interface SAM {
+        void m();
+    }
+
+    { call(()-> { System.out.println(new NonExistentClass() + ""); }); }
+
+    void call(SAM s) { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadStatementInLambda02.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+BadStatementInLambda02.java:16:42: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, BadStatementInLambda02, null)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadTargetType.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that only SAM are allowed as target types for lambda expressions
+ * @author Jan Lahoda
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadTargetType.out -XDrawDiagnostics BadTargetType.java
+ */
+
+class BadTargetType {
+
+    static void m1(Object o) {}
+    void m2(Object o) {}
+
+    static Object l1 = (int pos)-> { };
+    Object l2 = (int pos)-> { };
+
+    {
+        m1((int pos)-> { });
+        m2((int pos)-> { });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/BadTargetType.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+BadTargetType.java:16:24: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+BadTargetType.java:17:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+BadTargetType.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, java.lang.Object, @460, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf))
+BadTargetType.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, java.lang.Object, @489, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Conditional01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  conditional and varargs
+ * @compile -XDcomplexinference Conditional01.java
+ */
+
+import java.util.*;
+
+class Conditional01 {
+    void varargs(Object ... args) {  }
+
+    void test(boolean flag, List<String> ls) {
+       varargs(flag ? "" : ls);
+       varargs(null, flag ? "" : ls);
+       varargs(flag ? "" : ls());
+       varargs(null, flag ? "" : ls());
+    }
+
+    List<String> ls() { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Conditional02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  inference and conditionals
+ * @compile -XDcomplexinference Conditional02.java
+ */
+
+class Conditional02 {
+
+    <Z> void m1(Z z) { }
+    <Z> void m2(Z... z) { }
+
+    void test(boolean flag) {
+        m1(flag ? "" : "");
+        m2(flag ? "" : "");
+        m2("", flag ? "" : "");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Conditional03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  conditionals and boxing
+ * @compile -XDcomplexinference Conditional03.java
+ */
+
+class Conditional03 {
+
+   void m1(Object o) { }
+   void m2(int i) { }
+
+   void test(boolean cond) {
+       m1((cond ? 1 : 1));
+       m1((cond ? box(1) : box(1)));
+   }
+
+   Integer box(int i) { return i; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Conformance01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  lambda compiler regression with uninferred type-variables in generic constructor call
+ * @compile Conformance01.java
+ */
+
+class Conformance01 {
+    <T1, T2> Conformance01(T1 t) { }
+
+    Conformance01 c01 = new Conformance01(null);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/Defender01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  routine that checks for SAM types should skip defender methods in extended interfaces
+ * @author  Maurizio Cimadamore
+ * @compile Defender01.java
+ */
+
+class Defender01 {
+
+    interface A{
+        Object m();
+        default void n() { E.n(this); }
+    }
+
+    static class E{
+        static void n(A a){};
+    }
+
+    A t = ()-> null;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/DisjunctiveTypeTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that subtyping between disjunctive and non disjunctive type works
+ * @author  Maurizio Cimadamore
+ * @compile DisjunctiveTypeTest.java
+ */
+
+class DisjunctiveTypeTest {
+
+    static class A extends IllegalArgumentException {
+       A(String a) { super(a); }
+    }
+
+    class B extends IllegalArgumentException {
+       B(String b) { super(b); }
+    }
+
+    void m() throws A,B {}
+
+    void test() {
+        try {
+            m();
+        } catch (A|B e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinal01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  effectively final check fails on method parameter
+ * @compile/fail/ref=EffectivelyFinal01.out -XDrawDiagnostics EffectivelyFinal01.java
+ */
+class EffectivelyFinal01 {
+
+    interface SAM {
+        Integer m(Integer i);
+    }
+
+    void test(Integer nefPar) {
+        SAM s = (Integer h) ->  { Integer k = 0; return k + h + nefPar; };
+        nefPar++;  //non-effectively final
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinal01.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+EffectivelyFinal01.java:15:65: compiler.err.cant.ref.non.effectively.final.var: nefPar, (compiler.misc.lambda)
+1 error
--- a/langtools/test/tools/javac/lambda/EffectivelyFinalTest.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinalTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -1,30 +1,9 @@
 /*
- * Copyright (c) 2012, 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
- * @summary Integrate efectively final check with DA/DU analysis
- * @compile/fail/ref=EffectivelyFinalTest01.out -XDallowEffectivelyFinalInInnerClasses -XDrawDiagnostics EffectivelyFinalTest.java
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Integrate effectively final check with DA/DU analysis
+ * @compile/fail/ref=EffectivelyFinalTest01.out -XDrawDiagnostics EffectivelyFinalTest.java
  * @compile/fail/ref=EffectivelyFinalTest02.out -source 7 -Xlint:-options -XDrawDiagnostics EffectivelyFinalTest.java
  */
 class EffectivelyFinalTest {
@@ -62,7 +41,7 @@
 
     void m6(int x) {
         new Object() { { System.out.println(x+1); } }; //error - x not EF
-        x++;
+        x++; // Illegal: x is not effectively final.
     }
 
     void m7(int x) {
--- a/langtools/test/tools/javac/lambda/EffectivelyFinalTest01.out	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinalTest01.out	Sat Nov 17 19:01:03 2012 +0000
@@ -1,6 +1,6 @@
-EffectivelyFinalTest.java:46:47: compiler.err.var.might.not.have.been.initialized: y
-EffectivelyFinalTest.java:60:47: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
-EffectivelyFinalTest.java:64:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
-EffectivelyFinalTest.java:69:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
-EffectivelyFinalTest.java:74:45: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:25:47: compiler.err.var.might.not.have.been.initialized: y
+EffectivelyFinalTest.java:39:47: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:43:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:48:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:53:45: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
 5 errors
--- a/langtools/test/tools/javac/lambda/EffectivelyFinalTest02.out	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/lambda/EffectivelyFinalTest02.out	Sat Nov 17 19:01:03 2012 +0000
@@ -1,14 +1,14 @@
-EffectivelyFinalTest.java:46:47: compiler.err.var.might.not.have.been.initialized: y
-EffectivelyFinalTest.java:34:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:34:47: compiler.err.local.var.accessed.from.icls.needs.final: y
-EffectivelyFinalTest.java:40:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:40:47: compiler.err.local.var.accessed.from.icls.needs.final: y
-EffectivelyFinalTest.java:46:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:53:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:53:47: compiler.err.local.var.accessed.from.icls.needs.final: y
-EffectivelyFinalTest.java:60:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:60:47: compiler.err.local.var.accessed.from.icls.needs.final: y
-EffectivelyFinalTest.java:64:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:69:45: compiler.err.local.var.accessed.from.icls.needs.final: x
-EffectivelyFinalTest.java:74:45: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:25:47: compiler.err.var.might.not.have.been.initialized: y
+EffectivelyFinalTest.java:13:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:13:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:19:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:19:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:25:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:32:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:32:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:39:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:39:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:43:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:48:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:53:45: compiler.err.local.var.accessed.from.icls.needs.final: y
 13 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/ErroneousArg.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,36 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  speculative cache mismatches between Resolve.access and Attr.checkId leads to compiler crashes
+ * @compile/fail/ref=ErroneousArg.out -XDrawDiagnostics ErroneousArg.java
+ */
+class ErroneousArg {
+
+    private static class Foo {
+        static int j() { return 1; }
+    }
+
+    static Foo foo = new Foo();
+
+    static void m(String s) { }
+    static void m(Integer i) { }
+
+    static int f(String s) { return 1; }
+
+    static int g(String s) { return 1; }
+    static int g(Double s) { return 1; }
+
+    int h() { return 1; }
+}
+
+class TestErroneousArg extends ErroneousArg {
+    static void test() {
+        m(unknown()); //method not found
+        m(f(1)); //inapplicable method
+        m(g(1)); //inapplicable methods
+        m(g(null)); //ambiguous
+        m(h()); //static error
+        m(foo.j()); //inaccessible method
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/ErroneousArg.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,7 @@
+ErroneousArg.java:29:11: compiler.err.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, TestErroneousArg, null)
+ErroneousArg.java:30:11: compiler.err.cant.apply.symbol: kindname.method, f, java.lang.String, int, kindname.class, ErroneousArg, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))
+ErroneousArg.java:31:11: compiler.err.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, ErroneousArg, g(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.method, ErroneousArg, g(java.lang.Double), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.Double)))}
+ErroneousArg.java:32:11: compiler.err.ref.ambiguous: g, kindname.method, g(java.lang.String), ErroneousArg, kindname.method, g(java.lang.Double), ErroneousArg
+ErroneousArg.java:33:11: compiler.err.non-static.cant.be.ref: kindname.method, h()
+ErroneousArg.java:34:14: compiler.err.not.def.access.class.intf.cant.access: j(), ErroneousArg.Foo
+6 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/ErroneousLambdaExpr.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  stale state after speculative attribution round leads to missing classfiles
+ */
+public class ErroneousLambdaExpr<T> {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1<X> {
+        X m(X t, String s);
+    }
+
+    interface SAM2 {
+        void m(String s, int i);
+    }
+
+    interface SAM3<X> {
+        X m(X t, String s, int i);
+    }
+
+    void call(SAM1<T> s1) { assertTrue(true); }
+
+    void call(SAM2 s2) { assertTrue(false); }
+
+    void call(SAM3<T> s3) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        ErroneousLambdaExpr<StringBuilder> test =
+                new ErroneousLambdaExpr<>();
+
+        test.call((builder, string) -> { builder.append(string); return builder; });
+        assertTrue(assertionCount == 1);
+    }
+}
--- a/langtools/test/tools/javac/lambda/InnerConstructor.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/lambda/InnerConstructor.java	Sat Nov 17 19:01:03 2012 +0000
@@ -23,15 +23,20 @@
 
 /*
  * @test
- * @summary Regression test JDK-8003306 inner class constructor in lambda
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Regression test JDK-8003306 inner class constructor in lambda
  * @author  Robert Field
- * @compile -XDallowLambda InnerConstructor.java
  */
 
-class InnerConstructor {
+public class InnerConstructor {
 
-    public void testLambdaWithInnerConstructor() {
-        System.out.printf("%s should be %s\n", seq1().m().toString(), "Cbl:nada");
+    public static void main(String... args) {
+        InnerConstructor ic = new InnerConstructor();
+        String res = ic.seq1().m().toString();
+        if (!res.equals("Cbl.toString")) {
+            throw new AssertionError(String.format("Unexpected result: %s", res));
+        }
     }
 
     Ib1 seq1() {
@@ -40,6 +45,9 @@
 
     class Cbl {
         Cbl() {  }
+        public String toString() {
+            return "Cbl.toString";
+        }
     }
 
     interface Ib1 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture01
+ */
+
+public class LambdaCapture01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    public int n = 5;
+
+    //Simple local capture
+    void test1() {
+        final int N = 1;
+        int res = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + N, 3);
+        assertTrue(4 == res);
+    }
+
+    //Local capture with multiple scopes (anon class)
+    void test2() {
+        final int N = 1;
+        new Tester() {
+            public void test() {
+                final int M = 2;
+                int res = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }.test();
+    }
+
+    //Local capture with multiple scopes (local class)
+    void test3() {
+        final int N = 1;
+        class MyTester implements Tester {
+            public void test() {
+                final int M = 2;
+                int res = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }
+        new MyTester().test();
+    }
+
+    //access to field from enclosing scope
+    void test4() {
+        final int N = 4;
+        int res1 = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + n + N, 3);
+        assertTrue(12 == res1);
+        int res2 = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + LambdaCapture01.this.n + N, 3);
+        assertTrue(12 == res2);
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture01 t = new LambdaCapture01();
+        t.test1();
+        t.test2();
+        t.test3();
+        t.test4();
+        assertTrue(assertionCount == 5);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture02
+ */
+
+public class LambdaCapture02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    public Integer n = 5;
+
+    //Simple local capture
+    void test1() {
+        final Integer N = 1;
+        int res = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + N, 3);
+        assertTrue(4 == res);
+    }
+
+    //Local capture with multiple scopes (anon class)
+    void test2() {
+        final Integer N = 1;
+        new Tester() {
+            public void test() {
+                final Integer M = 2;
+                int res = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }.test();
+    }
+
+    //Local capture with multiple scopes (local class)
+    void test3() {
+        final Integer N = 1;
+        class MyTester implements Tester {
+            public void test() {
+                final Integer M = 2;
+                int res = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }
+        new MyTester().test();
+    }
+
+    //access to field from enclosing scope
+    void test4() {
+        final Integer N = 4;
+        int res1 = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + n + N, 3);
+        assertTrue(12 == res1);
+        int res2 = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + LambdaCapture02.this.n + N, 3);
+        assertTrue(12 == res2);
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture02 t = new LambdaCapture02();
+        t.test1();
+        t.test2();
+        t.test3();
+        t.test4();
+        assertTrue(assertionCount == 5);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  test for capture of non-mutable locals/outer fields in multiple scopes
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture03
+ */
+
+public class LambdaCapture03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    Integer n1 = 10;
+
+    void test1() {
+        final Integer N1 = 1;
+        class A {
+            Integer n2 = 20;
+            void test() {
+                  final Integer N2 = 2;
+                  class B {
+                       void test() {
+                           final Integer N3 = 3;
+                           int res = LambdaCapture03.exec((Integer x) -> x + n1 + n2 + N1 + N2 + N3, 30);
+                           assertTrue(res == 66);
+                       }
+                  }
+                  new B().test();
+            }
+        }
+        new A().test();
+    }
+
+    void test2() {
+        final Integer N1 = 1;
+        new Tester() {
+            Integer n2 = 20;
+            public void test() {
+                final Integer N2 = 2;
+                new Tester() {
+                    public void test() {
+                        final Integer N3 = 3;
+                        int res = LambdaCapture03.exec((Integer x) -> x + n1 + n2 + N1 + N2 + N3, 30);
+                        assertTrue(res == 66);
+                    }
+                }.test();
+            }
+        }.test();
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture03 t = new LambdaCapture03();
+        t.test1();
+        t.test2();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture04.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  test for capture of non-mutable locals/outer fields in multiple scopes
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture04
+ */
+
+public class LambdaCapture04 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<U> {
+        public void foo(U u);
+    }
+
+    public static <U> void exec(TU<U> lambda, U x) {
+        lambda.foo(x);
+    }
+
+    Integer n1 = 10;
+
+    void test1() {
+        final Integer N1 = 1;
+        class A {
+            Integer n2 = 20;
+            void test() {
+                  final Integer N2 = 2;
+                  class B {
+                       void test() {
+                           final Integer N3 = 3;
+                           exec((final Integer x) -> new Tester() { public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } }.test(),30);
+                       }
+                  }
+                  new B().test();
+            }
+        }
+        new A().test();
+    }
+
+    void test2() {
+        final Integer N1 = 1;
+        class A {
+            Integer n2 = 20;
+            void test() {
+                  final Integer N2 = 2;
+                  class B {
+                       void test() {
+                           final Integer N3 = 3;
+                           exec((final Integer x) -> {
+                               class LocTester implements Tester {
+                                   public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); }
+                               };
+                               new LocTester().test();
+                           },30);
+                       }
+                  }
+                  new B().test();
+            }
+        }
+        new A().test();
+    }
+
+    void test3() {
+        final Integer N1 = 1;
+        new Tester() {
+            Integer n2 = 20;
+            public void test() {
+                final Integer N2 = 2;
+                new Tester() {
+                    public void test() {
+                        final Integer N3 = 3;
+                        exec((final Integer x) -> new Tester() { public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } }.test(),30);
+                    }
+                }.test();
+            }
+        }.test();
+    }
+
+    void test4() {
+        final Integer N1 = 1;
+        new Tester() {
+            Integer n2 = 20;
+            public void test() {
+                final Integer N2 = 2;
+                new Tester() {
+                    public void test() {
+                        final Integer N3 = 3;
+                        exec((final Integer x) -> {
+                            class LocTester implements Tester {
+                                public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); }
+                            };
+                            new LocTester().test();
+                        },30);
+                    }
+                }.test();
+            }
+        }.test();
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture04 t = new LambdaCapture04();
+        t.test1();
+        t.test2();
+        t.test3();
+        t.test4();
+        assertTrue(assertionCount == 4);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture05.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  test for capture in nested lambda expressions
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture05
+ */
+
+public class LambdaCapture05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    int i = 40;
+
+    void test1(final int a0) {
+        exec((final Integer a1) -> {
+            final Integer x2 = 10; exec((final Integer a2) -> {
+                final Integer x3 = 20;
+                exec((final Integer a3) -> { assertTrue(106 == (a0 + a1 + a2 + a3 + x2 + x3 + i)); return null; }, 3);
+                return null;
+            },2);
+            return null;
+        },1);
+    }
+
+    static void test2(final int a0) {
+        exec((final Integer a1) -> {
+            final Integer x2 = 10; exec((final Integer a2) -> {
+                final Integer x3 = 20;
+                exec((final Integer a3) -> { assertTrue(66 == (a0 + a1 + a2 + a3 + x2 + x3)); return null; }, 3);
+                return null;
+            }, 2);
+            return null;
+        }, 1);
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture05 t = new LambdaCapture05();
+        t.test1(30);
+        test2(30);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaCapture06.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2012, 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
+ * @ignore investigate as to whether code generation fails
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Compiler crash when local inner class nested inside lambda captures local variables from enclosing scope
+ */
+public class LambdaCapture06 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m(int n);
+    }
+
+    public static void main(String[] args) {
+        int n = 5;
+        SAM s = k -> {
+            new Object() {
+                void test() { int j = n; assertTrue(j == 5); }
+            }.test();
+        };
+        s.m(42);
+        assertTrue(assertionCount == 1);
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for lambda conversion
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv01
+ */
+
+public class LambdaConv01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface IntToInt {
+      public int foo(int x);
+    }
+
+    interface IntToVoid {
+      public void foo(int x);
+    }
+
+    interface VoidToInt {
+      public int foo();
+    }
+
+    interface TU<T, U> {
+      public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    static {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3));
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3));
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void test1() {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3));
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public void test2() {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3));
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaConv01().test2();
+        assertTrue(assertionCount == 16);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  SAM types and method type inference
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv03
+ */
+
+public class LambdaConv03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface TU<T, U> {
+      public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    static {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void test1() {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public void test2() {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaConv03().test2();
+        assertTrue(assertionCount == 12);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv05.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  function type and method type inference
+ * @author  Alex Buckley
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv05
+ */
+
+import java.util.*;
+
+public class LambdaConv05 {
+
+    static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    int count = 0;
+
+    void sort(List<String> data) {
+      Collections.sort(data,
+                       (String a, String b) -> { LambdaConv05.this.count++; return a.length()-b.length(); });
+    }
+
+    public static void main(String[] args) {
+        ArrayList<String> arr = new ArrayList<>();
+        arr.add("Three");
+        arr.add("Four");
+        arr.add("One");
+        LambdaConv05 sorter = new LambdaConv05();
+        sorter.sort(arr);
+        assertTrue(arr.get(0).equals("One"));
+        assertTrue(arr.get(1).equals("Four"));
+        assertTrue(arr.get(2).equals("Three"));
+        assertTrue(sorter.count == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv06.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  ensure that definite assignment analysis doesn't mess up with lambda attribution
+ * @author Jan Lahoda
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv06.java
+ */
+
+class LambdaConv06 {
+
+    private int t() {
+        return a((final Object indexed) -> {
+            return b(new R() {
+                public String build(final Object index) {
+                    return "";
+                }
+            });
+        });
+    }
+
+    private int a(R r) {return 0;}
+    private String b(R r) {return null;}
+
+    public static interface R {
+        public String build(Object o);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv08.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that SAM conversion handles covarinat return types correctly
+ * @author  Peter Levart
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv08
+ */
+
+public class LambdaConv08 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public interface ObjectF { Object invoke(); }
+    public interface StringF extends ObjectF { String invoke(); }
+
+    public static void call(StringF stringFunc) {
+        assertTrue(true);
+    }
+
+    public static void call(ObjectF objectFunc) {  }
+
+    public static void main(String[] args)   {
+        call(()-> "Hello");
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv09.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,50 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that SAM conversion handles Object members correctly
+ * @author  Alex Buckley
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=LambdaConv09.out -XDrawDiagnostics LambdaConv09.java
+ */
+
+class LambdaConv09 {
+
+    // Not a SAM type; not enough abstract methods
+    interface Foo1 {}
+
+    // SAM type; Foo has no abstract methods
+    interface Foo2 { boolean equals(Object object); }
+
+
+    // Not a SAM type; Foo still has no abstract methods
+    interface Foo3 extends Foo2 { public abstract String toString(); }
+
+    // SAM type; Bar has one abstract non-Object method
+    interface Foo4<T> extends Foo2 { int compare(T o1, T o2); }
+
+    // Not a SAM type; still no valid abstract methods
+    interface Foo5 {
+        boolean equals(Object object);
+        String toString();
+    }
+
+    // SAM type; Foo6 has one abstract non-Object method
+    interface Foo6<T> {
+        boolean equals(Object obj);
+        int compare(T o1, T o2);
+    }
+
+    // SAM type; Foo6 has one abstract non-Object method
+    interface Foo7<T> extends Foo2, Foo6<T> { }
+
+    void test() {
+        Foo1 f1 = ()-> { };
+        Foo2 f2 = ()-> { };
+        Foo3 f3 = x -> true;
+        Foo4 f4 = (x, y) -> 1;
+        Foo5 f5 = x -> true;
+        Foo6 f6 = (x, y) -> 1;
+        Foo7 f7 = (x, y) -> 1;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv09.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+LambdaConv09.java:42:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo1))
+LambdaConv09.java:43:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo2))
+LambdaConv09.java:44:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo3))
+LambdaConv09.java:46:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo5))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv10.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda conversion does not allow boxing of lambda parameters
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=LambdaConv10.out -XDrawDiagnostics LambdaConv10.java
+ */
+
+class LambdaConv10 {
+
+    interface Method1<R, A1> { public R call( A1 a1 ); }
+
+    public static void main( final String... notUsed ) {
+        Method1<Integer,Integer> m1 = (int i) -> 2 * i;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv10.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+LambdaConv10.java:15:39: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv11.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  issues with lambda conversion involving generic class hierarchies
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv11.java
+ */
+
+import java.util.Comparator;
+
+class LambdaConv11<T> {
+
+    interface SAM<X> extends Comparator<X> {
+        public int compare(X left, X right);
+    }
+
+    SAM<T> y = (l, r) -> 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv12.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  instance creation expression should allow lambda expressions as constrcutor arguments
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv12.java
+ */
+
+class LambdaConv12 {
+
+    LambdaConv12(SAM s) {}
+
+    interface SAM {
+        public abstract void m();
+    }
+
+    void test() {
+        new LambdaConv12(()-> { });
+        new LambdaConv12(()-> { }) {};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv13.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  interface methods in diamond shaped inheritance trees shouldn't be counted twice
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv13.java
+ */
+
+class LambdaConv13 {
+
+    interface I {
+        void m();
+    }
+
+    interface A extends I {}
+    interface B extends I {}
+    interface C extends A, B {}
+    interface D extends A, I {}
+    interface E extends B, I {}
+
+    C c = ()-> { };
+    D d = ()-> { };
+    D e = ()-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv16.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  SAM conversion and raw types in argument/return types
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv16
+ */
+
+import java.util.*;
+
+public class LambdaConv16 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A {
+        Iterable m(List<String> ls);
+    }
+
+    interface B {
+        Iterable<String> m(List l);
+    }
+
+    interface AB extends A, B {} //SAM type ([List], Iterable<String>, {})
+
+    static void test(AB ab, List l) { ab.m(l); }
+
+    public static void main(String[] args) {
+        AB ab = (List list) -> { assertTrue(true); return new ArrayList<String>(); };
+        ab.m(null);
+        test((List list) -> { assertTrue(true); return new ArrayList<String>(); }, null);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv17.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  lambda compiler crashes if lambda has try-with-resources
+ * @compile LambdaConv17.java
+ */
+
+class LambdaConv17 {
+    interface SAM {
+       void m() throws Exception;
+    }
+
+    SAM s = ()-> { try (AutoCloseable ac = null){ } };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv18.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  simple test for lambda candidate check
+ * @compile/fail/ref=LambdaConv18.out -XDrawDiagnostics -XDidentifyLambdaCandidate=true LambdaConv18.java
+ */
+
+class LambdaConv18 {
+
+    interface SAM {
+        void m();
+    }
+
+    interface NonSAM {
+        void m1();
+        void m2();
+    }
+
+    SAM s1 = new SAM() { public void m() {} };
+    NonSAM s2 = new NonSAM() { public void m1() {}
+                              public void m2() {} };
+    NonExistent s3 = new NonExistent() { public void m() {} };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv18.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,4 @@
+LambdaConv18.java:23:5: compiler.err.cant.resolve.location: kindname.class, NonExistent, , , (compiler.misc.location: kindname.class, LambdaConv18, null)
+LambdaConv18.java:20:24: compiler.note.potential.lambda.found
+LambdaConv18.java:23:26: compiler.err.cant.resolve.location: kindname.class, NonExistent, , , (compiler.misc.location: kindname.class, LambdaConv18, null)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv19.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that redundant cast warnings are not generated for SAM conversions
+ * @compile -Xlint:cast -Werror LambdaConv19.java
+ */
+
+class LambdaConv19 {
+
+    interface SAM {
+        void m();
+    }
+
+    SAM s = (SAM)()-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv20.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that synthetic casts are added when erased type of lambda body
+ *          ends up being too general
+ * @run main LambdaConv20
+ */
+
+import java.util.*;
+
+public class LambdaConv20 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<X> {
+        X m(List<X> l);
+    }
+
+    public static void main(String[] args) {
+        SAM<Integer> si1 = l -> l.get(0);
+        assertTrue(si1.m(Arrays.asList(1)) == 1);
+        SAM<Integer> si2 = l -> { return l.get(0); };
+        assertTrue(si2.m(Arrays.asList(1)) == 1);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv21.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,38 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that code generation handles void-compatibility correctly
+ * @compile/fail/ref=LambdaConv21.out -XDrawDiagnostics LambdaConv21.java
+ */
+
+class LambdaConv21 {
+
+    interface SAM_void<X> {
+        void m();
+    }
+
+    interface SAM_java_lang_Void {
+        Void m();
+    }
+
+    static void m_void() { }
+
+    static Void m_java_lang_Void() { return null; }
+
+    static void testExpressionLambda() {
+        SAM_void s1 = ()->m_void(); //ok
+        SAM_java_lang_Void s2 = ()->m_void(); //no - incompatible target
+        SAM_void s3 = ()->m_java_lang_Void(); //no - incompatible target
+        SAM_java_lang_Void s4 = ()->m_java_lang_Void(); //ok
+    }
+
+    static void testStatementLambda() {
+        SAM_void s1 = ()-> { m_void(); }; //ok
+        SAM_java_lang_Void s2 = ()-> { m_void(); }; //no - missing return value
+        SAM_void s3 = ()-> { return m_java_lang_Void(); }; //no - unexpected return value
+        SAM_java_lang_Void s4 = ()-> { return m_java_lang_Void(); }; //ok
+        SAM_void s5 = ()-> { m_java_lang_Void(); }; //ok
+        SAM_java_lang_Void s6 = ()-> { m_java_lang_Void(); }; //no - missing return value
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv21.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,6 @@
+LambdaConv21.java:25:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Void))
+LambdaConv21.java:26:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Void, void))
+LambdaConv21.java:32:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
+LambdaConv21.java:33:53: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))
+LambdaConv21.java:36:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv22.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  inner class translator fails with spurious method clash errors
+ * @compile LambdaConv22.java
+ */
+
+class LambdaConv22<U> {
+
+    interface Factory<T> { T make(); }
+
+    U make() { return null; }
+
+    void test(U u) {
+        Factory<U> fu1 = () -> u;
+        Factory<U> fu2 = this::make;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv23.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check super varargs reference is handled correctly
+ * @run main LambdaConv23
+ */
+public class LambdaConv23 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM { void m(Integer a, Integer b); }
+
+    static class Super {
+        void m(Object... vi) { assertTrue(true); }
+    }
+
+
+    static class Sub extends Super {
+
+        void m(Object... vi) { assertTrue(false); }
+
+        public void test() {
+            SAM q = super::m;
+            q.m(1, 2);
+        }
+    }
+
+    public static void main(String[] args) {
+        new Sub().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConv24.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda inside 'this' call is handled properly
+ * @run main LambdaConv24
+ */
+public class LambdaConv24 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<X> {
+        boolean m(X x);
+    }
+
+    LambdaConv24(SAM<String> p) {
+        assertTrue(p.m("42"));
+    }
+
+    LambdaConv24(int i) {
+        this(s->true);
+    }
+
+    LambdaConv24(int i1, int i2) {
+        this(LambdaConv24::m);
+    }
+
+    static boolean m(String s) { return true; }
+
+    public static void main(String[] args) {
+        new LambdaConv24(1);
+        new LambdaConv24(1,2);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaConversionTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,246 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  perform several automated checks in lambda conversion, esp. around accessibility
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConversionTest
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class LambdaConversionTest {
+
+    enum PackageKind {
+        NO_PKG(""),
+        PKG_A("a");
+
+        String pkg;
+
+        PackageKind(String pkg) {
+            this.pkg = pkg;
+        }
+
+        String getPkgDecl() {
+            return this == NO_PKG ?
+                "" :
+                "package " + pkg + ";";
+        }
+
+        String getImportStat() {
+            return this == NO_PKG ?
+                "" :
+                "import " + pkg + ".*;";
+        }
+    }
+
+    enum SamKind {
+        CLASS("public class Sam {  }"),
+        ABSTACT_CLASS("public abstract class Sam {  }"),
+        ANNOTATION("public @interface Sam {  }"),
+        ENUM("public enum Sam { }"),
+        INTERFACE("public interface Sam { \n #METH; \n }");
+
+        String sam_str;
+
+        SamKind(String sam_str) {
+            this.sam_str = sam_str;
+        }
+
+        String getSam(String methStr) {
+            return sam_str.replaceAll("#METH", methStr);
+        }
+    }
+
+    enum ModifierKind {
+        PUBLIC("public"),
+        PACKAGE("");
+
+        String modifier_str;
+
+        ModifierKind(String modifier_str) {
+            this.modifier_str = modifier_str;
+        }
+
+        boolean stricterThan(ModifierKind that) {
+            return this.ordinal() > that.ordinal();
+        }
+    }
+
+    enum TypeKind {
+        EXCEPTION("Exception"),
+        PKG_CLASS("PackageClass");
+
+        String typeStr;
+
+        private TypeKind(String typeStr) {
+            this.typeStr = typeStr;
+        }
+    }
+
+    enum MethodKind {
+        NONE(""),
+        NON_GENERIC("public #R m(#ARG s) throws #T;"),
+        GENERIC("public <X> #R m(#ARG s) throws #T;");
+
+        String methodTemplate;
+
+        private MethodKind(String methodTemplate) {
+            this.methodTemplate = methodTemplate;
+        }
+
+        String getMethod(TypeKind retType, TypeKind argType, TypeKind thrownType) {
+            return methodTemplate.replaceAll("#R", retType.typeStr).
+                    replaceAll("#ARG", argType.typeStr).
+                    replaceAll("#T", thrownType.typeStr);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        for (PackageKind samPkg : PackageKind.values()) {
+            for (ModifierKind modKind : ModifierKind.values()) {
+                for (SamKind samKind : SamKind.values()) {
+                    for (MethodKind meth : MethodKind.values()) {
+                        for (TypeKind retType : TypeKind.values()) {
+                            for (TypeKind argType : TypeKind.values()) {
+                                for (TypeKind thrownType : TypeKind.values()) {
+                                    new LambdaConversionTest(samPkg, modKind, samKind,
+                                            meth, retType, argType, thrownType).test();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    PackageKind samPkg;
+    ModifierKind modKind;
+    SamKind samKind;
+    MethodKind meth;
+    TypeKind retType;
+    TypeKind argType;
+    TypeKind thrownType;
+
+    SourceFile samSourceFile = new SourceFile("Sam.java", "#P \n #C") {
+        public String toString() {
+            return template.replaceAll("#P", samPkg.getPkgDecl()).
+                    replaceAll("#C", samKind.getSam(meth.getMethod(retType, argType, thrownType)));
+        }
+    };
+
+    SourceFile pkgClassSourceFile = new SourceFile("PackageClass.java",
+                                                   "#P\n #M class PackageClass extends Exception { }") {
+        public String toString() {
+            return template.replaceAll("#P", samPkg.getPkgDecl()).
+                    replaceAll("#M", modKind.modifier_str);
+        }
+    };
+
+    SourceFile clientSourceFile = new SourceFile("Client.java",
+                                                 "#I\n class Client { Sam s = x -> null; }") {
+        public String toString() {
+            return template.replaceAll("#I", samPkg.getImportStat());
+        }
+    };
+
+    LambdaConversionTest(PackageKind samPkg, ModifierKind modKind, SamKind samKind,
+            MethodKind meth, TypeKind retType, TypeKind argType, TypeKind thrownType) {
+        this.samPkg = samPkg;
+        this.modKind = modKind;
+        this.samKind = samKind;
+        this.meth = meth;
+        this.retType = retType;
+        this.argType = argType;
+        this.thrownType = thrownType;
+    }
+
+    void test() throws Exception {
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, dc,
+                null, null, Arrays.asList(samSourceFile, pkgClassSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkSamConversion()) {
+            throw new AssertionError(samSourceFile + "\n\n" + pkgClassSourceFile + "\n\n" + clientSourceFile);
+        }
+    }
+
+    boolean checkSamConversion() {
+        if (samKind != SamKind.INTERFACE) {
+            //sam type must be an interface
+            return false;
+        } else if (meth != MethodKind.NON_GENERIC) {
+            //target method must be non-generic
+            return false;
+        } else if (samPkg != PackageKind.NO_PKG &&
+                modKind != ModifierKind.PUBLIC &&
+                (retType == TypeKind.PKG_CLASS ||
+                argType == TypeKind.PKG_CLASS ||
+                thrownType == TypeKind.PKG_CLASS)) {
+            //target must not contain inaccessible types
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,60 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Integrate efectively final check with DA/DU analysis
+ * @compile/fail/ref=LambdaEffectivelyFinalTest.out -XDrawDiagnostics LambdaEffectivelyFinalTest.java
+ */
+class LambdaEffectivelyFinalTest {
+
+    interface SAM {
+        int m();
+    }
+
+    void foo(LambdaEffectivelyFinalTest.SAM s) { }
+
+    void m1(int x) {
+        int y = 1;
+        foo(() -> x+y); // Legal: x and y are both effectively final.
+    }
+
+    void m2(int x) {
+        int y;
+        y = 1;
+        foo(() -> x+y); // Legal: x and y are both effectively final.
+    }
+
+    void m3(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        foo(() -> x+y); // Illegal: y is effectively final, but not definitely assigned.
+    }
+
+    void m4(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        else y = 2;
+        foo(() -> x+y); // Legal: x and y are both effectively final.
+    }
+
+    void m5(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        y = 2;
+        foo(() -> x+y); // Illegal: y is not effectively final.t EF
+    }
+
+    void m6(int x) {
+        foo(() -> x+1);
+        x++; // Illegal: x is not effectively final.
+    }
+
+    void m7(int x) {
+        foo(() -> x=1); // Illegal: x in the assignment does not denote a variable (see 6.5.6.1)
+    }
+
+    void m8() {
+        int y;
+        foo(() -> y=1); // Illegal: y in the assignment does not denote a variable (see 6.5.6.1)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,6 @@
+LambdaEffectivelyFinalTest.java:30:21: compiler.err.var.might.not.have.been.initialized: y
+LambdaEffectivelyFinalTest.java:44:21: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:48:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:53:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:58:19: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for simple lambda expressions in multiple scopes
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaExpr01
+ */
+
+public class LambdaExpr01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface S_int {
+        int m();
+    }
+
+    interface S_Integer {
+        Integer m();
+    }
+
+    interface S_int_int {
+        int m(int i);
+    }
+
+    interface S_Integer_int {
+        int m(Integer i);
+    }
+
+    interface S_int_Integer {
+        Integer m(int i);
+    }
+
+    interface S_Integer_Integer {
+        Integer m(Integer i);
+    }
+
+    static {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    static void test1() {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    void test2() {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaExpr01().test2();
+        assertTrue(assertionCount == 24);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for simple lambda expressions in multiple scopes
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaExpr01
+ */
+
+public class LambdaExpr02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface S_int {
+        int m();
+    }
+
+    interface S_Integer {
+        Integer m();
+    }
+
+    interface S_int_int {
+        int m(int i);
+    }
+
+    interface S_Integer_int {
+        int m(Integer i);
+    }
+
+    interface S_int_Integer {
+        Integer m(int i);
+    }
+
+    interface S_Integer_Integer {
+        Integer m(Integer i);
+    }
+
+    static {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    static void test1() {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    void test2() {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaExpr02().test2();
+        assertTrue(assertionCount == 24);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr04.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda initializers compile w/o problems
+ * @author Jan Lahoda
+ * @author  Maurizio Cimadamore
+ * @compile LambdaExpr04.java
+ */
+
+class LambdaExpr04 {
+
+    interface SAM {
+        void m(int i);
+    }
+    static SAM lambda_01 = (int pos) -> { };
+
+    static final SAM lambda_02 = (int pos) -> { };
+
+    SAM lambda_03 = (int pos) -> { };
+
+    final SAM lambda_04 = (int pos) -> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr05.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that binary expression in lambda expression is parsed correctly
+ * @author  Maurizio Cimadamore
+ * @compile LambdaExpr05.java
+ */
+
+class LambdaExpr05 {
+
+    interface SAM { int foo(int i); }
+
+    SAM s1 = i -> i * 2;
+    SAM s2 = i -> 2 * i;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr06.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  parser test for nested parenthesized lambda expression
+ * @run main LambdaExpr06
+ */
+
+public class LambdaExpr06 {
+
+    static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A {
+        int m();
+    }
+
+    interface B {
+        int dup(int i);
+    }
+
+    public static void main(String[] args) {
+        A a = ()-> ((B)i -> i * 2).dup(3);
+        assertTrue(a.m() == 6);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr07.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check access to effectively final local variable from doubly nested lambda
+ * @run main LambdaExpr07
+ */
+
+public class LambdaExpr07 {
+
+    interface Block<A, R> {
+        R apply(A x);
+    }
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    String S = "A";
+
+    void test() {
+        Block<String, Block<String, String>> o = s1 -> s2 -> S + s1 + s2;
+        assertTrue(o.apply("B").apply("C").equals("ABC"));
+    }
+
+    public static void main(String[] args) {
+        new LambdaExpr07().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr08.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that reference to local final variable w/o initializer is accepted
+ * @compile LambdaExpr08.java
+ */
+
+class LambdaExpr08 {
+
+    interface SAM {
+       String m();
+    }
+
+    void test() {
+        final String s;
+        s = "";
+        SAM sam = () -> s;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr09.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda in array initializers is correctly accepted
+ * @compile LambdaExpr09.java
+ */
+
+class LambdaExpr09 {
+
+    interface Block<T> {
+       void m(T t);
+    }
+
+    void apply(Object[] obj_arr) { }
+
+    void test1() {
+        Block<?>[] arr1 =  { t -> { }, t -> { } };
+        Block<?>[][] arr2 =  { { t -> { }, t -> { } }, { t -> { }, t -> { } } };
+    }
+
+    void test2() {
+        Block<?>[] arr1 =  new Block<?>[]{ t -> { }, t -> { } };
+        Block<?>[][] arr2 =  new Block<?>[][]{ { t -> { }, t -> { } }, { t -> { }, t -> { } } };
+    }
+
+    void test3() {
+        apply(new Block<?>[]{ t -> { }, t -> { } });
+        apply(new Block<?>[][]{ { t -> { }, t -> { } }, { t -> { }, t -> { } } });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr10.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,37 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda in array initializers (with wrong type) are correctly rejected
+ * @compile/fail/ref=LambdaExpr10.out -XDrawDiagnostics LambdaExpr10.java
+ */
+
+class LambdaExpr10 {
+
+    interface Block<T> {
+       void m(T t);
+    }
+
+    void apply(Object[] obj_arr) { }
+
+    void test1() {
+        Object[] arr1 =  { t -> { } };
+        Object[][] arr2 =  { { t -> { } } };
+    }
+
+    void test2() {
+        Object[] arr1 =  new Object[]{ t -> { } };
+        Object[][] arr2 =  new Object[][]{ { t -> { } } };
+    }
+
+    void test3() {
+        apply(new Object[]{ t -> { } });
+        apply(new Object[][]{ { t -> { } } });
+    }
+
+    void test4() {
+        Block<?>[] arr1 =  { t -> t };
+        Block<?>[] arr2 =  new Block<?>[]{ t -> t };
+        apply(new Block<?>[]{ t -> { }, t -> { } });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr10.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,9 @@
+LambdaExpr10.java:18:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:19:32: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:23:40: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:24:46: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:28:29: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:29:33: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:33:35: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
+LambdaExpr10.java:34:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
+8 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr11.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that creating an inner class from a lambda does add a captured this
+ * @run main LambdaExpr11
+ */
+public class LambdaExpr11 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    class Inner {
+        Inner() { assertTrue(true); }
+    }
+
+    void test() {
+        Runnable r1 = ()-> { new Inner(); };
+        r1.run();
+        Runnable r2 = ()-> { new Inner() {}; };
+        r2.run();
+        Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); };
+        r3.run();
+        Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; };
+        r4.run();
+        new Inner2().test();
+    }
+
+    class Inner2 {
+        void test() {
+            Runnable r1 = ()-> { new Inner(); };
+            r1.run();
+            Runnable r2 = ()-> { new Inner() {}; };
+            r2.run();
+            Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); };
+            r3.run();
+            Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; };
+            r4.run();
+            new Inner3().test();
+        }
+
+        class Inner3 {
+            void test() {
+                Runnable r1 = ()-> { new Inner(); };
+                r1.run();
+                Runnable r2 = ()-> { new Inner() {}; };
+                r2.run();
+                Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); };
+                r3.run();
+                Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; };
+                r4.run();
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        new LambdaExpr11().test();
+        assertTrue(assertionCount == 12);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr12.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that creating an inner class from a lambda does add a captured this
+ * @run main LambdaExpr12
+ */
+
+public class LambdaExpr12 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Getter<X> {
+        X get();
+    }
+
+
+    interface Mapper<X,Y> {
+        Y map(X x);
+    }
+
+    void test() {
+        Mapper<String, Getter<Character>> mapper =
+                (final String s) -> new Getter<Character>() {
+                     @Override
+                     public Character get() {
+                         return s.charAt(0);
+                     }
+                };
+        assertTrue(mapper.map("First").get() == 'F');
+    }
+
+    public static void main(String[] args) {
+        new LambdaExpr12().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr13.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that recursive lambda (through field ref) is accepted in all contexts
+ * @compile LambdaExpr13.java
+ */
+
+class LambdaExpr13 {
+
+    Runnable ir = () -> { ir.run(); };;
+    static Runnable sr = () -> { sr.run(); };
+
+    { ir = () -> { ir.run(); }; }
+    static { sr = () -> { sr.run(); }; }
+
+    static void m1() {
+        sr = () -> { sr.run(); };
+    }
+
+    void m2() {
+        ir = () -> { ir.run(); };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr14.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that recursion from doubly nested lambda is handled correctly
+ */
+
+public class LambdaExpr14 {
+
+    interface SAM {
+       SAM invoke();
+    }
+
+    static SAM local;
+
+    public static void main(String[] args) {
+        local = () -> () -> local.invoke();
+        local.invoke().invoke(); // Not a recursive lambda - exec should terminate
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr15.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, 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
+ * @ignore investigate as to whether code generation fails
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that nested inner class in statement lambdas don't get corrupted return statements
+ * @run main LambdaExpr15
+ */
+public class LambdaExpr15 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Block<T> {
+       void apply(T t);
+    }
+
+    public static void main(String[] args) {
+        //anon class
+        Block<Object> ba1 = t -> {
+            new Object() {
+                String get() { return ""; }
+            };
+            assertTrue(t == 1);
+        };
+        ba1.apply(1);
+
+        //local class
+        Block<Object> ba2 = t -> {
+            class A {
+                String get() { return ""; }
+            };
+            new A();
+            assertTrue(t == 2);
+        };
+        ba2.apply(2);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr16.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that super inside lambda is handled correctly
+ * @run main LambdaExpr16
+ */
+public class LambdaExpr16 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A { void m(); }
+
+    static class Sup {
+       void m() {
+          assertTrue(true);
+       }
+    }
+
+    static class Sub extends Sup {
+        void testLambda1() {
+            A a = ()->{ super.m(); };
+            a.m();
+        }
+        void testLambda2() {
+            A a = () -> { A a1 = () -> { super.m(); }; a1.m(); };
+            a.m();
+        }
+        void testRef1() {
+            A a = () -> { A a1 = super::m; a1.m(); };
+            a.m();
+        }
+        void testRef2() {
+            A a = () -> { A a1 = () -> { A a2 = super::m; a2.m(); }; a1.m(); };
+            a.m();
+        }
+    }
+
+   public static void main(String[] args) {
+      Sub s = new Sub();
+      s.testLambda1();
+      s.testLambda2();
+      s.testRef1();
+      s.testRef2();
+      assertTrue(assertionCount == 4);
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr17.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that super in argument position inside lambda is handled correctly
+ * @run main LambdaExpr17
+ */
+public class LambdaExpr17 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    static class Sup {
+        protected String m() {
+            assertTrue(true);
+            return "Hello!";
+        }
+    }
+
+    static class Sub extends Sup {
+        void test() {
+            SAM s = () -> { System.out.println(super.m()); };
+            s.m();
+        }
+    }
+
+    public static void main(String[] args) {
+        new Sub().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr18.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that synthetic casts from outer environment are not inserted twice
+ * @run main LambdaExpr18
+ */
+public class LambdaExpr18 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<R> {
+        R eval();
+    }
+
+    static void test(){
+        SAM<Integer> sam1 = () -> {
+            assertTrue(true);
+            SAM<String> sam2 = () -> {
+                assertTrue(true);
+                return "";
+            };
+            sam2.eval();
+            return 1;
+        };
+        sam1.eval();
+    }
+
+    public static void main(String[] args) {
+        test();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr19.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,53 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that inner scopes are left after a lambda check exception has been thrown
+ * @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java
+ */
+class LambdaExpr19 {
+
+    interface SAM {
+        String m();
+    }
+
+    void m(SAM s) { }
+
+    void testTry() {
+        m(() -> {
+                try { return 1; }
+                catch (Exception e) { }
+            });
+    }
+
+    void testTryWithResources() {
+        m(() -> {
+                try (AutoCloseable c = null) { return 1; }
+                catch (Exception e) { }
+            });
+    }
+
+    void testSwitch() {
+        m(() -> {
+                switch (1) {
+                    default: return 1;
+                }
+            });
+    }
+
+    void testFor() {
+        m(() -> {
+                for (;;) {
+                    return 1;
+                }
+            });
+    }
+
+    void testForeach() {
+        m(() -> {
+                for (Object o : new Object[] { null , null }) {
+                    return 1;
+                }
+            });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr19.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,6 @@
+LambdaExpr19.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @363, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:24:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @512, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:31:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @676, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:39:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @824, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:47:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @965, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExpr20.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that default super call from lambda expression is compiled successfully
+ * @compile LambdaExpr20.java
+ */
+
+class LambdaExpr20 {
+
+    interface K {
+        default void m() { }
+    }
+
+    static class Test implements K {
+        @Override
+        public void m() {
+            Runnable r = () -> { K.super.m(); };
+            r.run();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda expression body (when not a block) cannot be void
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=LambdaExprNotVoid.out -XDlambdaInferenceDiags=false -XDrawDiagnostics LambdaExprNotVoid.java
+ */
+
+class LambdaExpr05 {
+
+    interface SAM { void foo(int i); }
+
+    SAM s1 = i -> i * 2;
+    SAM s2 = i -> 2 * i;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaExprNotVoid.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+LambdaExprNotVoid.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+LambdaExprNotVoid.java:15:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+2 errors
--- a/langtools/test/tools/javac/lambda/LambdaParserTest.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaParserTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,9 @@
 /*
  * @test
  * @bug 7115050
- * @summary Add parser support for lambda expressions
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Add parser support for lambda expressions
  */
 
 import com.sun.source.util.JavacTask;
@@ -234,7 +236,7 @@
 
     void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
         JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                Arrays.asList("-XDallowLambda"), null, Arrays.asList(source));
+                null, null, Arrays.asList(source));
         try {
             ct.parse();
         } catch (Throwable ex) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaScope01
+ */
+
+public class LambdaScope01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    public int n = 5;
+
+    public int hashCode() {
+        throw new RuntimeException();
+    }
+
+    public void test1() {
+        try {
+            int res = LambdaScope01.<Integer,Integer>exec((Integer x) -> x * hashCode(), 3);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true); //should throw
+        }
+    }
+
+    public void test2() {
+        final int n = 10;
+        int res = LambdaScope01.<Integer,Integer>exec((Integer x) -> x + n, 3);
+        assertTrue(13 == res);
+    }
+
+    public static void main(String[] args) {
+        LambdaScope01 t = new LambdaScope01();
+        t.test1();
+        t.test2();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that Object members are accessible as expected
+ * @author  Maurizio Cimadamore
+ * @run main LambdaScope02
+ */
+
+public class LambdaScope02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    @Override
+    public String toString() {
+        return "Callable1";
+    }
+
+    interface Callable {
+        void call();
+    }
+
+    static void call(Callable c) { c.call(); }
+
+    void test() {
+        call(()-> { assertTrue(LambdaScope02.this.toString().equals("Callable1")); });
+        call(()-> { assertTrue(toString().equals("Callable1")); });
+    }
+
+    public static void main(String[] args) {
+        new LambdaScope02().test();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that unqualified Object members are accessed as expected
+ * @author  Maurizio Cimadamore
+ * @run main LambdaScope03
+ */
+
+public class LambdaScope03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    static void call(SAM s) { s.m(); }
+
+    void test() {
+        call(()-> { assertTrue(LambdaScope03.this.getClass().equals(getClass())); });
+        call(()-> { assertTrue(LambdaScope03.this.getClass().equals(this.getClass())); });
+        call(()-> { assertTrue(LambdaScope03.this.hashCode() == hashCode()); });
+        call(()-> { assertTrue(LambdaScope03.this.hashCode() == this.hashCode()); });
+        call(()-> { assertTrue(LambdaScope03.this.toString().equals(toString())); });
+        call(()-> { assertTrue(LambdaScope03.this.toString().equals(this.toString())); });
+        call(()-> { assertTrue(LambdaScope03.this.equals(this)); });
+        call(()-> { assertTrue(equals(LambdaScope03.this)); });
+    }
+
+    public static void main(String[] args) {
+        new LambdaScope03().test();
+        assertTrue(assertionCount == 8);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope04.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,163 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda cannot shadow variables from enclosing scope
+ * @compile/fail/ref=LambdaScope04.out -XDrawDiagnostics LambdaScope04.java
+ */
+
+class LambdaScope04 {
+
+    interface SAM {
+        void m(Object o);
+    }
+
+    static SAM field1 = field1->{}; //ok
+    static SAM field2 = param->{ Object field2 = null; }; //ok
+
+    SAM field3 = field3->{}; //ok
+    SAM field4 = param->{ Object field4 = null; }; //ok
+
+    {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+    }
+
+    static {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    void testLocalInstance() {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    static void testLocalStatic() {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    void testParamInstance(Object local) {
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    static void testParamStatic(Object local) {
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    void testForInstance() {
+        for (int local = 0; local != 0 ; local++) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testForStatic(Iterable<Object> elems) {
+        for (int local = 0; local != 0 ; local++) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testForEachInstance(Iterable<Object> elems) {
+        for (Object local : elems) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testForEachStatic(Iterable<Object> elems) {
+        for (Object local : elems) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testCatchInstance() {
+        try { } catch (Throwable local) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testCatchStatic(Iterable<Object> elems) {
+        try { } catch (Throwable local) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testTWRInstance(AutoCloseable res) {
+        try (AutoCloseable local = res) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        } finally { }
+    }
+
+    static void testTWRStatic(AutoCloseable res) {
+        try (AutoCloseable local = res) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        } finally { }
+    }
+
+    void testBlockLocalInstance() {
+        Object local = null;
+        {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testBlockLocalStatic() {
+        Object local = null;
+        {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testSwitchLocalInstance(int i) {
+        switch (i) {
+            case 0: Object local = null;
+            default: {
+                SAM s1 = local->{}; //error
+                SAM s2 = param->{ Object local = null; }; //error
+                SAM s3 = field1->{ Object field_2 = null; }; //ok
+            }
+        }
+    }
+
+    static void testSwitchLocalStatic(int i) {
+        switch (i) {
+            case 0: Object local = null;
+            default: {
+                SAM s1 = local->{}; //error
+                SAM s2 = param->{ Object local = null; }; //error
+                SAM s3 = field1->{ Object field_2 = null; }; //ok
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaScope04.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,37 @@
+LambdaScope04.java:23:18: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.instance.init, kindname.class, LambdaScope04
+LambdaScope04.java:24:34: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.instance.init, kindname.class, LambdaScope04
+LambdaScope04.java:29:18: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.static.init, kindname.class, LambdaScope04
+LambdaScope04.java:30:34: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.static.init, kindname.class, LambdaScope04
+LambdaScope04.java:36:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalInstance()
+LambdaScope04.java:37:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalInstance()
+LambdaScope04.java:43:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalStatic()
+LambdaScope04.java:44:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalStatic()
+LambdaScope04.java:49:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamInstance(java.lang.Object)
+LambdaScope04.java:50:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamInstance(java.lang.Object)
+LambdaScope04.java:55:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamStatic(java.lang.Object)
+LambdaScope04.java:56:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamStatic(java.lang.Object)
+LambdaScope04.java:62:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForInstance()
+LambdaScope04.java:63:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForInstance()
+LambdaScope04.java:70:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:71:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:78:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachInstance(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:79:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachInstance(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:86:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:87:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:94:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchInstance()
+LambdaScope04.java:95:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchInstance()
+LambdaScope04.java:102:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:103:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:110:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRInstance(java.lang.AutoCloseable)
+LambdaScope04.java:111:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRInstance(java.lang.AutoCloseable)
+LambdaScope04.java:118:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRStatic(java.lang.AutoCloseable)
+LambdaScope04.java:119:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRStatic(java.lang.AutoCloseable)
+LambdaScope04.java:127:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalInstance()
+LambdaScope04.java:128:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalInstance()
+LambdaScope04.java:136:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalStatic()
+LambdaScope04.java:137:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalStatic()
+LambdaScope04.java:146:26: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalInstance(int)
+LambdaScope04.java:147:42: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalInstance(int)
+LambdaScope04.java:157:26: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalStatic(int)
+LambdaScope04.java:158:42: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalStatic(int)
+36 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LocalBreakAndContinue.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that local break/continue is allowed in lambda expressions
+ * @author  Maurizio Cimadamore
+ * @compile LocalBreakAndContinue.java
+ */
+
+class LocalBreakAndContinue {
+
+    static interface SAM {
+       void m();
+    }
+
+    SAM s1 = ()-> { while (true) break; };
+    SAM s2 = ()-> { while (true) continue; };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  use method reference to sort list elements by field
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference01
+ */
+
+import java.util.*;
+
+public class MethodReference01 {
+
+    interface Getter<U, T> {
+        public U get(T t);
+    }
+
+    static class Foo {
+        private Integer a;
+        private String b;
+
+        Foo(Integer a, String b) {
+            this.a = a;
+            this.b = b;
+        }
+
+        static Integer getA(Foo f) { return f.a; }
+        static String getB(Foo f) { return f.b; }
+    }
+
+    public static <T, U extends Comparable<? super U>>
+           void sortBy(List<T> s, final Getter<U, T> getter) {
+        Collections.sort(s, new Comparator<T>() {
+            public int compare(T t1, T t2) {
+                return getter.get(t1).compareTo(getter.get(t2));
+            }
+        });
+    };
+
+    public static void main(String[] args) {
+        List<Foo> c = new ArrayList<Foo>();
+        c.add(new Foo(2, "Hello3!"));
+        c.add(new Foo(3, "Hello1!"));
+        c.add(new Foo(1, "Hello2!"));
+        checkSortByA(c);
+        checkSortByB(c);
+    }
+
+    static void checkSortByA(List<Foo> l) {
+        sortBy(l, Foo::getA);
+        int oldA = -1;
+        for (Foo foo : l) {
+            if (foo.a.compareTo(oldA) < 1) {
+                throw new AssertionError();
+            }
+        }
+    }
+
+    static void checkSortByB(List<Foo> l) {
+        sortBy(l, Foo::getB);
+        String oldB = "";
+        for (Foo foo : l) {
+            if (foo.b.compareTo(oldB) < 1) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that seemingly ambiguous method references are resolved properly
+ * @author  Maurizio Cimadamore
+ * @compile MethodReference02.java
+ */
+
+class MethodReference02 {
+    static interface SAM {
+       void m(Integer i);
+    }
+
+    void m(Integer i) {}
+    void m(Double d) {}
+
+    SAM s = this::m; //use target type to disambiguate
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that most specific method is selected as expected
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference03
+ */
+
+public class MethodReference03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+       void m(Integer i);
+    }
+
+    static void m(Number i) {}
+    static void m(Integer d) { assertTrue(true); }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference03::m;
+        s.m(1);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference04.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that target type of a method ref is a SAM type
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference04.out -XDrawDiagnostics MethodReference04.java
+ */
+
+class MethodReference04 {
+    void m(Integer i) {}
+
+    Object o = this::m; //fail - not a valid target type
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference04.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MethodReference04.java:13:16: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference05.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-static method refernces from static context are handled correctly
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference05
+ */
+
+public class MethodReference05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+       void m(MethodReference05 receiver, Integer i);
+    }
+
+    void m(Integer i) { assertTrue(this != null); }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference05::m;
+        s.m(new MethodReference05(), 1);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference06.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  method references and super
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference06
+ */
+
+public class MethodReference06 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM { //works if SAM is an abstract class
+        abstract void meth(int i);
+    }
+
+    static class A {
+        void m(int i) { assertTrue(true); }
+    }
+
+    static class B extends A {
+        void m(int i) {
+            SAM mh = super::m;
+            mh.meth(i);
+        }
+    }
+
+    public static void main(String[] args) {
+        new B().m(10);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference07.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that syntax for selecting generic receiver works
+ * @author  Maurizio Cimadamore
+ * @compile MethodReference07.java
+ */
+
+class MethodReference07 {
+    interface SAM {
+       String m(Foo<String> f);
+    }
+
+    static class Foo<X> {
+       String getX() { return null; }
+
+       static void test() {
+          SAM s = Foo<String>::getX;
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference08.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that syntax for selecting generic receiver works
+ * @author  Maurizio Cimadamore
+ *
+ * @compile MethodReference08.java
+ * @compile/fail/ref=MethodReference08.out -Werror -Xlint:rawtypes -XDrawDiagnostics MethodReference08.java
+ */
+
+class MethodReference08 {
+    interface SAM {
+       String m(Foo f);
+    }
+
+    static class Foo<X> {
+       String getX() { return null; }
+
+       static void test() {
+          SAM s = Foo::getX;
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference08.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+MethodReference08.java:14:17: compiler.warn.raw.class.use: MethodReference08.Foo, MethodReference08.Foo<X>
+MethodReference08.java:21:19: compiler.warn.raw.class.use: MethodReference08.Foo, MethodReference08.Foo<X>
+- compiler.err.warnings.and.werror
+1 error
+2 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference09.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non static members cannot be referenced from a method reference qualifier
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference09.out -XDrawDiagnostics MethodReference09.java
+ */
+
+class MethodReference09 {
+    interface SAM {
+       String m(Foo f);
+    }
+
+    static class Foo<X> {
+       String getX() { return null; }
+
+       Foo<X> getThis() { return this; }
+
+       static void test() {
+          SAM s1 = Foo.getThis()::getX;
+          SAM s2 = this::getX;
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference09.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,4 @@
+MethodReference09.java:21:23: compiler.err.non-static.cant.be.ref: kindname.method, getThis()
+MethodReference09.java:21:20: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, getX, compiler.misc.no.args, MethodReference09.Foo, kindname.class, MethodReference09.Foo<X>, (compiler.misc.arg.length.mismatch)))
+MethodReference09.java:22:20: compiler.err.non-static.cant.be.ref: kindname.variable, this
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference10.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that non static selectors in method refs are handled correctly
+ * @author  Maurizio Cimadamore
+ * @compile MethodReference10.java
+ */
+
+import java.util.*;
+
+class MethodReference10 {
+
+    interface Getter<U, T> {
+        public U get(T t);
+    }
+
+    public static <T, U extends Comparable<? super U>>
+        void sortBy(Collection<T> s, Getter<U, T> getter) {};
+
+    static class Foo {
+        private String a;
+        String getA(Foo f) { return f.a; }
+    }
+
+    public static void main(String[] args) {
+        Collection<Foo> c = new ArrayList<Foo>();
+        sortBy(c, new Foo()::getA);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference11.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that static vs. non-static selection logic in method references works
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference11
+ */
+
+import java.util.*;
+
+public class MethodReference11 {
+    public static void main(String[] args) {
+        String[] strings = new String[] { "D", "C", "B", "A" };
+        Arrays.sort( strings, String.CASE_INSENSITIVE_ORDER::compare );
+        String last = "1";
+        for (String s : strings) {
+            if (String.CASE_INSENSITIVE_ORDER.compare(last, s) > 0) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference12.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that Object methods are dispatched accordingly
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference12
+ */
+
+public class MethodReference12 {
+
+    interface SAM { void foo(int i); }
+
+    static void print(int i) {
+        System.out.println(i);
+    }
+
+    public static void main(String[] args) {
+        try {
+            test(MethodReference12::print);
+            test(i -> { System.out.println(i); } );
+        }
+        catch (Throwable t) {
+            t.printStackTrace();
+            throw new AssertionError("An error occurred");
+        }
+    }
+
+    static void test(SAM s) throws Throwable {
+        s.hashCode();
+        s.equals(null);
+        s.toString();
+        try {
+            s.notify(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException e) {  }
+        try {
+            s.notifyAll(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException e) {  }
+        try {
+            s.wait(1); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+        try {
+            s.wait(1,1); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+        try {
+            s.wait(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference13.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that equals() on Proxied objects is handled accordingly
+ * @author  Maurizio Cimadamore
+ * @compile -XDuseProxy MethodReference13.java
+ * @run main MethodReference13
+ */
+
+public class MethodReference13 {
+
+    static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    static void m() { }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference13::m;
+        assertTrue(s.equals(s));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference14.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check casting a method reference to a SAM type does not result in a CCE
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference14
+ */
+
+public class MethodReference14 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    interface SAM {
+        void m();
+    }
+
+    static void m() { assertTrue(true); }
+
+    public static void main(String[] args) {
+        SAM s = (SAM)MethodReference14::m;
+        s.m();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference15.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that assignments involving method references do not trigger transitional 292 warnings
+ * @author  Maurizio Cimadamore
+ * @compile -Werror MethodReference15.java
+ */
+
+public class MethodReference15 {
+
+    interface SAM {
+        void m();
+    }
+
+    static void m() { }
+
+    static void test() {
+        SAM s = MethodReference15::m;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference16.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  semantics of statically qualified method reference should not depend on the context
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference16
+ */
+
+public class MethodReference16 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    interface SAM {
+        void m(MethodReference16 receiver);
+    }
+
+    void m() { assertTrue(true); }
+
+    void test() {
+        SAM s = (SAM)MethodReference16::m;
+        s.m(this);
+    }
+
+    public static void main(String[] args) {
+        MethodReference16 rec = new MethodReference16();
+        SAM s = (SAM)MethodReference16::m;
+        s.m(rec);
+        rec.test();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference17.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference17
+ */
+
+public class MethodReference17 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    MethodReference17() {
+        assertTrue(true);
+    }
+
+    interface SAM {
+        MethodReference17 m();
+    }
+
+    static void test(SAM s) {
+        s.m();
+    }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference17::new;
+        s.m();
+        test(MethodReference17::new);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference18.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference18
+ */
+
+public class MethodReference18 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    MethodReference18(Object o) {
+        assertTrue(true);
+    }
+
+    MethodReference18(Number n) {
+        assertTrue(false);
+    }
+
+    interface SAM {
+        MethodReference18 m(Object o);
+    }
+
+    static void test(SAM s, Object arg) {
+        s.m(arg);
+    }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference18::new;
+        s.m("");
+        test(MethodReference18::new, "");
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference19.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references and generic classes
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference19
+ */
+
+public class MethodReference19<X> {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    MethodReference19(X x) {
+        assertTrue(true);
+    }
+
+    interface SAM<Z> {
+        MethodReference19<Z> m(Z z);
+    }
+
+    static <Y> void test(SAM<Y> s, Y arg) {
+        s.m(arg);
+    }
+
+    public static void main(String[] args) {
+        SAM<String> s = MethodReference19<String>::new;
+        s.m("");
+        test(MethodReference19<String>::new, "");
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference20.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references and generic classes
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference20.out -XDrawDiagnostics MethodReference20.java
+ */
+
+class MethodReference20<X> {
+
+    MethodReference20(X x) { }
+
+    interface SAM<Z> {
+        MethodReference20<Z> m(Z z);
+    }
+
+    static void test(SAM<Integer> s) {   }
+
+    public static void main(String[] args) {
+        SAM<Integer> s = MethodReference20<String>::new;
+        test(MethodReference20<String>::new);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference20.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+MethodReference20.java:21:26: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, MethodReference20, java.lang.String, java.lang.Integer, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String))))
+MethodReference20.java:22:9: compiler.err.cant.apply.symbol: kindname.method, test, MethodReference20.SAM<java.lang.Integer>, @549, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, MethodReference20, java.lang.String, java.lang.Integer, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String)))))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference21.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that erroneous method references are flagged with errors as expected
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference21.out -XDrawDiagnostics MethodReference21.java
+ */
+
+class MethodReference21 {
+
+    interface SAM {
+        void m();
+    }
+
+    void call(SAM s) {}
+
+    SAM s = NonExistentType::m;
+
+    {
+        call(NonExistentType::m);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference21.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+MethodReference21.java:18:13: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference21, null)
+MethodReference21.java:21:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference21, null)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference22.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,67 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that pair of bound/non-bound method references checked correctly
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference22.out -XDrawDiagnostics MethodReference22.java
+ */
+
+class MethodReference22 {
+
+    void m1(String x) { }
+    void m1(MethodReference22 rec, String x) { }
+
+    static void m2(String x) { }
+    static void m2(MethodReference22 rec, String x) { }
+
+    static void m3(String x) { }
+    void m3(MethodReference22 rec, String x) { }
+
+    void m4(String x) { }
+    static void m4(MethodReference22 rec, String x) { }
+
+    interface SAM1 {
+        void m(String x);
+    }
+
+    interface SAM2 {
+        void m(MethodReference22 rec, String x);
+    }
+
+    static void call1(SAM1 s) {   }
+
+    static void call2(SAM2 s) {   }
+
+    static void call3(SAM1 s) {   }
+    static void call3(SAM2 s) {   }
+
+    static void test1() {
+        SAM1 s1 = MethodReference22::m1; //fail
+        call1(MethodReference22::m1); //fail
+        SAM1 s2 = MethodReference22::m2; //ok
+        call1(MethodReference22::m2); //ok
+        SAM1 s3 = MethodReference22::m3; //ok
+        call1(MethodReference22::m3); //ok
+        SAM1 s4 = MethodReference22::m4; //fail
+        call1(MethodReference22::m4); //fail
+    }
+
+    static void test2() {
+        SAM2 s1 = MethodReference22::m1; //ok
+        call2(MethodReference22::m1); //ok
+        SAM2 s2 = MethodReference22::m2; //ok
+        call2(MethodReference22::m2); //ok
+        SAM2 s3 = MethodReference22::m3; //fail
+        call2(MethodReference22::m3); //fail
+        SAM2 s4 = MethodReference22::m4; //fail
+        call2(MethodReference22::m4); //fail
+    }
+
+    static void test3() {
+        call3(MethodReference22::m1); //ok
+        call3(MethodReference22::m2); //ambiguous
+        call3(MethodReference22::m3); //ok
+        call3(MethodReference22::m4); //fail
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference22.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,11 @@
+MethodReference22.java:40:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)))
+MethodReference22.java:41:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @999, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))))
+MethodReference22.java:46:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)))
+MethodReference22.java:47:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @1270, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))))
+MethodReference22.java:55:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String)))
+MethodReference22.java:56:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1574, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String))))
+MethodReference22.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))
+MethodReference22.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1667, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)))
+MethodReference22.java:63:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22
+MethodReference22.java:65:9: compiler.err.cant.apply.symbols: kindname.method, call3, @1881,{(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))))),(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))))}
+10 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference23.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,74 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that pair of bound/non-bound constructor references is flagged as ambiguous
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference23.out -XDrawDiagnostics MethodReference23.java
+ */
+
+class MethodReference23 {
+
+    class Inner1 {
+        Inner1(MethodReference23 outer) {};
+        Inner1() {};
+    }
+
+    static class Inner2 {
+        Inner2(MethodReference23 outer) {};
+        Inner2() {};
+    }
+
+    interface SAM11 {
+        Inner1 m(MethodReference23 rec);
+    }
+
+    interface SAM12 {
+        Inner1 m();
+    }
+
+    interface SAM21 {
+        Inner2 m(MethodReference23 rec);
+    }
+
+    interface SAM22 {
+        Inner2 m();
+    }
+
+    static void call11(SAM11 s) {   }
+
+    static void call12(SAM12 s) {   }
+
+    static void call21(SAM21 s) {   }
+
+    static void call22(SAM22 s) {   }
+
+    static void call3(SAM11 s) {   }
+    static void call3(SAM12 s) {   }
+    static void call3(SAM21 s) {   }
+    static void call3(SAM22 s) {   }
+
+    static void test11() {
+        SAM11 s = MethodReference23.Inner1::new; //ok
+        call11(MethodReference23.Inner1::new); //ok
+    }
+
+    static void test12() {
+        SAM12 s = MethodReference23.Inner1::new; //fail
+        call12(MethodReference23.Inner1::new); //fail
+    }
+
+    static void test21() {
+        SAM21 s = MethodReference23.Inner2::new; //ok
+        call21(MethodReference23.Inner2::new); //ok
+    }
+
+    static void test22() {
+        SAM22 s = MethodReference23.Inner2::new; //ok
+        call22(MethodReference23.Inner2::new); //ok
+    }
+
+    static void test3() {
+        call3(MethodReference23.Inner2::new); //ambiguous
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference23.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,6 @@
+MethodReference23.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23))
+MethodReference23.java:53:9: compiler.err.cant.apply.symbol: kindname.method, call11, MethodReference23.SAM11, @1140, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)))
+MethodReference23.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))
+MethodReference23.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call12, MethodReference23.SAM12, @1282, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)))
+MethodReference23.java:72:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference23.SAM21), MethodReference23, kindname.method, call3(MethodReference23.SAM22), MethodReference23
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference24.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-boxing method references conversion has the precedence
+ * @run main MethodReference24
+ */
+
+public class MethodReference24 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    static void m(int i) { assertTrue(true); }
+    static void m(Integer i) { assertTrue(false); }
+
+    interface SAM {
+        void m(int x);
+    }
+
+    static void call(SAM s) { s.m(42); }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference24::m; //resolves to m(int)
+        s.m(42);
+        call(MethodReference24::m); //resolves to m(int)
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference25.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-boxing method references conversion has the precedence
+ * @run main MethodReference25
+ */
+
+public class MethodReference25 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    static void m(Integer i) { assertTrue(true); }
+
+    interface SAM1 {
+        void m(int x);
+    }
+
+    interface SAM2 {
+        void m(Integer x);
+    }
+
+    static void call(int i, SAM1 s) { s.m(i); assertTrue(false); }
+    static void call(int i, SAM2 s) { s.m(i);  }
+
+    public static void main(String[] args) {
+        call(1, MethodReference25::m); //resolves to call(int, SAM2)
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference26.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check strict method conversion does not allow loose method reference conversion
+ * @compile/fail/ref=MethodReference26.out -XDrawDiagnostics MethodReference26.java
+ */
+
+class MethodReference26 {
+
+    static void m(Integer i) { }
+
+    interface SAM {
+        void m(int x);
+    }
+
+    static void call(int i, SAM s) {   }
+    static void call(Integer i, SAM s) {   }
+
+    static void test() {
+        call(1, MethodReference26::m); //ambiguous
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference26.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MethodReference26.java:21:9: compiler.err.ref.ambiguous: call, kindname.method, call(int,MethodReference26.SAM), MethodReference26, kindname.method, call(java.lang.Integer,MethodReference26.SAM), MethodReference26
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference27.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-boxing method references conversion has the precedence
+ * @run main MethodReference27
+ */
+
+public class MethodReference27 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    interface SAM {
+        void m(int i1, int i2);
+    }
+
+    static void m1(int i1, int i2) { assertTrue(true); }
+    static void m1(Integer i1, int i2) { assertTrue(false); }
+    static void m1(int i1, Integer i2) { assertTrue(false); }
+    static void m1(Integer i1, Integer i2) { assertTrue(false); }
+    static void m1(Integer... is) { assertTrue(false); }
+
+    static void m2(int... is) { assertTrue(true); }
+    static void m2(double... ds) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        SAM s1 = MethodReference27::m1;
+        s1.m(42,42);
+        SAM s2 = MethodReference27::m2;
+        s2.m(42,42);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference28.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,56 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-compatible method references are rejected
+ * @compile/fail/ref=MethodReference28.out -XDrawDiagnostics MethodReference28.java
+ */
+
+class MethodReference28 {
+
+    interface SAM1 {
+        void m(int i);
+    }
+
+    interface SAM2 {
+        void m(MethodReference28 rec, int i);
+    }
+
+    static void static_m1(Integer i) { } //ok - boxing
+    static void static_m2(Integer i1, Integer i2) { } //wrong arity
+    static void static_m3(String s) { } //type mismatch
+    static void static_m4(String... ss) { } //type mismatch - varargs
+
+    void m1(Integer i) { } //ok - boxing
+    void m2(Integer i1, Integer i2) { } //wrong arity
+    void m3(String s) { } //type mismatch
+    void m4(String... ss) { } //type mismatch - varargs
+
+    static void testStatic() {
+        SAM1 s1 = MethodReference28::static_m1;
+        SAM1 s2 = MethodReference28::static_m2;
+        SAM1 s3 = MethodReference28::static_m3;
+        SAM1 s4 = MethodReference28::static_m4;
+    }
+
+    void testBadMember() {
+        SAM1 s1 = MethodReference28::m1;
+        SAM1 s2 = MethodReference28::m2;
+        SAM1 s3 = MethodReference28::m3;
+        SAM1 s4 = MethodReference28::m4;
+    }
+
+    void testMember() {
+        SAM1 s1 = this::m1;
+        SAM1 s2 = this::m2;
+        SAM1 s3 = this::m3;
+        SAM1 s4 = this::m4;
+    }
+
+    static void testUnbound() {
+        SAM2 s1 = MethodReference28::m1;
+        SAM2 s2 = MethodReference28::m2;
+        SAM2 s3 = MethodReference28::m3;
+        SAM2 s4 = MethodReference28::m4;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference28.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,14 @@
+MethodReference28.java:31:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:32:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:33:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:37:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.Integer)))
+MethodReference28.java:38:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:39:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:40:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:45:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:46:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:47:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: MethodReference28, java.lang.Integer))))
+MethodReference28.java:53:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:54:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: MethodReference28, java.lang.String))))
+13 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference29.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  reference to super leads to compiler crash when 292 translation scheme is enabled
+ */
+
+public class MethodReference29 {
+
+    interface SAM {
+        void m(Integer i);
+    }
+
+    static class A {
+        void m(int i) { }
+    }
+
+    static class B extends A {
+        void test() {
+            SAM s = super::m;
+            s.m(42);
+        }
+
+        void m(int i) { throw new AssertionError(); }
+    }
+
+    public static void main(String[] args) {
+        new B().test();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference30.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-static qualifier of static method reference is eagerly evaluated
+ */
+
+public class MethodReference30 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+       void m();
+    }
+
+    MethodReference30() {
+        assertTrue(true);
+    }
+
+   static void m() { }
+
+   public static void main(String[] args) {
+      SAM s = new MethodReference30()::m;
+      assertTrue(assertionCount == 1);
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference31.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that boxing of return-type works as expected
+ */
+
+public class MethodReference31 {
+
+    static class Success extends RuntimeException { }
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<X> {
+        X m();
+    }
+
+    interface SAM_byte {
+        byte m();
+    }
+
+    interface SAM_short {
+        short m();
+    }
+
+    interface SAM_int {
+        int m();
+    }
+
+    interface SAM_long {
+        long m();
+    }
+
+    interface SAM_float {
+        float m();
+    }
+
+    interface SAM_double {
+        double m();
+    }
+
+    static <Z> Z test() {
+        assertTrue(true);
+        throw new Success();
+    }
+
+    static byte test_byte() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static short test_short() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static int test_int() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static long test_long() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static float test_float() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static double test_double() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static void testByte() {
+        SAM<Byte> s1 = MethodReference31::test_byte;
+        s1.m();
+        SAM_byte s2 = MethodReference31::test_byte;
+        s2.m();
+        SAM<Byte> s3 = MethodReference31::<Byte>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_byte s4 = MethodReference31::<Byte>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testShort() {
+        SAM<Short> s1 = MethodReference31::test_short;
+        s1.m();
+        SAM_short s2 = MethodReference31::test_short;
+        s2.m();
+        SAM<Short> s3 = MethodReference31::<Short>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_short s4 = MethodReference31::<Short>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testInteger() {
+        SAM<Integer> s1 = MethodReference31::test_int;
+        s1.m();
+        SAM_int s2 = MethodReference31::test_int;
+        s2.m();
+        SAM<Integer> s3 = MethodReference31::<Integer>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_int s4 = MethodReference31::<Integer>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testLong() {
+        SAM<Long> s1 = MethodReference31::test_long;
+        s1.m();
+        SAM_long s2 = MethodReference31::test_long;
+        s2.m();
+        SAM<Long> s3 = MethodReference31::<Long>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_long s4 = MethodReference31::<Long>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testFloat() {
+        SAM<Float> s1 = MethodReference31::test_float;
+        s1.m();
+        SAM_float s2 = MethodReference31::test_float;
+        s2.m();
+        SAM<Float> s3 = MethodReference31::<Float>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_float s4 = MethodReference31::<Float>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testDouble() {
+        SAM<Double> s1 = MethodReference31::test_double;
+        s1.m();
+        SAM_double s2 = MethodReference31::test_double;
+        s2.m();
+        SAM<Double> s3 = MethodReference31::<Double>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_double s4 = MethodReference31::<Double>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    public static void main(String[] args) {
+        testByte();
+        testShort();
+        testInteger();
+        testLong();
+        testFloat();
+        testDouble();
+        assertTrue(assertionCount == 24);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference32.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that varargs warnings are generated during SAM conversion
+ * @compile/fail/ref=MethodReference32.out -Xlint:unchecked -Werror -XDrawDiagnostics MethodReference32.java
+ */
+
+import java.util.*;
+
+class MethodReference32 {
+
+    interface SAM {
+        MethodReference32 m(List<Integer> l1, List<Integer> l2);
+    }
+
+    MethodReference32 meth(List<Integer>... lli) { return null; }
+    MethodReference32(List<Integer>... lli) { }
+
+    SAM s1 = this::meth;
+    SAM s2 = MethodReference32::new;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference32.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,7 @@
+MethodReference32.java:17:45: compiler.warn.unchecked.varargs.non.reifiable.type: java.util.List<java.lang.Integer>
+MethodReference32.java:18:40: compiler.warn.unchecked.varargs.non.reifiable.type: java.util.List<java.lang.Integer>
+MethodReference32.java:20:14: compiler.warn.unchecked.generic.array.creation: java.util.List<java.lang.Integer>[]
+MethodReference32.java:21:14: compiler.warn.unchecked.generic.array.creation: java.util.List<java.lang.Integer>[]
+- compiler.err.warnings.and.werror
+1 error
+4 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference33.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  test bridged constructor references
+ */
+
+public class MethodReference33 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    class Foo {
+        Foo(Integer i) { assertTrue(true); }
+        Foo() { assertTrue(true); }
+    }
+
+    interface BridgeSAMBound<X> {
+        X m(int i);
+    }
+
+    interface NonBridgeSAMBound<X> {
+        X m();
+    }
+
+    void test() {
+        BridgeSAMBound<Foo> b1 = Foo::new;
+        b1.m(1);
+        NonBridgeSAMBound<Foo> b2 = Foo::new;
+        b2.m();
+    }
+
+    public static void main(String[] args) {
+        MethodReference33 test = new MethodReference33();
+        test.test();
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference34.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that code generation handles void-compatibility correctly
+ * @run main MethodReference34
+ */
+
+public class MethodReference34 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM_void<X> {
+        void m();
+    }
+
+    interface SAM_java_lang_Void<X> {
+        void m();
+    }
+
+    static void m_void() { assertTrue(true); }
+
+    static Void m_java_lang_Void() { assertTrue(true); return null; }
+
+    public static void main(String[] args) {
+        SAM_void s1 = MethodReference34::m_void;
+        s1.m();
+        SAM_java_lang_Void s2 = MethodReference34::m_void;
+        s2.m();
+        SAM_void s3 = MethodReference34::m_java_lang_Void;
+        s3.m();
+        SAM_java_lang_Void s4 = MethodReference34::m_java_lang_Void;
+        s4.m();
+        assertTrue(assertionCount == 4);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference35.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda/method references are valid method reference qualifiers
+ * @run main MethodReference35
+ */
+
+public class MethodReference35 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        MethodReference35 invoke();
+    }
+
+    MethodReference35() {
+        assertTrue(true);
+    }
+
+    static MethodReference35 m() {
+        assertTrue(true);
+        return null;
+    }
+
+    public static void main(String[] args) {
+        SAM sam1 = ((SAM)() -> { assertTrue(true); return null; })::invoke;
+        sam1.invoke();
+        SAM sam2 = ((SAM)MethodReference35::new)::invoke;
+        sam1.invoke();
+        SAM sam3 = ((SAM)MethodReference35::m)::invoke;
+        sam1.invoke();
+        assertTrue(assertionCount == 3);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference36.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that method reference handles varargs conversion properly
+ * @run main MethodReference36
+ */
+
+public class MethodReference36 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SamC { void m(char[] a); }
+    interface SamZ { void m(boolean[] a); }
+    interface SamB { void m(byte[] a); }
+    interface SamS { void m(short[] a); }
+    interface SamI { void m(int[] a); }
+    interface SamL { void m(long[] a); }
+    interface SamF { void m(float[] a); }
+    interface SamD { void m(double[] a); }
+    interface SamO { void m(Object[] a); }
+
+
+    static void m(Object... vi) {
+        assertTrue(true);
+    }
+
+    public void test() {
+
+        SamC sc = MethodReference36::m;
+        sc.m(new char[] { 'a', 'b' } );
+
+        SamZ sz = MethodReference36::m;
+        sz.m(new boolean[] { true, false } );
+
+        SamB sb = MethodReference36::m;
+        sb.m(new byte[] { 0, 1 } );
+
+        SamS ss = MethodReference36::m;
+        ss.m(new short[] { 0, 1 } );
+
+        SamI si = MethodReference36::m;
+        si.m(new int[] { 0, 1 } );
+
+        SamL sl = MethodReference36::m;
+        sl.m(new long[] { 0, 1 } );
+
+        SamF sf = MethodReference36::m;
+        sf.m(new float[] { 0, 1 } );
+
+        SamD sd = MethodReference36::m;
+        sd.m(new double[] { 0, 1 } );
+
+        SamO so = MethodReference36::m;
+        so.m(new Object[] { null, null } );
+    }
+
+    public static void main(String[] args) {
+       new MethodReference36().test();
+       assertTrue(assertionCount == 9);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference37.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  spurious exceptions when checking references to inner constructors where
+ *          the enclosing class is not defined in any outer context
+ * @compile/fail/ref=MethodReference37.out -XDrawDiagnostics MethodReference37.java
+ */
+
+class MethodReference37 {
+
+    interface SAM1<R> {
+        R invoke();
+    }
+
+    interface SAM2<R, A> {
+        R invoke(A a);
+    }
+
+    static class Outer {
+        class Inner { }
+
+        static void test1() {
+            SAM2<Inner, Outer> sam = Inner::new;
+        }
+
+        void test2() {
+            SAM1<Inner> sam0 = Inner::new;
+            SAM2<Inner, Outer> sam1 = Inner::new;
+        }
+    }
+
+    static void test1() {
+        SAM2<Outer.Inner, Outer> sam = Outer.Inner::new;
+    }
+
+    void test2() {
+        SAM2<Outer.Inner, Outer> sam1 = Outer.Inner::new;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference37.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+MethodReference37.java:24:38: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference37.java:29:39: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference37.java:34:40: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference37.java:38:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference38.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  The qualifier type of a constructor reference must be a concrete class
+ * @compile/fail/ref=MethodReference38.out -XDrawDiagnostics MethodReference38.java
+ */
+
+class MethodReference38 {
+
+    interface SAM<R> {
+        R invoke();
+    }
+
+    @interface A { }
+
+    interface I { }
+
+    static abstract class AC { }
+
+    enum E { }
+
+    void test() {
+        SAM s1 = A::new;
+        SAM s2 = I::new;
+        SAM s3 = AC::new;
+        SAM s4 = E::new;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference38.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+MethodReference38.java:24:18: compiler.err.abstract.cant.be.instantiated
+MethodReference38.java:25:18: compiler.err.abstract.cant.be.instantiated
+MethodReference38.java:26:18: compiler.err.abstract.cant.be.instantiated
+MethodReference38.java:27:18: compiler.err.enum.cant.be.instantiated
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference39.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that bad enclosing class parameter type is discarded accordingly
+ * @compile/fail/ref=MethodReference39.out -XDrawDiagnostics MethodReference39.java
+ */
+class MethodReference39 {
+
+    static class Sup {}
+
+
+    static class Sub extends Sup {
+
+        interface SAM { Sup m(Sup x, String str); }
+
+        class Inner extends Sup {
+            Inner(String val) { }
+        }
+
+        void test() {
+            SAM var = Sub.Inner::new;;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference39.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MethodReference39.java:22:23: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, java.lang.String, MethodReference39.Sup,java.lang.String, kindname.class, MethodReference39.Sub.Inner, (compiler.misc.arg.length.mismatch)))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference40.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that unbound constructor reference are not accepted
+ * @compile/fail/ref=MethodReference40.out -XDrawDiagnostics MethodReference40.java
+ */
+class MethodReference40 {
+
+    static class Sup {
+        class Inner {
+            Inner(String val) { }
+        }
+    }
+
+    static class Sub extends Sup {
+
+        interface SAM { Sup.Inner m(Sub x, String str); }
+
+        void test() {
+            SAM var = Sub.Inner::new;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference40.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MethodReference40.java:21:23: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, java.lang.String, MethodReference40.Sub,java.lang.String, kindname.class, MethodReference40.Sup.Inner, (compiler.misc.arg.length.mismatch)))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference41.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that diamond inference is applied when using raw constructor reference qualifier
+ * @run main MethodReference41
+ */
+public class MethodReference41 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       void m(String s);
+    }
+
+    interface SAM2 {
+       void m(Integer s);
+    }
+
+    interface SAM3 {
+       void m(Object o);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+
+    static void m(SAM1 s) { assertTrue(false); }
+    static void m(SAM2 s) { assertTrue(true); }
+    static void m(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        m(Foo::new);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference42.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that diamond inference is applied when using raw constructor reference qualifier
+ * @run main MethodReference42
+ */
+public class MethodReference42 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class SuperFoo<X> { }
+
+    static class Foo<X extends Number> extends SuperFoo<X> { }
+
+    interface SAM1 {
+        SuperFoo<String> m();
+    }
+
+    interface SAM2 {
+        SuperFoo<Integer> m();
+    }
+
+    interface SAM3 {
+        SuperFoo<Object> m();
+    }
+
+    static void m(SAM1 s) { assertTrue(false); }
+    static void m(SAM2 s) { assertTrue(true); }
+    static void m(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        m(Foo::new);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference43.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that diamond inference is applied when using raw constructor reference qualifier
+ * @run main MethodReference43
+ */
+public class MethodReference43 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       Foo<?> m(String s);
+    }
+
+    interface SAM2 {
+       Foo<?> m(Integer s);
+    }
+
+    interface SAM3 {
+       Foo<?> m(Object o);
+    }
+
+    interface SAM4 {
+       Foo<Number> m(Integer o);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+
+    static void m(SAM1 s) { assertTrue(false); }
+    static void m(SAM2 s) { assertTrue(true); }
+    static void m(SAM3 s) { assertTrue(false); }
+    static void m(SAM4 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        m(Foo::new);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference44.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @run main MethodReference44
+ */
+public class MethodReference44 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class SuperFoo<X> { }
+
+    static class Foo<X extends Number> extends SuperFoo<X> { }
+
+    interface SAM1 {
+        SuperFoo<String> m();
+    }
+
+    interface SAM2 {
+        SuperFoo<Integer> m();
+    }
+
+    interface SAM3 {
+        SuperFoo<Object> m();
+    }
+
+    static <X extends Number> Foo<X> m() { return null; }
+
+    static void g(SAM1 s) { assertTrue(false); }
+    static void g(SAM2 s) { assertTrue(true); }
+    static void g(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        g(MethodReference44::m);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference45.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @compile/fail/ref=MethodReference45.out -XDrawDiagnostics MethodReference45.java
+ */
+public class MethodReference45 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class SuperFoo<X> { }
+
+    static class Foo<X extends Number> extends SuperFoo<X> { }
+
+    interface SAM1 {
+        void m();
+    }
+
+    interface SAM2 {
+        void m();
+    }
+
+    static <X extends Number> Foo<X> m() { return null; }
+
+    static void g1(SAM1 s) { }
+    static void g2(SAM1 s) { }
+    static void g2(SAM2 s) { }
+
+    void test() {
+        g1(MethodReference45::m);
+        g2(MethodReference45::m);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference45.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MethodReference45.java:38:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference45.SAM1), MethodReference45, kindname.method, g2(MethodReference45.SAM2), MethodReference45
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference46.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @run main MethodReference46
+ */
+public class MethodReference46 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       void m(String s);
+    }
+
+    interface SAM2 {
+       void m(Integer s);
+    }
+
+    interface SAM3 {
+       void m(Object o);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+    static <X extends Number> void m(X fx) { }
+
+    static void g(SAM1 s) { assertTrue(false); }
+    static void g(SAM2 s) { assertTrue(true); }
+    static void g(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        g(MethodReference46::m);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference47.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @compile/fail/ref=MethodReference47.out -XDrawDiagnostics MethodReference47.java
+ */
+public class MethodReference47 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       void m(Integer s);
+    }
+
+    interface SAM2 {
+       void m(Integer s);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+    static <X extends Number> void m(X fx) { }
+
+    static void g1(SAM1 s) { }
+    static void g2(SAM1 s) { }
+    static void g2(SAM2 s) { }
+
+    public static void main(String[] args) {
+        g1(MethodReference46::m);
+        g2(MethodReference46::m);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference47.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MethodReference47.java:38:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference47.SAM1), MethodReference47, kindname.method, g2(MethodReference47.SAM2), MethodReference47
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference48.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that raw qualifier in unbound method reference is inferred from descriptor
+ * @run main MethodReference48
+ */
+public class MethodReference48 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class Foo<X> {
+        X m() { return null; };
+    }
+
+    interface SAM1 {
+        Foo<Object> m(Foo<String> fs);
+    }
+
+    interface SAM2 {
+        Integer m(Foo<Integer> fi);
+    }
+
+    interface SAM3 {
+        Object m(Foo<Integer> fi);
+    }
+
+    static void g(SAM1 s) { assertTrue(false); } //return type not compatible
+    static void g(SAM2 s) { assertTrue(true); } //ok
+    static void g(SAM3 s) { assertTrue(false); } //ok but less specific
+
+    public static void main(String[] args) {
+        g(Foo::m);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference49.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that an array type can be used as a qualifier of an unbound method reference
+ * @run main MethodReference49
+ */
+public class MethodReference49 {
+
+    interface SAM {
+       Object m(int[] i);
+    }
+
+    public static void main(String[] args) {
+        SAM s = int[]::clone;
+        int[] iarr = { 1, 2, 3 };
+        int[] iarr2 = (int[])s.m(iarr);
+        if (iarr == iarr2) {
+            throw new AssertionError();
+        }
+        for (int i = 0 ; i < iarr.length ; i ++) {
+            if (iarr[i] != iarr2[i]) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference50.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that erroneous method references are flagged with errors as expected
+ * @compile/fail/ref=MethodReference50.out -XDrawDiagnostics MethodReference50.java
+ */
+
+class MethodReference50 {
+
+    interface SAM1 {
+        void m();
+    }
+
+    interface SAM2 {
+        void m();
+    }
+
+    void call(SAM1 s) {}
+    void call(SAM2 s) {}
+
+    {
+        call(NonExistentType::m);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference50.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MethodReference50.java:23:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference50, null)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference51.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,46 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  certain cases of erroneous member reference lookup are not handled by Attr.visitReference
+ * @compile/fail/ref=MethodReference51.out -XDrawDiagnostics MethodReference51.java
+ */
+class MethodReference51 {
+
+    private static class Foo {
+        static int j(int i) { return i; }
+    }
+
+    static Foo foo = new Foo();
+
+    static void m(String s) { }
+    static void m(Integer i) { }
+
+    static int f(String s) { return 1; }
+
+    static int g(Integer i, Number n) { return 1; }
+    static int g(Number n, Integer i) { return 1; }
+
+    int h(int i) { return i; }
+}
+
+class TestMethodReference51 {
+
+    interface IntSam {
+        int m(int i);
+    }
+
+    interface IntegerIntegerSam {
+        int m(Integer i1, Integer i2);
+    }
+
+
+    static void test() {
+        IntSam s1 = MethodReference51::unknown; //method not found
+        IntSam s2 = MethodReference51::f; //inapplicable method
+        IntSam s3 = MethodReference51::g; //inapplicable methods
+        IntegerIntegerSam s4 = MethodReference51::g; //ambiguous
+        IntSam s5 = MethodReference51::h; //static error
+        IntSam s6 = MethodReference51.foo::j; //inaccessible method
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference51.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,7 @@
+MethodReference51.java:39:21: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , int, (compiler.misc.location: kindname.class, MethodReference51, null))
+MethodReference51.java:40:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, f, java.lang.String, int, kindname.class, MethodReference51, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference51.java:41:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Integer,java.lang.Number), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Number,java.lang.Integer), (compiler.misc.arg.length.mismatch))}))
+MethodReference51.java:42:32: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: g, kindname.method, g(java.lang.Integer,java.lang.Number), MethodReference51, kindname.method, g(java.lang.Number,java.lang.Integer), MethodReference51))
+MethodReference51.java:43:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, h(int)))
+MethodReference51.java:44:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.not.def.access.class.intf.cant.access: j(int), MethodReference51.Foo))
+6 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference52.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,39 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  special cases of method references (getClass()/Array.clone()) not handled properly
+ * @compile/fail/ref=MethodReference52.out -XDrawDiagnostics MethodReference52.java
+ */
+import java.util.*;
+
+class MethodReference52 {
+
+    interface Clone1 {
+        int[] m();
+    }
+
+    interface Clone2 {
+        Object m();
+    }
+
+    interface WrongClone {
+        long[] m();
+    }
+
+    interface GetClass {
+        Class<? extends List> m();
+    }
+
+    interface WrongGetClass {
+        Class<List<String>> m();
+    }
+
+    void test(int[] iarr, List<String> ls) {
+        Clone1 c1 = iarr::clone; //ok
+        Clone2 c2 = iarr::clone; //ok - type more generic
+        WrongClone c3 = iarr::clone; //bad return type
+        GetClass c4 = ls::getClass; //ok
+        WrongGetClass c5 = ls::getClass; //bad return type
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference52.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+MethodReference52.java:35:25: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int[], long[]))
+MethodReference52.java:37:28: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.Class<? extends java.util.List>, java.lang.Class<java.util.List<java.lang.String>>))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference53.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  the case in which no member reference is found is now treated as a normal error (not dependent on target-type)
+ * @compile/fail/ref=MethodReference53.out -XDrawDiagnostics MethodReference53.java
+ */
+class MethodReference53 {
+
+    interface SAM1 {
+        void m(int i);
+    }
+
+    interface SAM2 {
+        void m(long i);
+    }
+
+    void m(SAM1 s1) { }
+    void m(SAM2 s1) { }
+
+    void test() {
+        m(this::unknown); //should not generate outer resolution diagnostic
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference53.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MethodReference53.java:22:11: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, MethodReference53, null))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference54.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  method call with bad qualifier generates NPE if argument is a method reference
+ * @compile/fail/ref=MethodReference54.out -XDrawDiagnostics MethodReference54.java
+ */
+class MethodReference54 {
+
+    interface SAM {
+        void m();
+    }
+
+    void test() {
+        nonExistent.m(MethodReference54::get);
+    }
+
+    static String get() { return ""; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReference54.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MethodReference54.java:15:9: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, MethodReference54, null)
+1 error
--- a/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -24,7 +24,9 @@
 /*
  * @test
  * @bug 7115052
- * @summary Add parser support for method references
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Add parser support for method references
  */
 
 import com.sun.source.util.JavacTask;
@@ -227,7 +229,7 @@
 
     void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
         JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                Arrays.asList("-XDallowMethodReferences"), null, Arrays.asList(source));
+                null, null, Arrays.asList(source));
         try {
             ct.parse();
         } catch (Throwable ex) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check correctness of structural most specific test routine
+ * @compile/fail/ref=MostSpecific01.out -XDrawDiagnostics MostSpecific01.java
+ */
+
+class Test {
+
+    interface IntMapper {
+        int map();
+    }
+
+    interface LongMapper {
+        long map();
+    }
+
+    void m(IntMapper im, String s) { }
+    void m(LongMapper lm, Integer s) { }
+
+    void test() {
+        m(()->1, null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific01.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MostSpecific01.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper,java.lang.String), Test, kindname.method, m(Test.LongMapper,java.lang.Integer), Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check correctness of structural most specific test routine
+ * @compile/fail/ref=MostSpecific02.out -XDrawDiagnostics MostSpecific02.java
+ */
+
+class Test {
+
+    interface IntMapper {
+        int map();
+    }
+
+    interface LongMapper {
+        long map();
+    }
+
+    void m(IntMapper im, LongMapper s) { }
+    void m(LongMapper lm, IntMapper s) { }
+
+    void test() {
+        m(()->1, ()->1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific02.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+MostSpecific02.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper,Test.LongMapper), Test, kindname.method, m(Test.LongMapper,Test.IntMapper), Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,63 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check correctness of structural most specific test routine
+ * @compile/fail/ref=MostSpecific03.out -XDrawDiagnostics MostSpecific03.java
+ */
+
+class Test {
+
+    interface IntMapper {
+        int map();
+    }
+
+    interface LongMapper {
+        long map();
+    }
+
+    void m(IntMapper... im) { }
+    void m(LongMapper... lm) { }
+
+    void m2(IntMapper im1, IntMapper... im) { }
+    void m2(LongMapper... lm) { }
+
+    void test1() {
+        m(); //ambiguous
+        m(()->1); //ok
+        m(()->1, ()->1); //ok
+        m(()->1, ()->1, ()->1); //ok
+    }
+
+    void test2() {
+        m(null, null); //ambiguous
+        m(()->1, null); //ambiguous
+        m(null, ()->1); //ambiguous
+        m(()->1L, null); //ok
+        m(null, ()->1L); //ok
+    }
+
+    void test3() {
+        m2(); //ok
+        m2(()->1); //ambiguous
+        m2(()->1, ()->1); //ok
+        m2(()->1, ()->1, ()->1); //ok
+    }
+
+    void test4() {
+        m2(null, null, null); //ambiguous
+        m2(()->1, null, null); //ambiguous
+        m2(null, ()->1, null); //ambiguous
+        m2(null, null, ()->1); //ambiguous
+        m2(()->1, ()->1, null); //ambiguous
+        m2(null, ()->1, ()->1); //ambiguous
+        m2(()->1, null, ()->1); //ambiguous
+
+        m2(()->1L, null, null); //ok
+        m2(null, ()->1L, null); //ok
+        m2(null, null, ()->1L); //ok
+        m2(()->1L, ()->1L, null); //ok
+        m2(null, ()->1L, ()->1L); //ok
+        m2(()->1L, null, ()->1L); //ok
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific03.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,13 @@
+MostSpecific03.java:26:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:33:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:34:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:35:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:42:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:48:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:49:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:50:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:51:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:52:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:53:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:54:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+12 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific04.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  Structural most specific doesn't handle cases with wildcards in functional interfaces
+ */
+public class MostSpecific04 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface DoubleMapper<T> {
+        double map(T t);
+    }
+
+    interface LongMapper<T> {
+        long map(T t);
+    }
+
+    static class MyList<E> {
+        void map(DoubleMapper<? super E> m) { assertTrue(false); }
+        void map(LongMapper<? super E> m) { assertTrue(true); }
+    }
+
+    public static void main(String[] args) {
+        MyList<String> ls = new MyList<String>();
+        ls.map(e->e.length());
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific05.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  Structural most specific doesn't handle cases with wildcards in functional interfaces
+ */
+public class MostSpecific05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface ObjectConverter<T extends Object> {
+        T map(Object o);
+    }
+
+    interface NumberConverter<T extends Number> {
+        T map(Object o);
+    }
+
+    static class MyMapper<A extends Object, B extends Number> {
+        void map(ObjectConverter<? extends A> m) { assertTrue(false); }
+        void map(NumberConverter<? extends B> m) { assertTrue(true); }
+    }
+
+    public static void main(String[] args) {
+        MyMapper<Number, Double> mm = new MyMapper<Number, Double>();
+        mm.map(e->1.0);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific06.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  most specific resolution crashes on stuck lambdas
+ * @compile/fail/ref=MostSpecific06.out -XDrawDiagnostics MostSpecific06.java
+ */
+import java.util.*;
+
+class MostSpecific06 {
+
+    interface Predicate<X> {
+        boolean accept(X x);
+    }
+
+    interface ExtPredicate<X> extends Predicate<X> { }
+
+
+
+    void test(boolean cond, ArrayList<String> als) {
+        m(u -> true, als, als);
+        m((u -> true), als, als);
+        m(cond ? u -> true : u -> false, als, als);
+    }
+
+    <U> U m(Predicate<U> p, List<U> lu, ArrayList<U> au) { return null; }
+
+
+    <U> U m(ExtPredicate<U> ep, ArrayList<U> au, List<U> lu) { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific06.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,4 @@
+MostSpecific06.java:21:9: compiler.err.ref.ambiguous: m, kindname.method, <U>m(MostSpecific06.Predicate<U>,java.util.List<U>,java.util.ArrayList<U>), MostSpecific06, kindname.method, <U>m(MostSpecific06.ExtPredicate<U>,java.util.ArrayList<U>,java.util.List<U>), MostSpecific06
+MostSpecific06.java:22:9: compiler.err.ref.ambiguous: m, kindname.method, <U>m(MostSpecific06.Predicate<U>,java.util.List<U>,java.util.ArrayList<U>), MostSpecific06, kindname.method, <U>m(MostSpecific06.ExtPredicate<U>,java.util.ArrayList<U>,java.util.List<U>), MostSpecific06
+MostSpecific06.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, <U>m(MostSpecific06.Predicate<U>,java.util.List<U>,java.util.ArrayList<U>), MostSpecific06, kindname.method, <U>m(MostSpecific06.ExtPredicate<U>,java.util.ArrayList<U>,java.util.List<U>), MostSpecific06
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific07.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  speculative cache contents are overwritten by deferred type-checking of nested stuck expressions
+ * @compile/fail/ref=MostSpecific07.out -XDrawDiagnostics MostSpecific07.java
+ */
+import java.util.*;
+
+class MostSpecific07 {
+
+    interface Predicate<X, Y> {
+        Y accept(X x);
+    }
+
+    interface VoidMapper {
+        void accept();
+    }
+
+    interface ExtPredicate<X, Y> extends Predicate<X, Y> { }
+
+    void test(boolean cond, ArrayList<String> als, VoidMapper vm) {
+        m(u -> ()->{}, als, als, vm);
+        m((u -> ()->{}), als, als, vm);
+        m(cond ? u -> ()->{} : u -> ()->{}, als, als, vm);
+    }
+
+    <U, V> U m(Predicate<U, V> p, List<U> lu, ArrayList<U> au, V v) { return null; }
+
+    <U, V> U m(ExtPredicate<U, V> ep, ArrayList<U> au, List<U> lu, V v) { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MostSpecific07.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,4 @@
+MostSpecific07.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, <U,V>m(MostSpecific07.Predicate<U,V>,java.util.List<U>,java.util.ArrayList<U>,V), MostSpecific07, kindname.method, <U,V>m(MostSpecific07.ExtPredicate<U,V>,java.util.ArrayList<U>,java.util.List<U>,V), MostSpecific07
+MostSpecific07.java:24:9: compiler.err.ref.ambiguous: m, kindname.method, <U,V>m(MostSpecific07.Predicate<U,V>,java.util.List<U>,java.util.ArrayList<U>,V), MostSpecific07, kindname.method, <U,V>m(MostSpecific07.ExtPredicate<U,V>,java.util.ArrayList<U>,java.util.List<U>,V), MostSpecific07
+MostSpecific07.java:25:9: compiler.err.ref.ambiguous: m, kindname.method, <U,V>m(MostSpecific07.Predicate<U,V>,java.util.List<U>,java.util.ArrayList<U>,V), MostSpecific07, kindname.method, <U,V>m(MostSpecific07.ExtPredicate<U,V>,java.util.ArrayList<U>,java.util.List<U>,V), MostSpecific07
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/NakedThis.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @compile NakedThis.java
+ */
+
+class NakedThis {
+
+    interface SAM {
+        NakedThis m(int x);
+    }
+
+    SAM s1 = (int x) -> this;
+    SAM s2 = (int x) -> NakedThis.this;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/SourceLevelTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda features are not enabled with source < 8
+ * @compile/fail/ref=SourceLevelTest.out -XDrawDiagnostics -source 7 SourceLevelTest.java
+ */
+
+class SourceLevelTest {
+    interface I {
+        default void m() { SourceLevelTest.impl(this); }
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    SAM s1 = () -> { };
+    SAM s2 = this::m;
+
+    static void impl(I i) {}
+    void m() {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/SourceLevelTest.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,6 @@
+- compiler.warn.source.no.bootclasspath: 1.7
+SourceLevelTest.java:11:9: compiler.err.default.methods.not.supported.in.source: 1.7
+SourceLevelTest.java:18:17: compiler.err.lambda.not.supported.in.source: 1.7
+SourceLevelTest.java:19:20: compiler.err.method.references.not.supported.in.source: 1.7
+3 errors
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType01.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check nested case of overload resolution and lambda parameter inference
+ * @author  Maurizio Cimadamore
+ * @compile TargetType01.java
+ */
+
+class TargetType01 {
+
+    interface Func<A,B> {
+        B call(A a);
+    }
+
+    interface F_I_I extends Func<Integer,Integer> {}
+    interface F_S_S extends Func<String,String> {}
+
+    static Integer M(F_I_I f){ return null; }
+    static String M(F_S_S f){ return null; }
+
+    static {
+        //ambiguity here - the compiler does not try all the combinations!
+        M(x1 -> { return M( x2 -> { return x1 + x2; });});
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType02.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check overload resolution and target type inference w.r.t. generic methods
+ * @author  Maurizio Cimadamore
+ * @run main TargetType02
+ */
+
+public class TargetType02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface S1<X extends Number> {
+        X m(Integer x);
+    }
+
+    interface S2<X extends String> {
+        abstract X m(Integer x);
+    }
+
+    static <Z extends Number> void call(S1<Z> s) { s.m(1); assertTrue(true); }
+    static <Z extends String> void call(S2<Z> s) { s.m(2); assertTrue(false); }
+
+    void test() {
+        call(i -> { toString(); return i; });
+    }
+
+    public static void main(String[] args) {
+        new TargetType02().test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType03.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check overload resolution and target type inference w.r.t. generic methods
+ * @author  Maurizio Cimadamore
+ * @run main TargetType03
+ */
+import java.util.*;
+
+public class TargetType03 {
+
+    interface Mapper<X,Y> {
+        Y myMap(X a);
+    }
+
+    static class MapperList<A> extends ArrayList<A> {
+        public <B> List<B> myMap(Mapper<A, B> mapper) {
+            ArrayList<B> mappedList = new ArrayList<>();
+            for (A elem : this) {
+                mappedList.add(mapper.myMap(elem));
+            }
+            return mappedList;
+        };
+    }
+
+    public static void main(String[] args) {
+        MapperList<Integer> numbers = new MapperList<>();
+        numbers.add(1);
+        numbers.add(2);
+        numbers.add(3);
+        numbers.add(4);
+        numbers.add(5);
+        List<Integer> sqNumbers = numbers.myMap(a -> a * a);
+        //check invariants
+        if (numbers.size() != sqNumbers.size()) {
+            throw new AssertionError();
+        }
+        for (int i = 0; i < numbers.size() ; i ++) {
+            if (sqNumbers.get(i) != Math.pow(numbers.get(i), 2)) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType04.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  target typing in assignment context
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType04.out -XDrawDiagnostics TargetType04.java
+ */
+class TargetType04 {
+
+    interface S<X extends Number, Y extends Number> {
+       Y m(X x);
+    }
+
+    S<Integer, Integer> s1 = i -> { return i; }; //ok
+    S<Double, Integer> s2 = i -> { return i; }; //no
+    S<Integer, Double> s3 = i -> { return i; }; //no
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType04.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+TargetType04.java:16:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Double, java.lang.Integer))
+TargetType04.java:17:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.Double))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType05.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  test recursion through SAM type
+ * @author  Maurizio Cimadamore
+ * @run main TargetType05
+ */
+public class TargetType05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Func<A,R> {
+        R call(A a);
+    }
+
+    static Func<Integer, Integer> f;
+
+    public static void main(String[] args) {
+        f = i -> { return i == 1 ? 1 : f.call(i-1) * i; };
+        assertTrue(f.call(5) == 120);
+        assertTrue(assertionCount == 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType06.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check complex case of target typing
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType06.out -XDrawDiagnostics TargetType06.java
+ */
+
+import java.util.List;
+
+class TargetType06 {
+
+    class Foo {
+        Foo getFoo() { return null; }
+    }
+
+    interface Function<A,R> {
+        R invoke(A a);
+    }
+
+    static <B> List<B> map(Function<B, B> function) { return null; }
+
+    void test() {
+        List<Foo> l = map(foo -> foo.getFoo());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType06.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType06.java:25:23: compiler.err.cant.apply.symbol: kindname.method, map, TargetType06.Function<B,B>, @510, kindname.class, TargetType06, (compiler.misc.cyclic.inference: B)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType07.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that explicit generic target type parses w/o problems
+ * @author  Peter Levart
+ * @author  Maurizio Cimadamore
+ * @compile TargetType07.java
+ */
+
+class TargetType07 {
+
+    public interface SAM1<X> { X m(); }
+    public interface SAM2<X> { X m(); }
+
+    public static <X> void call(SAM1<X> s) { }
+    public static <X> void call(SAM2<X> s) { }
+
+    public static void main(String[] args) {
+        call((SAM1<Integer>)()-> 1 );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType08.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that explicit non-generic target type parses w/o problems
+ * @author  Peter Levart
+ * @author  Maurizio Cimadamore
+ * @compile TargetType08.java
+ */
+
+class TargetType07 {
+
+    public interface SAM1 { String m(); }
+    public interface SAM2 { Comparable<?> m(); }
+
+    public static void call(SAM1 s) { }
+    public static void call(SAM2 s) { }
+
+    public static void main(String[] args) {
+        call((SAM1)()-> "Hello!" );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType10.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that wildcards in the target method of a lambda conversion is handled correctly
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType10.out -XDrawDiagnostics TargetType10.java
+ */
+
+class TargetType10 {
+    interface Function<A,R> {
+        R apply(A a);
+    }
+
+    static class Test {
+        <A,B,C> Function<A,C> compose(Function<B,C> g, Function<A,? extends B> f) { return null; }
+        { compose(x ->  "a" + x, x -> x + "b"); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType10.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType10.java:17:11: compiler.err.cant.apply.symbol: kindname.method, compose, TargetType10.Function<B,C>,TargetType10.Function<A,? extends B>, @500,@515, kindname.class, TargetType10.Test, (compiler.misc.cyclic.inference: B,A)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType11.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that wildcards in the target method of a lambda conversion is handled correctly
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType11.out -Xlint:unchecked -XDrawDiagnostics TargetType11.java
+ */
+
+class TargetType11 {
+    interface Predicate<X> {
+        boolean apply(X c);
+    }
+
+    static class Test {
+        public <T> Predicate<T> and(Predicate<? super T>... first) { return null; }
+        public Predicate<Character> forPredicate(Predicate<? super Character> predicate) { return null; }
+
+        Predicate<Character> c2 = forPredicate(c -> c.compareTo('e') < 0);
+        Predicate<Integer> k = and(i -> i > 0, i -> i % 2 == 0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType11.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,4 @@
+TargetType11.java:16:61: compiler.warn.unchecked.varargs.non.reifiable.type: TargetType11.Predicate<? super T>
+TargetType11.java:20:32: compiler.err.cant.apply.symbol: kindname.method, and, TargetType11.Predicate<? super T>[], @706,@718, kindname.class, TargetType11.Test, (compiler.misc.cyclic.inference: T)
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType12.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  Flow should not analyze lambda body that contains errors due to partially specified parameter types
+ * @author  Maurizio Cimadamore
+ * @compile TargetType12.java
+ */
+
+import java.util.*;
+
+class TargetType12 {
+
+    interface Extractor<X,Y> {
+       Y get(X x);
+    }
+
+    static <T, U extends Comparable<? super U>> void sortBy2(T[] array, Extractor<T, U> extractor) {
+        Comparator<T> comparator = (left,right) -> extractor.get(left).compareTo(extractor.get(right));
+        Arrays.sort(array, comparator);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType13.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  failure to infer exception thrown types from lambda body causes checked exception to be skipped
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType13.out -XDlambdaInferenceDiags=false -XDrawDiagnostics TargetType13.java
+ */
+
+class TargetType13 {
+
+    interface SAM<E extends Throwable> {
+       void m(Integer x) throws E;
+    }
+
+    static <E extends Throwable> void call(SAM<E> s) throws E { }
+
+    void test() {
+        call(i -> { if (i == 2) throw new Exception(); return; });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType13.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType13.java:19:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType14.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that return type is inferred from target type when cyclic inference found
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType14.out -XDrawDiagnostics TargetType14.java
+ */
+
+class TargetType14 {
+
+    interface SAM<X> {
+        X m(int i, int j);
+    }
+
+    static void test() {
+        SAM<Integer> s1 = (i, j) -> i + j;
+        m((i, j) -> i + j);
+        SAM<Integer> s2 = m2((i, j) -> i + j); //ok
+        SAM<Integer> s3 = m2((i, j) -> "" + i + j); //no
+    }
+
+    static void m(SAM<Integer> s) { }
+    static <X> SAM<X> m2(SAM<X> s) { return null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType14.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType14.java:20:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TargetType14.SAM<java.lang.String>, TargetType14.SAM<java.lang.Integer>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType15.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  bad target-type inference lead to compiler crash
+ * @author  Maurizio Cimadamore
+ * @compile TargetType15.java
+ */
+
+class TargetType15 {
+
+    interface SAM<T> {
+        T foo(T a, T b);
+    }
+
+    void m1(SAM<? extends String> f_1) {}
+    void m2(SAM<? super String> f_2) {}
+    void m3(SAM<?> f_3) {}
+
+    SAM<? extends String> f_1 = (a, b) -> a;
+    SAM<? super String> f_2 = (a, b) -> a;
+    SAM<?> f_3 = (a, b) -> a;
+
+    {
+        m1((a, b) -> a);
+        m2((a, b) -> a);
+        m3((a, b) -> a);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType16.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Check void-compatibility in strict vs. loose conversion contexts
+ * @compile/fail/ref=TargetType16.out -XDrawDiagnostics TargetType16.java
+ */
+
+class TargetType16 {
+
+    interface SAM1 {
+        void m1();
+    }
+
+    interface SAM2<X> {
+        X m2();
+    }
+
+    static void m(SAM1 s1) { }
+    static <T> void m(SAM2<T> s2) { }
+
+    public static void main(String[] args) {
+        m(() -> { throw new AssertionError(); }); //ambiguous
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType16.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType16.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(TargetType16.SAM1), TargetType16, kindname.method, <T>m(TargetType16.SAM2<T>), TargetType16
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType17.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that javac recovers succesfully from bad cast conversion to primitive type
+ * @compile/fail/ref=TargetType17.out -XDrawDiagnostics TargetType17.java
+ */
+
+class TargetType17 {
+    interface SAM<X> {
+        boolean m(X x);
+    }
+
+    byte b = (byte) ()-> true;
+    short s = (short) ()-> 1;
+    int i = (int) ()-> 1;
+    long l = (long) ()-> 1L;
+    float f = (float) ()-> 1.0F;
+    double d = (double) ()-> 1.0;
+    char c = (char) ()-> 'c';
+    boolean z = (boolean) ()-> true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType17.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,9 @@
+TargetType17.java:14:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:15:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:16:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:17:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:18:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:19:25: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:20:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:21:27: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+8 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType18.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that javac doesn't crash if implicit lambda parameter is involved in cast
+ * @compile TargetType18.java
+ */
+
+class TargetType18 {
+
+    interface Folder<T> {
+        public T fold(T a, T b);
+    }
+
+
+    public static <T> Folder<T> max() {
+        return (a, b) -> (((Comparable)a).compareTo(b)<0)? b: a;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType19.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  complex case of generic method call with lambda argument where target
+ *          is a wildcard SAM
+ * @compile TargetType19.java
+ */
+import java.util.List;
+
+class TargetType19 {
+
+    interface SAM<X> {
+        void f(List<? extends X> i);
+    }
+
+    <Z> void call(SAM<? extends Z> s, Z z) {  }
+
+   { call((List<? extends String> p) -> { }, 1); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType19.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType19.java:40:10: compiler.err.invalid.inferred.types: (compiler.misc.no.conforming.assignment.exists: TargetType19.SAM<java.lang.String>, TargetType19.SAM<? extends java.lang.Integer>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType20.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  complex case of lambda return type that depends on generic method
+ *          inference variable
+ * @compile/fail/ref=TargetType20.out -XDrawDiagnostics TargetType20.java
+ */
+import java.util.*;
+
+class TargetType20 {
+
+    interface SAM2<X> {
+      List<X> f();
+    }
+
+    class Test {
+       <Z> void call(SAM2<Z> x, SAM2<Z> y) { }
+       { call(() -> Collections.emptyList(), () -> new ArrayList<String>()); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType20.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType20.java:19:10: compiler.err.cant.apply.symbol: kindname.method, call, TargetType20.SAM2<Z>,TargetType20.SAM2<Z>, @428,@459, kindname.class, TargetType20.Test, (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType21.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that candidates with cyclic type-inference are removed from the
+ *          set of applicable methods
+ * @compile/fail/ref=TargetType21.out -XDrawDiagnostics TargetType21.java
+ */
+
+class TargetType21 {
+    interface SAM1 {
+        String m1(Integer n) throws Exception;
+    }
+
+    interface SAM2 {
+        void m2(Integer n);
+    }
+
+    interface SAM3<R,A> {
+        R m3(A n);
+    }
+
+    void call(SAM1 sam) { }
+    void call(SAM2 sam) { }
+    <R,A> void call(SAM3<R,A> sam) { }
+
+    void test() {
+        call(x -> { throw new Exception(); }); //ok - resolves to call(SAM1)
+        call(x -> { System.out.println(""); }); //ok - resolves to call(SAM2)
+        call(x -> { return (Object) null; }); //error - call(SAM3) is not applicable because of cyclic inference
+        call(x -> { return null; }); ////ok - resolves to call(SAM1)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType21.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, call(TargetType21.SAM2), TargetType21
+TargetType21.java:30:9: compiler.err.cant.apply.symbols: kindname.method, call, @755,{(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, <R,A>call(TargetType21.SAM3<R,A>), (compiler.misc.cyclic.inference: A))}
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType22.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,44 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that candidates with incompatible SAM descriptor args length
+            are removed from the set of applicable methods
+ * @compile/fail/ref=TargetType22.out -Xlint:unchecked -XDrawDiagnostics TargetType22.java
+ */
+
+class TargetType22 {
+
+    interface Sam0 {
+        void m();
+    }
+
+    interface Sam1<A> {
+        void m(A a);
+    }
+
+    interface Sam2<A> {
+        void m(A a1, A a2);
+    }
+
+    interface Sam3<A> {
+        void m(A a1, A a2, A a3);
+    }
+
+    interface SamX<A> {
+        void m(A... as);
+    }
+
+    void call(Sam0 s) { }
+    void call(Sam1<String> s) { }
+    void call(Sam2<String> s) { }
+    void call(Sam3<String> s) { }
+    void call(SamX<String> s) { }
+
+    void test() {
+        call(() -> { });
+        call(a1 -> { }); //ambiguous - both call(Sam1) and call(SamX) match
+        call((a1, a2) -> { });
+        call((a1, a2, a3) -> { });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType22.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,4 @@
+TargetType22.java:29:21: compiler.warn.unchecked.varargs.non.reifiable.type: A
+TargetType22.java:40:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType22.Sam1<java.lang.String>), TargetType22, kindname.method, call(TargetType22.SamX<java.lang.String>), TargetType22
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType23.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,37 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check case of ambiguous method call with lambda whose body cannot
+            complete normally
+ * @compile/fail/ref=TargetType23.out -XDrawDiagnostics TargetType23.java
+ */
+
+class TargetType23 {
+
+    interface Sam0 {
+        void m();
+    }
+
+    interface Sam1 {
+        int m();
+    }
+
+    interface Sam2 {
+        String m();
+    }
+
+    interface Sam3<A> {
+        A m();
+    }
+
+
+    void call(Sam0 s) { }
+    void call(Sam1 s) { }
+    void call(Sam2 s) { }
+    <Z> void call(Sam3<Z> s) { }
+
+    void test() {
+        call(()-> { throw new RuntimeException(); }); //ambiguous - both call(Sam0), call(Sam2), call(Sam3) match
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType23.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType23.java:35:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam2), TargetType23, kindname.method, <Z>call(TargetType23.Sam3<Z>), TargetType23
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType24.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,39 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check case of nested method calls with lambda expression
+ * @compile/fail/ref=TargetType24.out -XDrawDiagnostics TargetType24.java
+ */
+
+class TargetType24 {
+
+    interface F<A, B> {
+        B f(A a);
+    }
+
+    interface FSub<A, B> extends F<A,B> { }
+
+    static class Array<A> {
+        boolean forAll(final F<A, Boolean> f) {
+            return false;
+        }
+
+        String forAll(final FSub<A, String> f) {
+            return "";
+        }
+
+        String forAll2(final FSub<A, String> f) {
+            return "";
+        }
+    }
+
+    void test(Array<String> as, final Array<Character> ac) {
+        final boolean b1 = as.forAll(s -> ac.forAll(c -> false)); //ok
+        final String s1 = as.forAll2(s -> ac.forAll2(c -> "")); //ok
+        final boolean b2 = as.forAll(s -> ac.forAll(c -> "" )); //fail
+        final String s2 = as.forAll2(s -> ac.forAll2(c -> false)); //fail
+        final boolean b3 = as.forAll((F<String, Boolean>)s -> ac.forAll((F<Character, Boolean>)c -> "")); //fail
+        final String s3 = as.forAll((FSub<String, String>)s -> ac.forAll((FSub<Character, String>)c -> false)); //fail
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType24.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+TargetType24.java:34:37: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, boolean)
+TargetType24.java:35:45: compiler.err.cant.apply.symbol: kindname.method, forAll2, TargetType24.FSub<java.lang.Character,java.lang.String>, @945, kindname.class, TargetType24.Array<A>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String)))
+TargetType24.java:36:101: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Boolean))
+TargetType24.java:37:104: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType25.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda expression can appear in
+ * @compile TargetType25.java
+ */
+
+class TargetType25 {
+
+    interface F<A, B> {
+        B f(A a);
+    }
+
+    <Z> void m1(F<String, Z> f) {  }
+    <Z> void m2(F<String, F<String, Z>> f) {  }
+    <Z> void m3(F<String, F<String, F<String, Z>>> f) {  }
+
+    void testExprLambdaInMethodContext() {
+        m1(s1 -> 1);
+        m2(s1 -> s2 -> 1);
+        m3(s1 -> s2 -> s3 -> 1);
+    }
+
+    void testExprLambdaInAssignmentContext() {
+        F<String, Integer> fn1 = s1 -> 1;
+        F<String, F<String, Integer>> fn2 = s1 -> s2 -> 1;
+        F<String, F<String, F<String, Integer>>> fn3 = s1 -> s2 -> s3 -> 1;
+    }
+
+    void testStatementLambdaInMethodContext() {
+        m1(s1 -> { return 1; });
+        m2(s1 -> { return s2 -> { return 1; }; });
+        m3(s1 -> { return s2 -> { return s3 -> { return 1; }; }; });
+    }
+
+    void testStatementLambdaInAssignmentContext() {
+        F<String, Integer> fn1 = s1 -> { return 1; };
+        F<String, F<String, Integer>> fn2 = s1 -> { return s2 -> { return 1; }; };
+        F<String, F<String, F<String, Integer>>> fn3 = s1 -> { return s2 -> { return s3 -> { return 1; }; }; };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType26.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  case of cyclic type inference (lambda passed where inference var expected)
+ * @compile/fail/ref=TargetType26.out -XDrawDiagnostics TargetType26.java
+ */
+
+class TargetType26 {
+    interface SAM {
+       void m();
+    }
+
+    <Z> void call(Z z) { }
+
+    { call(() -> { }); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType26.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType26.java:16:7: compiler.err.cant.apply.symbol: kindname.method, call, Z, @340, kindname.class, TargetType26, (compiler.misc.cyclic.inference: Z)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType27.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  complex case of cyclic type inference (lambda returned where inference var expected)
+ * @compile/fail/ref=TargetType27.out -XDrawDiagnostics TargetType27.java
+ * @compile/fail/ref=TargetType27.out -XDrawDiagnostics -XDcomplexinference TargetType27.java
+ */
+
+class TargetType27 {
+    interface F<X, Y>  {
+        Y f(X a);
+    }
+
+    <A, R> F<A, R> m(F<A, R>  f) { return null; }
+
+    void test() {
+        m((String s1) ->  (String s2) ->  new Integer(1));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType27.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType27.java:18:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType27.F<A,R>, @490, kindname.class, TargetType27, (compiler.misc.cyclic.inference: R)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType28.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  target type inference in a case where lambda expression returns diamond
+ * @compile/fail/ref=TargetType28.out -XDrawDiagnostics TargetType28.java
+ */
+
+class TargetType28 {
+    static class SuperFoo<X> {}
+
+    static class Foo<X extends Number> extends SuperFoo<X> {}
+
+    interface A<X, Y> {
+       SuperFoo<Y> m(X x);
+    }
+
+    <Z, R> SuperFoo<R> apply(A<Z, R> ax, Z x) { return null; }
+
+    SuperFoo<String> ls = apply(x-> new Foo<>(), 1);
+    SuperFoo<Integer> li = apply(x-> new Foo<>(), 1);
+    SuperFoo<?> lw = apply(x-> new Foo<>(), 1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType28.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TargetType28.SuperFoo<java.lang.Number>, TargetType28.SuperFoo<java.lang.String>)
+TargetType28.java:21:33: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: TargetType28.SuperFoo<java.lang.Number>, TargetType28.SuperFoo<java.lang.Integer>)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType29.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check type-substitution in SAM type wildcards inference
+ * @compile TargetType29.java
+ */
+
+import java.util.*;
+
+class TargetType29 {
+    interface Reducer<E, V> {
+        public V reduce(E element, V value);
+    }
+
+    private static <E> int reduce(Iterable<? extends E> iterable, Reducer<? super E, Integer> reducer) { return 0;  }
+
+    void test(List<Integer> li) {
+        reduce(li, (e, v) -> e + v);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType30.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that target type is propagated through parenthesized expressions
+ * @compile TargetType30.java
+ */
+
+class TargetType30 {
+
+    interface SAM {
+        void m(int x);
+    }
+
+    void m(SAM s) { }
+
+    void testAssignmentContext() {
+        SAM s1 = (x-> { System.out.println("Hello!"); });
+        SAM s2 = ((x-> { System.out.println("Hello!"); }));
+        SAM s3 = (((x-> { System.out.println("Hello!"); })));
+    }
+
+    void testMethodContext() {
+        m((x-> { System.out.println("Hello!"); }));
+        m(((x-> { System.out.println("Hello!"); })));
+        m((((x-> { System.out.println("Hello!"); }))));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType31.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that target type of a cast is propagated through parenthesized expressions
+ * @compile TargetType31.java
+ */
+
+class TargetType31 {
+
+    interface SAM {
+        void m(int x);
+    }
+
+    void m(SAM s) { }
+
+    void testAssignmentContext() {
+        SAM s1 = (SAM)(x-> { System.out.println("Hello!"); });
+        SAM s2 = (SAM)((x-> { System.out.println("Hello!"); }));
+        SAM s3 = (SAM)(((x-> { System.out.println("Hello!"); })));
+    }
+
+    void testMethodContext() {
+        m((SAM)(x-> { System.out.println("Hello!"); }));
+        m((SAM)((x-> { System.out.println("Hello!"); })));
+        m((SAM)(((x-> { System.out.println("Hello!"); }))));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType32.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  target-typing and conditional operator
+ */
+
+public class TargetType32 {
+
+    interface A<X> {
+        X m();
+    }
+
+    interface B<X> extends A<X> {}
+
+    void m(A<Integer> a) { }
+    void m(B<String> b) { }
+
+    <Z extends Integer> void m2(A<Z> a) { }
+    <Z extends String> void m2(B<Z> b) { }
+
+    void m3(A<TargetType32> a) { }
+    void m3(B<String> b) { }
+
+    <Z> void m4(A<Z> a) { }
+    <Z extends String> void m4(B<Z> b) { }
+
+    int intRes() { return 42; }
+
+    void testLambda(boolean flag) {
+        A<Integer> c = flag ? (() -> 23) : (() -> 42);
+        m(flag ? (() -> 23) : (() -> 42));
+        m2(flag ? (() -> 23) : (() -> 23));
+    }
+
+    void testMethodRef(boolean flag) {
+        A<Integer> c = flag ? this::intRes : this::intRes;
+        m(flag ? this::intRes : this::intRes);
+        m2(flag ? this::intRes : this::intRes);
+    }
+
+    void testConstrRef(boolean flag) {
+        A<TargetType32> c = flag ? TargetType32::new : TargetType32::new;
+        m3(flag ? TargetType32::new : TargetType32::new);
+        m4(flag ? TargetType32::new : TargetType32::new);
+    }
+
+    public static void main(String[] args) {
+        TargetType32 test = new TargetType32();
+        test.testLambda(true);
+        test.testMethodRef(true);
+        test.testConstrRef(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType33.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  crash when incompatible method reference is found in conditional expression
+ * @compile/fail/ref=TargetType33.out -XDrawDiagnostics TargetType33.java
+ */
+
+class TargetType33 {
+
+    interface A<X> {
+        X m();
+    }
+
+    void m(A<Integer> a) { }
+    <Z> void m2(A<Z> a) { }
+
+    int intRes(Object o) { return 42; }
+
+    void testMethodRef(boolean flag) {
+        A<Integer> c = flag ? this::intRes : this::intRes;
+        m(flag ? this::intRes : this::intRes);
+        m2(flag ? this::intRes : this::intRes);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType33.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+TargetType33.java:21:31: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))
+TargetType33.java:21:46: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))
+TargetType33.java:22:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType33.A<java.lang.Integer>, @509, kindname.class, TargetType33, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))))
+TargetType33.java:23:9: compiler.err.cant.apply.symbol: kindname.method, m2, TargetType33.A<Z>, @557, kindname.class, TargetType33, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType34.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  spurious resolution diagnostics when diamond constructor contains poly expression
+ * @compile -XDcomplexinference TargetType34.java
+ */
+
+class TargetType34<X> {
+
+    TargetType34(X x) {}
+
+    Object next;
+
+    void test() {
+        new TargetType34<>(next==null ? null : null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType35.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  missing erasure on intersection supertype of generated lambda class
+ */
+public class TargetType35 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A {}
+
+    interface B {}
+
+    static class C implements A, B {}
+
+    static class D implements A, B {}
+
+    interface SAM<Y, X> {
+        Y invoke(X arg);
+    }
+
+    static class Sup {
+       <Z> Z m(Z z) { return z; }
+    }
+
+    static class Sub extends Sup {
+        <Z> Z m(Z z) { return z; }
+
+        void test(C c, D d) {
+            choose(c, d, x->x);
+            choose(c, d, this::m);
+            choose(c, d, super::m);
+        }
+
+        <T> void choose(T t1, T t2, SAM<T, T> t3) {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args)
+    {
+        new Sub().test(null, null);
+        assertTrue(assertionCount == 3);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType36.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, 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
+ * @ignore
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that target type of cast is propagated to conditional subexpressions
+ * @compile TargetType36.java
+ */
+class TargetType36 { //awaits spec wording on cast vs. poly
+
+    interface SAM {
+       int m(int i, int j);
+    }
+
+    void test() {
+        SAM s1 = (SAM)((a,b)->a+b);
+        SAM s2 = (SAM)(true? (SAM)((a,b)->a+b) : (SAM)((a,b)->a+b));
+        SAM s3 = (SAM)(true? (a,b)->a+b : (a,b)->a+b);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType37.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that cast conversion context is propagated to conditional subexpressions
+ * @compile TargetType37.java
+ */
+class TargetType37 {
+
+    interface I { }
+
+    void test(Object o, boolean cond) {
+        I i = (I)(cond ? o : o);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType38.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that cast conversion context does not affect compatibility of lambda
+ * @compile/fail/ref=TargetType38.out -XDrawDiagnostics TargetType38.java
+ */
+class TargetType38 {
+
+    interface I { }
+
+    interface SAM {
+        I m();
+    }
+
+    static Object m() { return null; }
+
+    void test() {
+        Object o1 = (SAM)()->new Object();
+        Object o2 = (SAM)TargetType38::m;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType38.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+TargetType38.java:19:30: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
+TargetType38.java:20:26: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType39.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that type-checking fails because of recursive analysis of stuck expressions
+  * @compile/fail/ref=TargetType39.out -XDrawDiagnostics TargetType39.java
+ */
+class TargetType39 {
+
+    interface I { }
+
+    interface SAM<A, R> {
+        R m(A a);
+    }
+
+    <U, V> void call(SAM<U, V> s) { }
+
+    void test(boolean cond, SAM<String, Void> ssv) {
+        call(cond ? x-> null : ssv);
+        call((String s)-> cond ? x-> null : ssv);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType39.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+TargetType39.java:19:9: compiler.err.cant.apply.symbol: kindname.method, call, TargetType39.SAM<U,V>, @442, kindname.class, TargetType39, (compiler.misc.cyclic.inference: U)
+TargetType39.java:20:9: compiler.err.cant.apply.symbol: kindname.method, call, TargetType39.SAM<U,V>, @479, kindname.class, TargetType39, (compiler.misc.cyclic.inference: V)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType40.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler silently crashes when void method is passed as argument in overloaded call site
+ * @compile/fail/ref=TargetType40.out -XDrawDiagnostics TargetType40.java
+ */
+
+class TargetType40 {
+    void m(String s) { }
+    void m(Integer i) { }
+
+    void void_method() {}
+
+    void test() {
+       m(void_method());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType40.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType40.java:16:21: compiler.err.void.not.allowed.here
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType41.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  out-of-order method checking should check as many arguments as possible
+ * @compile/fail/ref=TargetType41.out -XDrawDiagnostics TargetType41.java
+ */
+
+class TargetType41 {
+    <X> void m(String s, java.util.List<String> lx) { }
+
+    void test() {
+        m(1, new java.util.ArrayList<>());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType41.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType41.java:13:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.String,java.util.List<java.lang.String>, int,java.util.ArrayList<java.lang.Object>, kindname.class, TargetType41, (compiler.misc.infer.no.conforming.assignment.exists: X, (compiler.misc.inconvertible.types: int, java.lang.String))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType42.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  effects of speculative attribution are undone on a per-argument basis rather than on a per-resolution basis
+ * @compile TargetType42.java
+ */
+class TargetType42 {
+
+    interface SAM<X, Y> {
+      Y f(X x);
+    }
+
+    <Z> void m(SAM<String, SAM<Z, Object>> s, Z z) { }
+
+    void test(Object obj) {
+        m((x)->{ class Foo { }; return (x2)-> { new Foo(); return null; }; }, obj);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType43.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  recovery attribution step for unchecked arguments
+ * @compile/fail/ref=TargetType43.out -XDrawDiagnostics TargetType43.java
+ */
+class TargetType43 {
+
+    void m(Object o) { }
+
+    void test(Object obj) {
+        Object o = x-> { new NonExistentClass(x); return 5; };
+        m(x-> { new NonExistentClass(x); return 5; });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType43.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+TargetType43.java:13:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType43.java:13:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
+TargetType43.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Object, @359, kindname.class, TargetType43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf))
+TargetType43.java:14:21: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType44.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler throw AssertionError while backtracing from speculative attribution round
+ * @compile/fail/ref=TargetType44.out -XDrawDiagnostics TargetType44.java
+ */
+class TargetType44 {
+
+    interface Unary {
+        void m(int i1);
+    }
+
+    interface Binary {
+        void m(int i1, int i2);
+    }
+
+    void m(Unary u) { }
+    void m(Binary u) { }
+
+    void test() {
+        m(()-> { new Object() { }; }); //fail
+        m(x -> { new Object() { }; }); //ok
+        m((x, y) -> { new Object() { }; }); //ok
+        m((x, y, z) -> { new Object() { }; }); //fail
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType44.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+TargetType44.java:22:9: compiler.err.cant.apply.symbols: kindname.method, m, @458,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))}
+TargetType44.java:25:9: compiler.err.cant.apply.symbols: kindname.method, m, @597,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))}
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType45.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler crashes during flow analysis as it fails to report diagnostics during attribution
+ * @compile/fail/ref=TargetType45.out -XDrawDiagnostics TargetType45.java
+ */
+class TargetType45 {
+
+    interface Predicate<X> {
+        boolean apply(X x);
+    }
+
+    interface Mapper<X, Y> {
+        Y apply(X x);
+    }
+
+    class Foo<X> {
+        Foo<X> filter(Predicate<? super X> p) { return null; }
+    }
+
+    static <U, V> Predicate<U> compose(Predicate<? super V> pi, Mapper<? super U, ? extends V> m) { return null; }
+
+    static Predicate<Integer> isOdd = i -> i % 2 != 0;
+
+    void top10Counties(Foo<String> foos) {
+        foos.filter(compose(isOdd, (String e) -> e.length()));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType45.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+TargetType45.java:27:28: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U,V, (compiler.misc.inconvertible.types: TargetType45.Mapper<java.lang.String,java.lang.Integer>, TargetType45.Mapper<? super java.lang.Object,? extends java.lang.Integer>))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType46.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler doesn't report accessibility problem due to inaccessible target
+ * @compile/fail/ref=TargetType46.out -XDrawDiagnostics TargetType46.java
+ */
+import java.util.*;
+
+class TargetType46Outer {
+
+    private interface PI {
+       void m();
+    }
+
+    void m(PI p) { }
+    void m(List<PI> p) { }
+}
+
+class TargetType46 {
+    void test(TargetType46Outer outer) {
+        outer.m(()->{}); //access error
+        outer.m(this::g); //access error
+        outer.m(new ArrayList<>()); //ok
+        outer.m(Collections.emptyList()); //ok
+    }
+
+    void g() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType46.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+TargetType46.java:22:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
+TargetType46.java:23:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType47.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  spurious functional interface conversion errors with default methods in target type
+ * @compile TargetType47.java
+ */
+
+class TargetType47 {
+    interface A {
+        void a();
+        void b();
+        default void c() { };
+    }
+
+    interface B extends A {
+        default void b() { };
+    }
+
+    B b = ()-> {};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType48.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  spurious functional interface conversion errors with default methods in target type
+ * @compile TargetType48.java
+ */
+
+class TargetType48 {
+    interface I1 {
+        void a();
+        void b();
+        void c();
+    }
+
+    interface I2 extends I1 {
+        default void a() { }
+    }
+
+    interface I3 extends I2 {
+        default void b() { }
+    }
+
+    I3 i3 = ()->{ };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType49.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  javac accepts ill-formed lambda/method reference targets
+ * @compile/fail/ref=TargetType49.out -XDrawDiagnostics TargetType49.java
+ */
+class TargetType49 {
+
+    interface F {
+        default Object clone() { return null; }
+        void m();
+    }
+
+    F f1 = ()->{};
+    F f2 = this::g;
+
+    void g() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType49.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+TargetType49.java:15:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: clone(), java.lang.Object, clone(), TargetType49.F), public
+TargetType49.java:16:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: clone(), java.lang.Object, clone(), TargetType49.F), public
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType50.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,28 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  bad stuck check for method reference leads to javac crash
+ * @compile/fail/ref=TargetType50.out -XDrawDiagnostics TargetType50.java
+ */
+import java.util.*;
+
+class TargetType50 {
+
+    interface Factory<F> {
+        F make();
+    }
+
+    static class Sink<T> {
+        static <Z> Sink<Z> make() { return null; }
+    }
+
+    <Y, S extends Sink<Y>> List<Y> m(Factory<S> factory) {  }
+
+    void test() {
+        List<?> l1 = m(Sink::new);
+        List<?> l2 = m(Sink::make);
+        List<String> l3 = m(Sink::new);
+        List<String> l4 = m(Sink::make);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType50.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+TargetType50.java:25:28: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object)
+TargetType50.java:26:28: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object)
+2 errors
--- a/langtools/test/tools/javac/lambda/TestInvokeDynamic.java	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/lambda/TestInvokeDynamic.java	Sat Nov 17 19:01:03 2012 +0000
@@ -25,7 +25,9 @@
  * @test
  * @bug 7194586
  *
- * @summary Add back-end support for invokedynamic
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Add back-end support for invokedynamic
  *
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TestSelfRef.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  Check that self/forward references from lambda expressions behave
+ *          consistently w.r.t. local inner classes
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class TestSelfRef {
+
+    static int checkCount = 0;
+
+    enum RefKind {
+        SELF_LAMBDA("SAM s = x->{ System.out.println(s); };", true, false),
+        FORWARD_LAMBDA("SAM s = x->{ System.out.println(f); };\nObject f = null;", false, true),
+        SELF_ANON("Object s = new Object() { void test() { System.out.println(s); } };", true, false),
+        FORWARD_ANON("Object s = new Object() { void test() { System.out.println(f); } }; Object f = null;", false, true);
+
+        String refStr;
+        boolean selfRef;
+        boolean forwardRef;
+
+        private RefKind(String refStr, boolean selfRef, boolean forwardRef) {
+            this.refStr = refStr;
+            this.selfRef = selfRef;
+            this.forwardRef = forwardRef;
+        }
+    }
+
+    enum EnclosingKind {
+        TOPLEVEL("class C { #S }"),
+        MEMBER_INNER("class Outer { class C { #S } }"),
+        NESTED_INNER("class Outer { static class C { #S } }");
+
+        String enclStr;
+
+        private EnclosingKind(String enclStr) {
+            this.enclStr = enclStr;
+        }
+    }
+
+    enum InnerKind {
+        NONE("#R"),
+        LOCAL_NONE("class Local { #R }"),
+        LOCAL_MTH("class Local { void test() { #R } }"),
+        ANON_NONE("new Object() { #R };"),
+        ANON_MTH("new Object() { void test() { #R } };");
+
+        String innerStr;
+
+        private InnerKind(String innerStr) {
+            this.innerStr = innerStr;
+        }
+
+        boolean inMethodContext(SiteKind sk) {
+            switch (this) {
+                case LOCAL_MTH:
+                case ANON_MTH: return true;
+                case NONE: return sk != SiteKind.NONE;
+                default:
+                    return false;
+            }
+        }
+    }
+
+    enum SiteKind {
+        NONE("#I"),
+        STATIC_INIT("static { #I }"),
+        INSTANCE_INIT("{ #I }"),
+        CONSTRUCTOR("C() { #I }"),
+        METHOD("void test() { #I }");
+
+        String siteStr;
+
+        private SiteKind(String siteStr) {
+            this.siteStr = siteStr;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (EnclosingKind ek : EnclosingKind.values()) {
+            for (SiteKind sk : SiteKind.values()) {
+                if (sk == SiteKind.STATIC_INIT && ek == EnclosingKind.MEMBER_INNER)
+                    continue;
+                for (InnerKind ik : InnerKind.values()) {
+                    if (ik != InnerKind.NONE && sk == SiteKind.NONE)
+                        break;
+                    for (RefKind rk : RefKind.values()) {
+                        new TestSelfRef(ek, sk, ik, rk).run(comp, fm);
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    EnclosingKind ek;
+    SiteKind sk;
+    InnerKind ik;
+    RefKind rk;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    TestSelfRef(EnclosingKind ek, SiteKind sk, InnerKind ik, RefKind rk) {
+        this.ek = ek;
+        this.sk = sk;
+        this.ik = ik;
+        this.rk = rk;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String bodyTemplate = "interface SAM { void test(Object o); }\n#B";
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = bodyTemplate.replace("#B",
+                    ek.enclStr.replace("#S", sk.siteStr.replace("#I", ik.innerStr.replace("#R", rk.refStr))));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        //illegal forward ref
+        boolean errorExpected = ik.inMethodContext(sk) &&
+                (rk.selfRef || rk.forwardRef);
+        if (diagChecker.errorFound != errorExpected) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/VoidCompatibility.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that that void compatibility affects overloading as expected
+ * @compile/fail/ref=VoidCompatibility.out -XDrawDiagnostics VoidCompatibility.java
+ */
+class VoidCompatibility {
+
+    interface Runnable { void run(); } //1
+    interface Thunk<T> { T get(); } //2
+
+    void schedule(Runnable r) { }
+    void schedule(Thunk<?> t) { }
+
+    void test() {
+        schedule(() -> System.setProperty("done", "true")); //2
+        schedule(() -> { System.setProperty("done", "true"); }); //1
+        schedule(() -> { return System.setProperty("done", "true"); }); //2
+        schedule(() -> System.out.println("done")); //1
+        schedule(() -> { System.out.println("done"); }); //1
+        schedule(Thread::yield); //1
+        schedule(Thread::getAllStackTraces); //ambiguous
+        schedule(Thread::interrupted); //1 (most specific)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/VoidCompatibility.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+VoidCompatibility.java:23:9: compiler.err.ref.ambiguous: schedule, kindname.method, schedule(VoidCompatibility.Runnable), VoidCompatibility, kindname.method, schedule(VoidCompatibility.Thunk<?>), VoidCompatibility
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/abort/Abort.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  check that all diagnostics are dumped to output when compiler exits abruptly
+ */
+
+import com.sun.source.util.JavacTask;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class Abort {
+
+    public static void main(String... args) throws Exception {
+
+        String SCRATCH_DIR = System.getProperty("user.dir");
+        JavaCompiler javacTool = ToolProvider.getSystemJavaCompiler();
+        java.io.File testDir = new java.io.File(SCRATCH_DIR);
+
+        sourceA.dumpTo(testDir);
+        sourceB.dumpTo(testDir);
+
+        DiagnosticChecker diagChecker = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)javacTool.getTask(null, null, diagChecker,
+                Arrays.asList("-XDrawDiagnostics", "-cp", testDir.getAbsolutePath()),
+                null, Arrays.asList(sourceA.asJFO(testDir)));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            //ignore abort exception thrown by javac
+        }
+
+        if (!diagChecker.errorFound) {
+            throw new AssertionError("Missing diagnostic");
+        }
+    }
+
+    static class JavaSource {
+        String contents;
+        String filename;
+
+        public JavaSource(String filename, String contents) {
+            this.filename =  filename;
+            this.contents = contents;
+        }
+
+        void dumpTo(java.io.File loc) throws Exception {
+            java.io.File file = new java.io.File(loc, filename);
+            java.io.BufferedWriter bw = new java.io.BufferedWriter(new java.io.FileWriter(file));
+            bw.append(contents);
+            bw.close();
+        }
+
+        SimpleJavaFileObject asJFO(java.io.File dir) {
+            return new SimpleJavaFileObject(URI.create(dir.getAbsolutePath() + "/" + filename), JavaFileObject.Kind.SOURCE) {
+                @Override
+                public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+                    return contents;
+                }
+            };
+        }
+    }
+
+    static JavaSource sourceA = new JavaSource("Abort.java", "public class Abort {\n" +
+                                "    public static void main(String[] args) {\n" +
+                                "        System.out.println(C.m());\n" +
+                                "    }\n" +
+                                "}");
+
+    static JavaSource sourceB = new JavaSource("C.java", "package com.example;\n" +
+                                "public class C {\n" +
+                                "    public static String m() { return null; }\n" +
+                                "}");
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+                    diagnostic.getCode().contains("compiler.err.cant.access")) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/badMemberRefBytecode/Main.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,9 @@
+import java.util.Collections;
+
+public class Main {
+
+    public static void main(String[] args) {
+        Collections.<String>sort(null, String::compareTo);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that classfiles with member ref CP entries are read correctly
+ * @author  Jan Lahoda
+ * @compile Main.java
+ * @compile Use.java
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/badMemberRefBytecode/Use.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+public class Use {
+    private Main m;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/Helper.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+/*SAM types:
+         1. An interface that has a single abstract method
+         2. Having more than one distinct methods, but only one is "real", the others are overriden public methods in Object - example: Comparator<T>
+         3. Having more than one methods due to inheritance, but they have the same signature
+         4. Having more than one methods due to inheritance, but one of them has a subsignature of all other methods
+                a) parameter types compatible
+                b) return type substitutable
+                c) thrown type not conflicting with the thrown clause of any other method
+                d) mixed up
+         5. Type-dependent SAM types
+  non-SAM types:
+         6. An interface that has a single abstract method, which is also public method in Object
+         7. Having more than one methods due to inheritance, and none of them has a subsignature of all other methods
+*/
+
+import java.util.List;
+import java.util.Collection;
+import java.sql.SQLException;
+import java.sql.SQLTransientException;
+import java.util.concurrent.TimeoutException;
+import java.io.*;
+
+interface A {int getOldest(List<Number> list);}
+interface B {int getOldest(List list);}
+interface C {int getOldest(List<?> list);}
+interface D {int getOldest(List<Integer> list);}
+interface E {int getOldest(Collection<?> collection);}
+//Not SAM type, case #7
+interface DE extends D, E {}
+
+interface Foo {int getAge(Number n);}
+interface Bar {int getAge(Integer i);}
+//Not SAM type, case #7
+interface FooBar extends Foo, Bar {}
+
+//Not SAM type, case #6
+interface Planet {boolean equals(Object o);}
+
+// SAM type interfaces:
+// type #2:
+//only one abstract non-Ojbect method getAge()
+interface Mars<T> extends Planet {int getAge(T t);}
+//only one abstract non-Ojbect method increment()
+interface Jupiter {
+    boolean equals(Object o);
+    String toString();
+    int increment(int i);
+}
+
+// type #3:
+interface X {int getTotal(List<String> arg);}
+interface Y {int getTotal(List<String> strs);}
+//SAM type ([List<String>], int, {})
+interface XY extends X, Y {}
+//SAM type ([List<String>], int, {})
+interface XYZ extends X, Y, XY {}
+
+// type #4 a):
+//SAM type ([List], int, {})
+interface AB extends A, B {}
+
+// type #4 b):
+interface F {Number getValue(String str);}
+interface G {Integer getValue(String str);}
+interface H {Serializable getValue(String str);}
+interface I {Object getValue(String str);}
+//SAM type ([String], Integer, {})
+interface FGHI extends F, G, H, I {}
+
+interface J {List<Number> getAll(String str);}
+interface K {List<?> getAll(String str);}
+interface L {List getAll(String str);}
+interface M {Collection getAll(String str);}
+//SAM type ([String], List<Number>/List, {}) - the return type is flexible to some degree
+interface JK extends J, K {}
+//SAM type ([String], List<Number>/List, {})
+interface JL extends J, L {}
+//SAM type ([String], List<Number>/List, {})
+interface JKL extends J, K, L {}
+//SAM type ([String], List<Number>/List, {})
+interface JKLM extends J, K, L, M {}
+
+// type #4 c):
+interface N {String getText(File f) throws IOException;}
+interface O {String getText(File f) throws FileNotFoundException;}
+interface P {String getText(File f) throws NullPointerException;}
+//SAM type ([File], String, {FileNotFoundException})
+interface NO extends N, O {}
+//SAM type ([File], String, {})
+interface NOP extends N, O, P {}
+
+interface Boo {int getAge(String s) throws IOException;}
+interface Doo {int getAge(String s) throws SQLException;}
+//SAM type ([String], int, {})
+interface BooDoo extends Boo, Doo {}
+
+// type #4 d):
+interface Q {Iterable m(Iterable<String> arg);}
+interface R {Iterable<String> m(Iterable arg);}
+//SAM type ([Iterable], Iterable<String>/Iterable, {})
+interface QR extends Q, R {}
+
+interface U {Collection foo(List<String> arg) throws IOException, SQLTransientException;}
+interface V {List<?> foo(List<String> arg) throws EOFException, SQLException, TimeoutException;}
+interface W {List<String> foo(List arg) throws Exception;}
+//SAM type ([List<String>], List<String>/List, {EOFException, SQLTransientException})
+interface UV extends U, V {}
+// SAM type ([List], List<String>/List, {EOFException, SQLTransientException})
+interface UVW extends U, V, W {}
+
+// type #5:
+// Not a SAM because sam-ness depends on instantiation of type-variables
+interface Qoo<T> {void m(T arg);}
+interface Roo<S extends Number> {void m(S arg);}
+interface QooRoo<T1, T2 extends Number, T3> extends Qoo<T1>, Roo<T2> {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *   This test is for lambda expressions
+ * @compile LambdaTest1.java
+ * @run main LambdaTest1
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaTest1 {
+    public static void main(String[] args) {
+
+        LambdaTest1 test = new LambdaTest1();
+
+        test.method2((int n) -> { });
+        test.method2((int n) -> { });
+        test.method2((int n) -> { return; }); // ";" is mandatory here
+        test.method2((int n) -> { System.out.println(n); }); // ";" is optional here
+        test.method2(n -> { System.out.println(n); }); //warning, explict type required for n?
+
+        test.method3(()-> { System.out.println("implementing VoidVoid.vvMethod()"); });
+        test.method3(() -> {});
+
+        test.method4(()-> 42);
+        test.method4(()-> { return 42; });//";" is mandatory here
+
+        test.method5((int n)-> n+1);
+        test.method5((int n) -> 42);
+        test.method5((int n) -> { return 42; });
+        test.method5(
+            (int n) -> { //"{" optional here
+                if(n > 0)
+                    return n++;
+                else
+                    return n--;
+            }
+        );
+
+        Runnable r = ()-> { System.out.println("Runnable.run() method implemented"); };
+        r.run();
+        ((Runnable)()-> { System.out.println("Runnable.run() method implemented"); }).run();
+    }
+
+    void method2(VoidInt a) {
+        System.out.println("method2()");
+        final int N = 1;
+        int n = 2; //effectively final variable
+        System.out.println("method2() \"this\":" + this);
+        ((Runnable)
+            ()->{
+                System.out.println("inside lambda \"this\":" + this);
+                System.out.println("inside lambda accessing final variable N:" + N);
+                System.out.println("inside lambda accessing effectively final variable n:" + n);
+            }
+        ).run();
+        //n++; //compile error if n is modified
+        a.viMethod(2);
+    }
+
+    void method3(VoidVoid a) {
+        System.out.println("method3()");
+        a.vvMethod();
+    }
+
+    void method4(IntVoid a) {
+        System.out.println("method4()");
+        System.out.println(a.ivMethod());
+    }
+
+    void method5(IntInt a) {
+        System.out.println("method5()");
+        System.out.println(a.iiMethod(5));
+    }
+
+
+    //SAM type interfaces
+    interface VoidInt {
+        void viMethod(int n);
+    }
+
+    interface VoidVoid {
+        void vvMethod();
+    }
+
+    interface IntVoid {
+        int ivMethod();
+    }
+
+    interface IntInt {
+        int iiMethod(int n);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is to verify invalid lambda expressions
+ * @compile/fail/ref=LambdaTest1_neg1.out -XDrawDiagnostics LambdaTest1_neg1.java
+ */
+
+import java.util.Comparator;
+
+public class LambdaTest1_neg1 {
+    void method() {
+        Comparator<Number> c = (Number n1, Number n2) -> { 42; } //compile error, not a statement
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+LambdaTest1_neg1.java:13:60: compiler.err.not.stmt
+LambdaTest1_neg1.java:13:65: compiler.err.expected: ';'
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is to verify mis-use of accessing "this" from within lambda expression
+ * @compile/fail/ref=LambdaTest1_neg2.out -XDrawDiagnostics LambdaTest1_neg2.java
+ */
+
+public class LambdaTest1_neg2 {
+    static void method() {
+        ((Runnable)
+            ()-> {
+                Object o = this; //use "this" inside lambda expression which is inside a static method, not allowed
+            }
+        ).run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+LambdaTest1_neg2.java:13:28: compiler.err.non-static.cant.be.ref: kindname.variable, this
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is to verify mis-use of capturing local variable within lambda expression
+ * @compile/fail/ref=LambdaTest1_neg3.out -XDrawDiagnostics LambdaTest1_neg3.java
+ */
+
+public class LambdaTest1_neg3 {
+    void method() {
+        int n = 2; //effectively final variable
+        ((Runnable)
+            ()-> {
+                int n2 = n; //inside lambda accessing effectively final variable;
+            }
+        ).run();
+        n++; //compile error if n is modified
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+LambdaTest1_neg3.java:14:26: compiler.err.cant.ref.non.effectively.final.var: n, (compiler.misc.lambda)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types 2 and 3, see Helper.java for SAM types
+ * @compile LambdaTest2_SAM1.java Helper.java
+ * @run main LambdaTest2_SAM1
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.*;
+
+public class LambdaTest2_SAM1 {
+    private static List<String> strs = new ArrayList<String>();
+    private static List<File> files = new ArrayList<File>();
+
+    public static void main(String[] args) {
+        strs.add("copy");
+        strs.add("paste");
+        strs.add("delete");
+        strs.add("rename");
+
+        files.add(new File("a.txt"));
+        files.add(new File("c.txt"));
+        files.add(new File("b.txt"));
+
+        //type #2: Comparator<T>
+        Collections.sort(files, (File f1, File f2) -> f1.getName().compareTo(f2.getName()));
+        for(File f : files)
+            System.out.println(f.getName());
+        System.out.println();
+        Collections.sort(files, (File f1, File f2) -> (int)(f1.length() - f2.length()));
+        for(File f : files)
+            System.out.println(f.getName() + " " + f.length());
+        System.out.println();
+
+        LambdaTest2_SAM1 test = new LambdaTest2_SAM1();
+
+        //type #2:
+        test.methodMars((File f) -> {
+            System.out.println("implementing Mars<File>.getAge(File f)...");
+            return (int)f.length();
+        });
+        test.methodJupiter((int n) -> n+1);
+
+        //type #3:
+        test.methodXY((List<String> strList) -> strList.size() );
+        test.methodXYZ((List<String> strList) -> 20 );
+    }
+
+    //type #2:
+    void methodMars(Mars<File> m) {
+        System.out.println("methodMars(): SAM type interface Mars object instantiated: " + m);
+        System.out.println(m.getAge(new File("a.txt")));
+    }
+
+    //type #2:
+    void methodJupiter(Jupiter j) {
+        System.out.println("methodJupiter(): SAM type interface Jupiter object instantiated: " + j);
+        System.out.println(j.increment(33));
+    }
+
+    //type #3:
+    void methodXY(XY xy) {
+        System.out.println("methodXY(): SAM type interface XY object instantiated: " + xy);
+        System.out.println(xy.getTotal(strs));
+    }
+
+    //type #3:
+    void methodXYZ(XYZ xyz) {
+        System.out.println("methodXYZ(): SAM type interface XYZ object instantiated: " + xyz);
+        System.out.println(xyz.getTotal(strs));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types #4, see Helper.java for SAM types
+ * @compile LambdaTest2_SAM2.java Helper.java
+ * @run main LambdaTest2_SAM2
+ */
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.concurrent.TimeoutException;
+import java.io.*;
+import java.sql.SQLException;
+import java.sql.SQLTransientException;
+
+public class LambdaTest2_SAM2 {
+    private static List<String> strs = new ArrayList<String>();
+
+    public static void main(String[] args) {
+        strs.add("copy");
+        strs.add("paste");
+        strs.add("delete");
+        strs.add("rename");
+
+        LambdaTest2_SAM2 test = new LambdaTest2_SAM2();
+
+        //type #4 a):
+        test.methodAB((List list) -> 100);
+
+        //type #4 b):
+        test.methodFGHI((String s) -> new Integer(22));
+        //type #4 b):
+        test.methodJK((String s) -> new ArrayList<Number>());
+        test.methodJK((String s) -> new ArrayList());
+        //type #4 b):
+        test.methodJL((String s) -> new ArrayList<Number>());
+        test.methodJL((String s) -> new ArrayList());
+        //type #4 b):
+        test.methodJKL((String s) -> new ArrayList<Number>());
+        test.methodJKL((String s) -> new ArrayList());
+        //type #4 b):
+        test.methodJKLM((String s) -> new ArrayList<Number>());
+        test.methodJKLM((String s) -> new ArrayList());
+
+        // tyep #4 c):
+        test.methodNO((File f) -> {
+                String temp = null;
+                StringBuffer sb = new StringBuffer();
+                try
+                {
+                    BufferedReader br = new BufferedReader(new FileReader(f));
+                    while((temp=br.readLine()) != null)
+                        sb.append(temp).append("\n");
+                }
+                catch(FileNotFoundException fne){throw fne;}
+                catch(IOException e){e.printStackTrace();}
+                return sb.toString();
+        });
+        // tyep #4 c):
+        test.methodNOP((File f) -> {
+                String temp = null;
+                StringBuffer sb = new StringBuffer();
+                try
+                {
+                    BufferedReader br = new BufferedReader(new FileReader(f));
+                    while((temp=br.readLine()) != null)
+                        sb.append(temp).append("\n");
+                }
+                catch(IOException e){e.printStackTrace();}
+                return sb.toString();
+        });
+        // type #4 c):
+        test.methodBooDoo((String s) -> s.length());
+
+        //type #4 d):
+        test.methodQR((Iterable i) -> new ArrayList<String>());
+        test.methodQR((Iterable i) -> new ArrayList());
+        //type #4 d):
+        test.methodUV((List<String> list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList<String>();
+        });
+        test.methodUV((List<String> list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList();
+        });
+        //type #4 d):
+        test.methodUVW((List list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList<String>();
+        });
+        test.methodUVW((List list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList();
+        });
+    }
+
+    private void exceptionMethod1() throws EOFException{
+    }
+
+    private void exceptionMethod2() throws SQLTransientException{
+    }
+
+    //type #4 a): SAM type ([List], int, {})
+    void methodAB (AB ab) {
+        System.out.println("methodAB(): SAM type interface AB object instantiated: " + ab);
+        System.out.println(ab.getOldest(strs));
+    }
+
+    //type #4 b): SAM type ([String], Integer, {})
+    void methodFGHI(FGHI f) {
+        System.out.println("methodFGHI(): SAM type interface FGHI object instantiated: " + f);
+        System.out.println(f.getValue("str"));
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJK(JK jk) {
+        System.out.println("methodJK(): SAM type interface JK object instantiated: " + jk);
+        for(Number n : jk.getAll("in"))
+            System.out.println(n);
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJL(JL jl) {
+        System.out.println("methodJL(): SAM type interface JL object instantiated: " + jl);
+        for(Number n : ((J)jl).getAll("in")) //cast should be redundant - see 7062745
+            System.out.println(n);
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJKL(JKL jkl) { //commented - see 7062745
+        System.out.println("methodJKL(): SAM type interface JKL object instantiated: " + jkl);
+        for(Number n : ((J)jkl).getAll("in"))
+            System.out.println(n);
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJKLM(JKLM jklm) { //commented - see 7062745
+        System.out.println("methodJKLM(): SAM type interface JKLM object instantiated: " + jklm);
+        for(Number n : ((J)jklm).getAll("in"))
+            System.out.println(n);
+    }
+
+    //type #4 c): SAM type ([File], String, {FileNotFoundException})
+    void methodNO(NO no) {
+        System.out.println("methodNO(): SAM type interface \"NO\" object instantiated: " + no);
+        try {
+            System.out.println("text=" + no.getText(new File("a.txt")));
+            System.out.println("got here, no exception thrown");
+        }
+        catch(FileNotFoundException e){e.printStackTrace();}
+    }
+
+    //type #4 c): SAM type ([File]), String, {})
+    void methodNOP(NOP nop) {
+        System.out.println("methodNOP(): SAM type interface \"NOP\" object instantiated: " + nop);
+        System.out.println("text=" + nop.getText(new File("a.txt")));
+    }
+
+    //type #4 c): SAM type ([String], int, {})
+    void methodBooDoo(BooDoo bd) {
+        System.out.println("methodBooDoo(): SAM type interface BooDoo object instantiated: " + bd);
+        System.out.println("result=" + bd.getAge("lambda"));
+    }
+
+    //type #4 d): SAM type ([Iterable], Iterable<String>, {})
+    void methodQR(QR qr) {
+        System.out.println("methodQR(): SAM type interface QR object instantiated: " + qr);
+        System.out.println("Iterable returned: " + qr.m(new SQLException()));
+    }
+
+    //type #4 d): SAM type ([List<String>], List<String>/List, {EOFException, SQLTransientException})
+    void methodUV(UV uv) {
+        System.out.println("methodUV(): SAM type interface UV object instantiated: " + uv);
+        try{
+            System.out.println("result returned: " + uv.foo(strs));
+        }catch(EOFException e){
+            System.out.println(e.getMessage());
+        }catch(SQLTransientException ex){
+            System.out.println(ex.getMessage());
+        }
+    }
+
+    //type #4 d): SAM type ([List], List<String>/List, {EOFException, SQLTransientException})
+    void methodUVW(UVW uvw) {
+        System.out.println("methodUVW(): SAM type interface UVW object instantiated: " + uvw);
+        try{
+            System.out.println("passing List<String>: " + uvw.foo(strs));
+            System.out.println("passing List: " + uvw.foo(new ArrayList()));
+        }catch(EOFException e){
+            System.out.println(e.getMessage());
+        }catch(SQLTransientException ex){
+            System.out.println(ex.getMessage());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types #5 and instantiating non-SAM types #7 through inner class,
+             see Helper.java for SAM types
+ * @compile LambdaTest2_SAM3.java Helper.java
+ * @run main LambdaTest2_SAM3
+ */
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaTest2_SAM3 {
+    private static List<String> strs = new ArrayList<String>();
+    private static List<Integer> integers = new ArrayList<Integer>();
+
+    public static void main(String[] args) {
+        LambdaTest2_SAM3 test = new LambdaTest2_SAM3();
+
+        //type #7, Not SAM-convertible, through inner class only:
+        test.methodFooBar(new FooBar() {
+                public int getAge(Number n) {
+                    System.out.println("getAge(Number n) called");
+                    return 100;
+                }
+                public int getAge(Integer i) {
+                    System.out.println("getAge(Integer i) called");
+                    return 200;
+                }
+            }
+        );
+
+        //type #7:
+        test.methodDE(new DE(){
+                public int getOldest(List<Integer > list) {
+                    System.out.println("getOldest(List<Integer> list) called");
+                    return 100;
+                }
+                public int getOldest(Collection<?> collection) {
+                    System.out.println("getOldest(Collection<?> collection) called");
+                    return 200;
+                }
+            }
+        );
+
+    }
+
+    //type #7: Not SAM type
+    void methodFooBar(FooBar fb) {
+        System.out.println("methodFooBar(): interface FooBar object instantiated: " + fb);
+        System.out.println("result=" + fb.getAge(new Byte("10")));
+        System.out.println("result=" + fb.getAge(new Integer(10)));
+    }
+
+    //type #7: Not SAM type
+    void methodDE (DE de) {
+        System.out.println("methodDE(): interface DE object instantiated: " + de);
+        System.out.println(de.getOldest(integers));
+        System.out.println(de.getOldest(strs));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types #5 and instantiating non-SAM types #7 through inner class,
+             see Helper.java for SAM types
+ * @compile/fail/ref=LambdaTest2_neg1.out -XDrawDiagnostics LambdaTest2_neg1.java Helper.java
+ */
+
+public class LambdaTest2_neg1 {
+
+    public static void main(String[] args) {
+        LambdaTest2_neg1 test = new LambdaTest2_neg1();
+        //not convertible - QooRoo is not a SAM
+        test.methodQooRoo((Integer i) -> { });
+    }
+
+    void methodQooRoo(QooRoo<Integer, Integer, Void> qooroo) { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+LambdaTest2_neg1.java:15:13: compiler.err.cant.apply.symbol: kindname.method, methodQooRoo, QooRoo<java.lang.Integer,java.lang.Integer,java.lang.Void>, @531, kindname.class, LambdaTest2_neg1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, QooRoo)))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying a non-SAM type 6: An interface that has a single abstract method, which is also public method in Object
+ * @compile/fail/ref=NonSAM1.out -XDrawDiagnostics NonSAM1.java Helper.java
+ */
+
+public class NonSAM1 {
+    void method() {
+        Planet n = (Object o) -> true;
+        System.out.println("never reach here " + n);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM1.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+NonSAM1.java:11:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, Planet))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying a non-SAM type: Having more than one methods due to inheritance, and none of them has a subsignature of all other methods
+ * @compile/fail/ref=NonSAM2.out -XDrawDiagnostics NonSAM2.java Helper.java
+ */
+
+import java.util.List;
+
+interface Foo1 { int getAge(String s);}
+interface Bar1 { Integer getAge(String s);}
+interface Foo1Bar1 extends Foo1, Bar1 {} //types Bar1 and Foo1 are incompatible; both define getAge(String), but with unrelated return types
+
+interface AC extends A, C {} //name clash: getOldest(List<?>) in C and getOldest(List<Number>) in A have the same erasure, yet neither overrides the other
+interface ABC extends A, B, C {} //name clash: getOldest(List<?>) in C and getOldest(List<Number>) in A have the same erasure, yet neither overrides the other
+interface AD extends A, D {} //name clash: getOldest(List<Integer>) in D and getOldest(List<Number>) in A have the same erasure, yet neither overrides the other
+
+interface Foo2<T> { void m(T arg);}
+interface Bar2<S> { void m(S arg);}
+interface Foo2Bar2<T1, T2> extends Foo2<T1>, Bar2<T2> {} //name clash: m(S) in Bar and m(T) in Foo have the same erasure, yet neither overrides the other
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,6 @@
+NonSAM2.java:13:1: compiler.err.types.incompatible.diff.ret: Bar1, Foo1, getAge(java.lang.String)
+NonSAM2.java:15:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<?>), C, getOldest(java.util.List<java.lang.Number>), A
+NonSAM2.java:16:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<?>), C, getOldest(java.util.List<java.lang.Number>), A
+NonSAM2.java:17:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<java.lang.Integer>), D, getOldest(java.util.List<java.lang.Number>), A
+NonSAM2.java:21:1: compiler.err.name.clash.same.erasure.no.override: m(S), Bar2, m(T), Foo2
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying a non-SAM type: Having overloaded methods due to inheritance
+ * @compile/fail/ref=NonSAM3.out -XDrawDiagnostics NonSAM3.java Helper.java
+ */
+
+import java.util.Collection;
+import java.util.List;
+
+public class NonSAM3 {
+    void method() {
+        //all of the following will have compile error: "the target type of a lambda conversion has multiple non-overriding abstract methods"
+        FooBar fb = (Number n) -> 100;
+        FooBar fb2 = (Integer i) -> 100;
+        DE de = (List<Integer> list) -> 100;
+        DE de2 = (List<?> list) -> 100;
+        DE de3 = (List list) -> 100;
+        DE de4 = (Collection<Integer> collection) -> 100;
+        DE de5 = (Collection<?> collection) -> 100;
+        DE de6 = (Collection collection) -> 100;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM3.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,9 @@
+NonSAM3.java:15:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, FooBar))
+NonSAM3.java:16:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, FooBar))
+NonSAM3.java:17:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:18:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:19:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:20:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:21:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:22:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+8 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test that lambda conversion is only for SAM interface, not abstract class
+ * @compile/fail/ref=AbstractClass_neg.out -XDrawDiagnostics AbstractClass_neg.java
+ */
+
+public class AbstractClass_neg {
+
+    abstract class SAM {
+        abstract int m();
+    }
+
+    void test() {
+        SAM s = ()-> 6;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+AbstractClass_neg.java:16:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test accessing non-static variable from lambda expressions in static context
+ * @compile/fail/ref=AccessNonStatic_neg.out -XDrawDiagnostics AccessNonStatic_neg.java
+ */
+
+public class AccessNonStatic_neg {
+
+    private int n = 0;
+
+    static {
+        ((Runnable) ()-> {
+            System.out.println(this);
+            System.out.println(n);
+        }).run();
+    }
+
+    public static void test() {
+        ((Runnable) ()-> {
+            Object o = this;
+            n++;
+        }).run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+AccessNonStatic_neg.java:15:32: compiler.err.non-static.cant.be.ref: kindname.variable, this
+AccessNonStatic_neg.java:16:32: compiler.err.non-static.cant.be.ref: kindname.variable, n
+AccessNonStatic_neg.java:22:24: compiler.err.non-static.cant.be.ref: kindname.variable, this
+AccessNonStatic_neg.java:23:13: compiler.err.non-static.cant.be.ref: kindname.variable, n
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Negative test of capture of "effectively final" local variable in lambda expressions
+ * @compile/fail/ref=EffectivelyFinal_neg.out -XDrawDiagnostics EffectivelyFinal_neg.java
+ */
+
+public class EffectivelyFinal_neg {
+
+    void test() {
+        String s = "a";
+        String s2 = "a";
+        int n = 1;
+        ((Runnable)
+            ()-> {
+                s2 = "b"; //re-assign illegal here
+                System.out.println(n);
+                System.out.println(s);
+                s = "b"; // not effectively final
+            }
+        ).run();
+        n = 2; // not effectively final
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+EffectivelyFinal_neg.java:17:17: compiler.err.cant.ref.non.effectively.final.var: s2, (compiler.misc.lambda)
+EffectivelyFinal_neg.java:18:36: compiler.err.cant.ref.non.effectively.final.var: n, (compiler.misc.lambda)
+EffectivelyFinal_neg.java:19:36: compiler.err.cant.ref.non.effectively.final.var: s, (compiler.misc.lambda)
+EffectivelyFinal_neg.java:20:17: compiler.err.cant.ref.non.effectively.final.var: s, (compiler.misc.lambda)
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression1.out -XDrawDiagnostics InvalidExpression1.java
+ */
+
+import java.util.Comparator;
+
+public class InvalidExpression1 {
+
+    void test() {
+        Comparator<Number> c = (Number n1, Number n2)-> { 42; }; //not a statement
+        Comparator<Number> c = (Number n1, Number n2)-> { return 42 }; //";" expected
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+InvalidExpression1.java:14:59: compiler.err.not.stmt
+InvalidExpression1.java:15:68: compiler.err.expected: ';'
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression3.out -XDrawDiagnostics InvalidExpression3.java
+ */
+
+import java.util.Comparator;
+
+public class InvalidExpression3 {
+
+    void test() {
+        Comparator<Integer> c2 = (Integer i1, Integer i2) -> { return "0"; }; //return type need to match
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+InvalidExpression3.java:14:71: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, int))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression4.out -XDrawDiagnostics InvalidExpression4.java
+ */
+
+public class InvalidExpression4 {
+
+    interface SAM {
+        void m(int i);
+    }
+
+    void test() {
+        SAM s = (Integer i) -> { }; //parameters not match, boxing not allowed here
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+InvalidExpression4.java:16:17: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression5.out -XDrawDiagnostics InvalidExpression5.java
+ */
+
+public class InvalidExpression5 {
+
+    void test() {
+        Object o = (int n) -> { }; // Invalid target type
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+InvalidExpression5.java:12:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression6.out -XDrawDiagnostics InvalidExpression6.java
+ */
+
+public class InvalidExpression6 {
+
+    interface SAM {
+        void m(int i);
+    }
+
+    void test() {
+        SAM s = (int n) -> { break; }; //break not allowed
+        s = (int n) -> { continue; }; //continue not allowed
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,3 @@
+InvalidExpression6.java:16:30: compiler.err.break.outside.switch.loop
+InvalidExpression6.java:17:26: compiler.err.cont.outside.loop
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test lambda expressions for existing SAM interfaces like Runnable and Comparator<T>
+ * @compile LambdaTest1.java
+ * @run main LambdaTest1
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Date;
+
+public class LambdaTest1 {
+
+    private static String assertionStr = "";
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private static void test1(Runnable r) {
+        r.run();
+    }
+
+    void test2(Object o) {
+        if(o instanceof Runnable)
+            ((Runnable)o).run();
+    }
+
+    Runnable test3() {
+        return ()-> { assertionStr += "Runnable6"; };
+    }
+
+    public static void main(String[] args) {
+
+        //lambda expressions for SAM interface Runnable:
+        //assign:
+        Runnable r = ()-> { assertionStr += "Runnable1 "; };
+        r.run();
+
+        //cast:
+        ((Runnable)()-> { assertionStr += "Runnable2 "; }).run();
+
+        Object o = (Runnable)()-> {};
+
+        o = (Runnable)()-> {
+                switch (assertionStr) {
+                    case "Runnable1 Runnable2 ":
+                        assertionStr += "Runnable3 ";
+                        break;
+                    default:
+                        throw new AssertionError();
+                }
+                return;
+            };
+
+        //method parameter:
+        test1(()-> { assertionStr += "Runnable4 "; return; });
+
+        LambdaTest1 test = new LambdaTest1();
+        test.test2((Runnable)()-> { assertionStr += "Runnable5 "; });
+
+        //return type:
+        r = test.test3();
+        r.run();
+
+        assertTrue(assertionStr.equals("Runnable1 Runnable2 Runnable4 Runnable5 Runnable6"));
+
+        //lambda expressions for SAM interface Comparator<T>:
+        List<Integer> list = new ArrayList<Integer>();
+        list.add(4);
+        list.add(10);
+        list.add(-5);
+        list.add(100);
+        list.add(9);
+        Collections.sort(list, (Integer i1, Integer i2)-> i2 - i1);
+        String result = "";
+        for(int i : list)
+            result += i + " ";
+        assertTrue(result.equals("100 10 9 4 -5 "));
+
+        Collections.sort(list,
+            (i1, i2) -> {
+                String s1 = i1.toString();
+                String s2 = i2.toString();
+                return s1.length() - s2.length();
+             });
+        result = "";
+        for(int i : list)
+            result += i + " ";
+        assertTrue(result.equals("9 4 10 -5 100 "));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test lambda expressions for different method signatures (parameter and return type)
+ * @compile LambdaTest2.java
+ * @run main LambdaTest2
+ */
+
+public class LambdaTest2 {
+
+    private static int count = 0;
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        LambdaTest2 test = new LambdaTest2();
+
+        test.method2((int n) -> { ; });
+        test.method2(n -> { }); // "int" is optional here
+        test.method2((int n) -> { }); // ";" is optional here
+        test.method2((int n) -> { return; }); // ";" is mandatory here
+        test.method2((int n) -> { count += n; });
+        assertTrue(count == 10);
+
+        VoidInt vi = (int i) -> {
+                            switch (i) {
+                                case 0:
+                                    System.out.println("normal");
+                                    break;
+                                default:
+                                    System.out.println("invalid");
+                            }
+                       };
+
+        test.method3(()-> { count++; });
+        test.method3(() -> {});
+        assertTrue(count == 11);
+
+        VoidVoid vv = ()-> { while(true)
+                            if(false)
+                                break;
+                            else
+                                continue;
+                       };
+
+        IntVoid iv1 = () -> 42;
+        IntVoid iv2 = () -> { return 43; };//";" is mandatory here
+        assertTrue(iv1.ivMethod() == 42);
+        assertTrue(iv2.ivMethod() == 43);
+
+        IntInt ii1 = (int n) -> n+1;
+        IntInt ii2 = n -> 42;
+        IntInt ii3 = n -> { return 43; };
+        IntInt ii4 =
+            (int n) -> {
+                if(n > 0)
+                    return n+1;
+                else
+                    return n-1;
+            };
+        assertTrue(ii1.iiMethod(1) == 2);
+        assertTrue(ii2.iiMethod(1) == 42);
+        assertTrue(ii3.iiMethod(1) == 43);
+        assertTrue(ii4.iiMethod(-1) == -2);
+    }
+
+    void method2(VoidInt a) {
+        a.viMethod(10);
+    }
+
+    void method3(VoidVoid a) {
+        a.vvMethod();
+    }
+
+    //SAM type interfaces
+    interface VoidInt {
+        void viMethod(int n);
+    }
+
+    interface VoidVoid {
+        void vvMethod();
+    }
+
+    interface IntVoid {
+        int ivMethod();
+    }
+
+    interface IntInt {
+        int iiMethod(int n);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test capture of "effectively final" local variable in lambda expressions
+ * @compile LambdaTest3.java
+ * @run main LambdaTest3
+ */
+
+public class LambdaTest3 {
+
+    private static int count = 0;
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        final int N = 100;
+        int n = 2; //effectively final variable
+
+        Runnable r = ((Runnable)
+            () -> {
+                count += N;
+                count += n;
+            }
+        );
+        assertTrue(count == 0);
+        r.run();
+        assertTrue(count == 102);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test accessing "this" in lambda expressions
+ * @compile LambdaTest4.java
+ * @run main LambdaTest4
+ */
+
+public class LambdaTest4 {
+
+    private String thisStr;
+    private static int count = 0;
+
+    {
+        ((Runnable)
+            ()-> {
+                this.init();
+                assertTrue(this.toString().equals(thisStr));
+                count++;
+            }
+        ).run();
+    }
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private void init() {
+        thisStr = this.toString();
+    }
+
+    private void m() {
+        String s1 = this.toString();
+        ((Runnable)
+            ()-> {
+                assertTrue(this.toString().equals(thisStr));
+                assertTrue(this.toString().equals(s1));
+            }
+        ).run();
+    }
+
+    public static void main(String[] args) {
+        LambdaTest4 test = new LambdaTest4();
+        assertTrue(count == 1);
+        test.m();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test lambda expressions inside lambda expressions
+ * @compile LambdaTest5.java
+ * @run main LambdaTest5
+ */
+
+public class LambdaTest5 {
+
+    interface A {
+        int m();
+    }
+
+    interface B {
+        int make (int i);
+    }
+
+    private static int count = 0;
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    static A a;
+    static A a2;
+    static A a3;
+    static A a4;
+
+    public static void main(String[] args) {
+        B b = (int i) -> ((A)()-> 5).m();
+        assertTrue(b.make(0) == 5);
+
+        a = () -> ((A)()-> { return 6; }).m(); //self reference
+        assertTrue(a.m() == 6);
+
+        a2 = ()-> {
+                  A an = ()-> { return 7; }; //self reference
+                  return an.m();
+                };
+        assertTrue(a2.m() == 7);
+
+        a3 = () -> a3.m(); //self reference
+        try {
+            a3.m();
+        } catch(StackOverflowError e) {
+            count++;
+        }
+        assertTrue(count==1);
+
+        a4 = ()-> ((B)(int i)-> ((A)()-> 9).m() ).make(0);
+        assertTrue(a4.m() == 9);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test bridge methods for certain SAM conversions
+ * @compile LambdaTest6.java
+ * @run main LambdaTest6
+ */
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+public class LambdaTest6<T> {
+
+    interface H {Object m();}
+
+    interface K<U> {void m(U element);}
+
+    interface L extends K<String> {} //generic substitution
+
+    interface M {void m(String s);}
+
+    interface KM extends K<String>, M{} //generic substitution
+
+    interface N extends H {String m();} //covariant return
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private Set<String> setOfStringObject() {
+        Set<String> s = new HashSet<>();
+        s.add("java.lang.String");
+        s.add("java.lang.Object");
+        return s;
+    }
+
+    private void test1()
+    {
+        L la = s -> { };
+        la.m("hi");
+        Class<? extends L> c1 = la.getClass();
+        Method[] methods = c1.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        for(Method m : methods) {
+            assertTrue(m.getName().equals("m"));
+            Class[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty() || (types.size() == 1 && types.contains("java.lang.String")));
+    }
+
+    private void test2()
+    {
+        KM km = s -> { };
+        //km.m("hi");
+        Class<? extends KM> c2 = km.getClass();
+        Method[] methods = c2.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        for(Method m : methods) {
+            assertTrue(m.getName().equals("m"));
+            Class[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty());
+    }
+
+    private void test3()
+    {
+        N na = ()-> "hi";
+        assertTrue( na.m().equals("hi") );
+        assertTrue( ((H)na).m().equals("hi") );
+        Class<? extends N> c3 = na.getClass();
+        Method[] methods = c3.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        for(Method m : methods) {
+            assertTrue(m.getName().equals("m"));
+            Class returnType = m.getReturnType();
+            assertTrue(types.remove(returnType.getName()));
+        }
+        assertTrue(types.isEmpty());
+    }
+
+
+    public static void main(String[] args) {
+        LambdaTest6 test = new LambdaTest6();
+        test.test1();
+        test.test2();
+        test.test3();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/SamConversion.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of lambda expressions in context of assignment, method call, return statement and cast.
+ * @compile SamConversion.java
+ * @run main SamConversion
+ */
+
+public class SamConversion {
+
+    static interface Foo {
+        Integer m(int i);
+    }
+
+    static interface Bar {
+        int m(Integer i) throws Exception;
+    }
+
+    private static String assertionStr = "";
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private static void test1(Foo foo) {
+        assertTrue(foo.m(1) == 2);
+    }
+
+    private static void test2(Bar bar) {
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e){
+            assertTrue(false);
+        }
+    }
+
+    private static Bar test3(int i) {
+        switch (i) {
+        case 0:
+            return n -> n + 1;
+        case 1:
+            return (Integer n) -> 2 * n;
+        case 2:
+            return (Integer n) -> {return new Integer(n-1);};
+        case 3:
+            return n -> {throw new Exception();};
+        default:
+            return null;
+        }
+    }
+
+    public static void main(String[] args) {
+
+        //assign:
+        Foo foo = (int n) -> n + 1; //explicit type and boxing
+        assertTrue(foo.m(1) == 2);
+
+        foo = n -> n + 1; //type inferrred and boxing
+        assertTrue(foo.m(1) == 2);
+
+        Bar bar = (Integer n) -> n + 1; //explicit type and unboxing
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = (Integer n) -> new Integer(n+1); //explicit type and unboxing twice
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = n -> n.intValue() + 1; //type inferred
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = n -> n + 1; // type inferred and unboxing
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        //cast:
+        assertTrue(((Foo)n -> {return n+1;}).m(1) == 2); //statement (instead of expression) in lambda body
+        try {
+            assertTrue(((Bar)n -> {return n+1;}).m(1) == 2); //statement in lambda body
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        //method parameter:
+        test1((int n) -> new Integer(n+1)); //explicit type
+        test2((Integer n) -> n.intValue() + 1); //explicit type
+
+        //return statement:
+        bar = test3(0);
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(1);
+        try {
+            assertTrue(bar.m(3) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(2);
+        try {
+            assertTrue(bar.m(10) == 9);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(3);
+        try {
+            bar.m(10);
+            assertTrue(false);
+        } catch (Exception e) {}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of lambda expressions in combinations of different contexts,
+ *           lambda body types(statement/expression), explict/implicit target type etc, to verify
+ *           SAM conversion being conducted successfully as expected.
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class SamConversionComboTest {
+
+    enum FInterface {
+        A("A", "interface A { Integer m(int i); }"),
+        B("B", "interface B { int m(Integer i); }"),
+        C("C", "interface C { int m(Integer i) throws Exception; }");
+
+        String interfaceType;
+        String interfaceDef;
+
+        FInterface(String interfaceType, String interfaceDef) {
+            this.interfaceType = interfaceType;
+            this.interfaceDef = interfaceDef;
+        }
+
+        String getParameterType() {
+            switch(this) {
+            case A:
+                return "int";
+            case B:
+            case C:
+                return "Integer";
+            default:
+                return null;
+            }
+        }
+    }
+
+    enum Context {
+        ASSIGNMENT("#FType f = #LBody;"),
+        METHOD_CALL("void method1(#FType f) { }\n" +
+                    "    void method2() {\n" +
+                    "        method1(#LBody);\n" +
+                    "    }"),
+        CONSTRUCTOR("X x = new X(#LBody);"),
+        RETURN_OF_METHOD("#FType method1() {\n" +
+                         "    return #LBody;\n" +
+                         "}"),
+        ARRAY_INITIALIZER("Object[] oarray = {\"a\", 1, (#FType)#LBody};"),
+        LAMBDA_BODY("#FType f = n -> ((#FType)#LBody).m(n);"),
+        CAST("void test() throws Exception { int n = ((#FType)#LBody).m(1); }"),
+        CONDITIONAL_EXPRESSION("#FType f = 2 > 1 ? #LBody : null;");
+
+        String context;
+
+        Context(String context) {
+            this.context = context;
+        }
+
+        String getContext(FInterface f, LambdaKind lk, LambdaBody lb, ReturnValue rv) {
+            return context.replace("#FType", f.interfaceType).replace("#LBody", lb.getLambdaBody(f, lk, rv));
+        }
+    }
+
+    enum LambdaKind {
+        EXPRESSION("#VAL"),
+        STATEMENT("{return #VAL;}"),
+        EXCEPTION_STMT("{throw new Exception();}");
+
+        String stmt;
+
+        LambdaKind(String stmt) {
+            this.stmt = stmt;
+        }
+    }
+
+    enum ReturnValue {
+        INT("i + 1"),
+        INTEGER("new Integer(i+1)"),
+        INT2("i.intValue() + 1"),
+        STRING("i + \"\""),
+        DOUBLE("i * 1.0");
+
+        String rValue;
+
+        ReturnValue(String rValue) {
+            this.rValue = rValue;
+        }
+    }
+
+    enum LambdaBody {
+        IMPLICIT("i -> #RET"),//type inferred
+        EXPLICIT("(#Type i) -> #RET");//explicit type
+
+        String bodyStr;
+
+        LambdaBody(String bodyStr) {
+            this.bodyStr = bodyStr;
+        }
+
+        String getLambdaBody(FInterface fi, LambdaKind lk, ReturnValue rv) {
+            return bodyStr.replace("#Type", fi.getParameterType()).replace("#RET", lk.stmt.replace("#VAL", rv.rValue));
+        }
+    }
+
+    boolean checkSamConversion() {
+        if(lambdaKind != LambdaKind.EXCEPTION_STMT && (returnValue == ReturnValue.DOUBLE || returnValue == ReturnValue.STRING)) //return type mismatch
+            return false;
+        if(context != Context.CONSTRUCTOR) {//context other than construcotr argument
+            if(fInterface != FInterface.C && lambdaKind == LambdaKind.EXCEPTION_STMT)
+                return false;
+            if(fInterface == FInterface.A && returnValue == ReturnValue.INT2)
+                return false;
+        }
+        else { //constructor argument context
+            //match X(A a) or X(B b) or X(C c)
+            if (lambdaKind == LambdaKind.EXCEPTION_STMT) {
+                return false; //ambiguous target type
+            }
+            else if(lambdaBody == LambdaBody.IMPLICIT) {
+                if(returnValue != ReturnValue.INTEGER) //ambiguous target type
+                    return false;
+            }
+            else { //explicit parameter type
+                if(fInterface.getParameterType().equals("Integer")) //ambiguous target type
+                //e.g. X x = new X((Integer i) -> i + 1);
+                    return false;
+                if(returnValue == ReturnValue.INT2)
+                //e.g. X x = new X(int i -> i.intValue() + 1);
+                    return false;
+            }
+        }
+        return true;
+    }
+
+    SourceFile samSourceFile = new SourceFile("FInterface.java", "#C") {
+        public String toString() {
+            String interfaces = "";
+            for(FInterface fi : FInterface.values())
+                interfaces += fi.interfaceDef + "\n";
+            return template.replace("#C", interfaces);
+        }
+    };
+
+    String clientTemplate = "class Client {\n" +
+                            "    #Context\n" +
+                            "}\n\n" +
+
+                            "class X {\n" +
+                            "    int value = 0;\n\n" +
+
+                            "    X(A a) {\n" +
+                            "        value = a.m(6);\n" +
+                            "    }\n\n" +
+
+                            "    X(B b) {\n" +
+                            "        value = b.m(7);\n" +
+                            "    }\n\n" +
+
+                            "    X(C c) {\n" +
+                            "        try {\n" +
+                            "            value = c.m(8);\n" +
+                            "        } catch (Exception e){}\n" +
+                            "    }\n" +
+                            "}";
+    SourceFile clientSourceFile = new SourceFile("Client.java", clientTemplate) {
+        public String toString() {
+            return template.replace("#Context", context.getContext(fInterface, lambdaKind, lambdaBody, returnValue));
+        }
+    };
+
+    void test() throws Exception {
+        System.out.println("\n====================================");
+        System.out.println(fInterface + ", " +  context + ", " + lambdaKind + ", " + lambdaBody + ", " + returnValue);
+        System.out.println(samSourceFile + "\n");
+        String clientFileStr = clientSourceFile.toString();
+        System.out.println(clientFileStr.substring(0, clientFileStr.indexOf("\n\n")));
+
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkSamConversion()) {
+            throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile);
+        }
+        count++;
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+    FInterface fInterface;
+    Context context;
+    LambdaBody lambdaBody;
+    LambdaKind lambdaKind;
+    ReturnValue returnValue;
+    static int count = 0;
+
+    SamConversionComboTest(FInterface f, Context c, LambdaBody lb, LambdaKind lk, ReturnValue rv) {
+        fInterface = f;
+        context = c;
+        lambdaKind = lk;
+        lambdaBody = lb;
+        returnValue = rv;
+    }
+
+    public static void main(String[] args) throws Exception {
+        for(Context ct : Context.values()) {
+            for (FInterface fi : FInterface.values()) {
+                for (LambdaKind lk: LambdaKind.values()) {
+                    for (LambdaBody lb : LambdaBody.values()) {
+                        for(ReturnValue rv : ReturnValue.values()) {
+                            new SamConversionComboTest(fi, ct, lb, lk, rv).test();
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("total tests: " + count);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/BridgeMethod.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test bridge methods in certain SAM conversion
+ * @compile BridgeMethod.java
+ * @run main BridgeMethod
+ */
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+public class BridgeMethod {
+
+    interface H {Object m();}
+
+    interface K<T> {void m(T t);}
+
+    interface L extends K<String> {} //generic substitution
+
+    interface M {void m(String s);}
+
+    interface KM extends K<String>, M{} //generic substitution
+
+    interface N extends H {String m();} //covariant return
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static void bar(String s) {
+        System.out.println("BridgeMethod.bar(String) " + s);
+    }
+
+    String moo() {
+        return "moo";
+    }
+
+    private static Set<String> setOfStringObject() {
+        Set<String> s = new HashSet<>();
+        s.add("java.lang.String");
+        s.add("java.lang.Object");
+        return s;
+    }
+
+    public static void main(String[] args) {
+        L la = BridgeMethod::bar; //static reference
+        la.m("hi");
+        Class<? extends L> c1 = la.getClass();
+        Method[] methods = c1.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        System.out.println("methods in SAM conversion of L:");
+        for(Method m : methods) {
+            System.out.println(m.toGenericString());
+            assertTrue(m.getName().equals("m"));
+            Class[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty() || (types.size() == 1 && types.contains("java.lang.String")));
+
+        KM km = BridgeMethod::bar;
+        //km.m("hi"); //will be uncommented when CR7028808 fixed
+        Class<? extends KM> c2 = km.getClass();
+        methods = c2.getDeclaredMethods();
+        types = setOfStringObject();
+        System.out.println("methods in SAM conversion of KM:");
+        for(Method m : methods) {
+            System.out.println(m.toGenericString());
+            assertTrue(m.getName().equals("m"));
+            Class<?>[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty());
+
+        N n = new BridgeMethod()::moo; //instance reference
+        assertTrue( n.m().equals("moo") );
+        assertTrue( ((H)n).m().equals("moo") );
+        Class<? extends N> c3 = n.getClass();
+        methods = c3.getDeclaredMethods();
+        types = setOfStringObject();
+        System.out.println("methods in SAM conversion of N:");
+        for(Method m : methods) {
+            System.out.println(m.toGenericString());
+            assertTrue(m.getName().equals("m"));
+            Class<?> returnType = m.getReturnType();
+            assertTrue(types.remove(returnType.getName()));
+        }
+        assertTrue(types.isEmpty());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef1.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test static method reference
+ * @compile MethodRef1.java
+ * @run main MethodRef1
+ */
+
+public class MethodRef1 {
+
+    static interface A {void m();}
+
+    static interface B {void m(int i);}
+
+    static interface C {String m(String s);}
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static void foo(int x) {
+        System.out.println("MethodRef1.foo(int) " + x);
+    }
+
+    static void bar() {
+        System.out.println("MethodRef1.bar()");
+    }
+
+    static void bar(int x) {
+        System.out.println("MethodRef1.bar(int) " + x);
+    }
+
+    static String bar(String s) {
+        return "MethodRef1.bar(String) " + s;
+    }
+
+    public static void main(String[] args) {
+
+        A a = MethodRef1::bar; //static reference to bar()
+        a.m();
+
+        B b = MethodRef1::foo; //static reference to foo(int), (int) omitted because method foo is not overloaded
+        b.m(1);
+
+        b = MethodRef1::foo; //static reference to foo(int)
+        b.m(1);
+
+        b = new MethodRef1()::foo; //instance reference to static methods, supported for now
+        b.m(1);
+
+        b = MethodRef1::bar; //static reference to bar(int)
+        b.m(2);
+
+        C c = MethodRef1::bar; //static reference to bar(String)
+        assertTrue( c.m("hi").equals("MethodRef1.bar(String) hi") );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef2.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test instance method reference
+ * @compile MethodRef2.java
+ * @run main MethodRef2
+ */
+
+public class MethodRef2 {
+
+    static interface A {String m();}
+
+    static interface B {String m(int i);}
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    String moo() {
+        return "moo";
+    }
+
+    String wahoo() {
+        return "wahoo";
+    }
+
+    String wahoo(int x) {
+        return "wahoo " + x;
+    }
+
+    public static void main(String[] args) {
+
+        MethodRef2 mr = new MethodRef2();
+
+        A a = mr::moo; //instance reference to moo()
+        assertTrue( a.m().equals("moo") );
+
+        a = new MethodRef2()::wahoo; //instance reference to wahoo()
+        assertTrue( a.m().equals("wahoo") );
+
+        B b = mr::wahoo; //instance reference to wahoo(int)
+        assertTrue( b.m(4).equals("wahoo 4") );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef3.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test unbound method reference
+ * @compile MethodRef3.java
+ * @run main MethodRef3
+ */
+
+public class MethodRef3 {
+
+    static interface A { String m(MethodRef3 mr); }
+
+    static interface B { String m(MethodRef3 mr, String s); }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    String moo() {
+        return "moo";
+    }
+
+    String wahoo(String s) {
+        return "wahoo " + s;
+    }
+
+    public static void main(String[] args) {
+
+        MethodRef3 mr = new MethodRef3();
+        A a = MethodRef3::moo; //unbound reference to moo()
+        assertTrue( a.m(mr).equals("moo") );
+        B b = MethodRef3::wahoo; //unbound reference to wahoo()
+        assertTrue( b.m(mr, "hi").equals("wahoo hi") );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef4.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test constructor reference
+ * @compile MethodRef4.java
+ * @run main MethodRef4
+ */
+
+public class MethodRef4 {
+
+    static interface A {Fee<String> m();}
+
+    static interface B {Fee<String> m(String s);}
+
+    static interface C {Object m();}
+
+    static class Fee<T> {
+
+        private T t;
+
+        public Fee() {
+            System.out.println("Fee<T> instantiated");
+        }
+
+        public Fee(T t) {
+            this.t = t;
+            System.out.println("Fee<T> instantiated: " + t);
+        }
+
+        public void make() {
+            System.out.println(this + ": make()");
+        }
+    }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        A a = Fee<String>::new; //constructor reference to Fee<T>()
+        a.m().make();
+
+        B b = Fee<String>::new; //constructor reference to Fee<T>(String)
+        b.m("hi").make();
+
+        C c = MethodRef4::new; //constructor reference to MethodRef4()
+        assertTrue( c.m() instanceof MethodRef4 );
+        c = MethodRef4::new; //constructor reference to MethodRef4()
+        assertTrue( c.m() instanceof MethodRef4 );
+        c = Fee<String>::new; //constructor reference to Fee<T>()
+        assertTrue( c.m() instanceof Fee );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef5.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test method reference with SAM interface Comparator<T>
+ * @compile MethodRef5.java
+ * @run main MethodRef5
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+
+public class MethodRef5 {
+
+    static class Person {
+
+        private String firstName;
+        private String lastName;
+        private int age;
+
+        public Person() { }
+
+        public Person(String fn, String ln, int a) {
+            firstName = fn;
+            lastName = ln;
+            age = a;
+        }
+
+        public String getLastName() {
+            return lastName;
+        }
+
+        public int getAge() {
+            return age;
+        }
+
+        //the following 2 methods are signature-compatible with Comparator<Person>.compare():
+        public static int compareByAge(Person a, Person b) {
+            return a.age - b.age;
+        }
+
+        public int compareByLastName(Person a, Person b) {
+            return a.lastName.compareToIgnoreCase(b.lastName);
+        }
+    }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        List<Person> persons = new ArrayList<Person>();
+        persons.add(new Person("John", "Smith", 49));
+        persons.add(new Person("Abraham", "Lincoln", 30));
+        persons.add(new Person("George", "Washington", 29));
+        persons.add(new Person("Peter", "Derby", 50));
+        Collections.sort(persons, Person::compareByAge);//static method reference to compareByAge(Person, Person)
+        String age = "";
+        for (Person p : persons) {
+            age += p.getAge() + " ";
+        }
+        assertTrue( (age.equals("29 30 49 50 ")) );
+        Collections.sort(persons, new Person()::compareByLastName);//instance method reference to compareByLastName(Person, Person)
+        String lastName = "";
+        for (Person p : persons) {
+            lastName += p.getLastName() + " ";
+        }
+        assertTrue( lastName.equals("Derby Lincoln Smith Washington ") );
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef6.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test that the most specific reference is selected when method parameters are elided
+ * @compile MethodRef6.java
+ * @run main MethodRef6
+ */
+
+public class MethodRef6 {
+
+    static interface A { String make(Integer i); }
+
+    static interface B { String make(Number i); }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static String m(Object o) {
+        return "Object " + o;
+    }
+
+    static String m(Number n) {
+        return "Number " + n;
+    }
+
+    static String m(Integer i) {
+        return "Integer " + i;
+    }
+
+    static String m(int i) {
+        return "int " + i;
+    }
+
+    public static void main(String[] args) {
+        A a = MethodRef6::m;
+        assertTrue(a.make(1).equals("Integer 1"));//method parameter type inferred from SAM descriptor, boxing applied
+        B b = MethodRef6::m;
+        assertTrue(b.make(1).equals("Number 1"));//method parameter type inferred from SAM descriptor, boxing and widen applied
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef7.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test that parameter types are inferred from SAM descriptor when method parameters are elided,
+             with different types of method references
+ * @compile MethodRef7.java
+ * @run main MethodRef7
+ */
+
+public class MethodRef7 {
+
+    static interface A {void m();}
+
+    static interface A2 {void m(int n);}
+
+    static interface B {String m();}
+
+    static interface B2 {String m(int n);}
+
+    static interface C {String m(MethodRef7 mr);}
+
+    static interface C2 {String m(MethodRef7 mr, int n);}
+
+    static interface D {Fee<String> m();}
+
+    static interface D2 {Fee<String> m(String s);}
+
+    static class Fee<T> {
+
+        public Fee() {
+            System.out.println("Fee<T> instantiated");
+        }
+
+        public Fee(String s) {
+            System.out.println("Fee<T> instantiated: " + s);
+        }
+    }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static void bar() {
+        System.out.println("MethodRef_neg1.bar()");
+    }
+
+    static void bar(int x) {
+        System.out.println("MethodRef_neg1.bar(int) " + x);
+    }
+
+    String wahoo() {
+        return "wahoo";
+    }
+
+    String wahoo(int x) {
+        return "wahoo " + x;
+    }
+
+    public static void main(String[] args) {
+
+        A a = MethodRef7::bar; //static reference to bar()
+        a.m();
+        A2 a2 = MethodRef7::bar; //static reference to bar(int x)
+        a2.m(10);
+
+        MethodRef7 mr = new MethodRef7();
+        B b = mr::wahoo; //instance reference to wahoo()
+        assertTrue(b.m().equals("wahoo"));
+        B2 b2 = mr::wahoo; //instance reference to wahoo(int x)
+        assertTrue(b2.m(1).equals("wahoo 1"));
+
+        C c = MethodRef7::wahoo; //unbound reference to wahoo()
+        assertTrue(c.m(mr).equals("wahoo"));
+        C2 c2 = MethodRef7::wahoo; //unbound reference to wahoo(int x)
+        assertTrue(c2.m(mr, 2).equals("wahoo 2"));
+
+        D d = Fee<String>::new; //constructor reference to Fee()
+        D2 d2 = Fee<String>::new; //constructor reference to Fee(String s)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,36 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This is negative test for wrong parameter/return type in method references
+ * @compile/fail/ref=MethodRef_neg.out -XDrawDiagnostics MethodRef_neg.java
+ */
+
+public class MethodRef_neg {
+
+    static interface A {void m(Integer i);}
+
+    static interface B {void m(String s);}
+
+    static interface C {Integer m();}
+
+    static interface D {String m();}
+
+
+    static void bar(int x) { }
+
+    int foo() {
+        return 5;
+    }
+
+    static void make() { }
+
+    void method() {
+        A a = MethodRef_neg::bar; //boxing on parameter type is ok
+        B b = MethodRef_neg::bar; //wrong parameter type, required: String, actual: int
+        C c = this::foo; //boxing on return type is ok
+        D d = this::foo; //wrong return type, required: String, actual: int
+        a = MethodRef_neg::make; //missing parameter
+        c = MethodRef_neg::make; //missing return type
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/MethodRef_neg.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,5 @@
+MethodRef_neg.java:30:15: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, bar, int, java.lang.String, kindname.class, MethodRef_neg, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, int))))
+MethodRef_neg.java:32:15: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int, java.lang.String))
+MethodRef_neg.java:33:13: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, make, compiler.misc.no.args, java.lang.Integer, kindname.class, MethodRef_neg, (compiler.misc.arg.length.mismatch)))
+MethodRef_neg.java:34:13: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: void, java.lang.Integer))
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/SamConversion.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,337 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of method references in contexts of assignment, method/constructor argument,
+ *           return statement, array initializer, lambda expression body, conditional expression and cast.
+ * @compile SamConversion.java
+ * @run main SamConversion
+ */
+
+public class SamConversion {
+
+    static int assertionCount = 0;
+
+    static interface Foo {
+        Integer m(int i);
+    }
+
+    static interface Bar {
+        int m(Integer i) throws MyException;
+    }
+
+    private static void assertTrue(boolean b) {
+        assertionCount++;
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private static int test1(Foo foo) {
+        return foo.m(1);
+    }
+
+    private static void test2(Bar bar, int result) {
+        try {
+            assertTrue(bar.m(1) == result);
+        } catch (Exception e){
+            assertTrue(false);
+        }
+    }
+
+    private static Bar test3(int i) {
+        switch (i) {
+        case 0:
+            return A::method1;
+        case 1:
+            return new A()::method2;
+        case 2:
+            return A::method3;
+        case 3:
+            return new A()::method4;
+        case 4:
+            return new A()::method5;
+        case 5:
+            return A::method6;
+        default:
+            return null;
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in assignment context
+     */
+    private static void testAssignment() {
+        Foo foo = A::method1; //static reference, parameter type matching and return type matching
+        assertTrue(foo.m(1) == 2);
+
+        foo = new A()::method2; //instance reference, parameter type unboxing and return type boxing
+        assertTrue(foo.m(1) == 3);
+
+        foo = A::method3; //static reference, parameter type matching and return type boxing
+        assertTrue(foo.m(1) == 4);
+
+        foo = new A()::method4; //instance reference, parameter type unboxing and return type matching
+        assertTrue(foo.m(1) == 5);
+
+        foo = new A()::method5; //instance reference, parameter type unboxing and return type matching
+        assertTrue(foo.m(1) == 6);
+
+        Bar bar = A::method1;
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method2;
+        try {
+            assertTrue(bar.m(1) == 3);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = A::method3;
+        try {
+            assertTrue(bar.m(1) == 4);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method4;
+        try {
+            assertTrue(bar.m(1) == 5);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method5;
+        try {
+            assertTrue(bar.m(1) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method6;
+        try {
+            bar.m(1);
+            assertTrue(false);
+        } catch (MyException e) {
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in method/constructor argument context
+     */
+    private static void testMethodArgument() {
+        assertTrue(test1(A::method1) == 2);
+        assertTrue(test1(new A()::method2) == 3);
+        assertTrue(test1(A::method3) == 4);
+        assertTrue(test1(new A()::method4) == 5);
+        assertTrue(test1(new A()::method5) == 6);
+        test2(A::method1, 2);
+        test2(new A()::method2, 3);
+        test2(A::method3, 4);
+        test2(new A()::method4, 5);
+        test2(new A()::method5, 6);
+        A a = new A(A::method1); //A(Foo f) called
+        assertTrue(a.method2(1) == 11);
+        assertTrue(a.method4(1) == 11);
+        assertTrue(a.method5(1) == 11);
+        A a2 = new A(new A()::method2); //A(Bar b) called
+        assertTrue(a2.method2(1) == 12);
+        assertTrue(a2.method4(1) == 12);
+        assertTrue(a2.method5(1) == 12);
+    }
+
+    /**
+     * Test SAM conversion of method reference in return statement context
+     */
+    private static void testReturnStatement() {
+        Bar bar = test3(0);
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(1);
+        try {
+            assertTrue(bar.m(1) == 3);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(2);
+        try {
+            assertTrue(bar.m(1) == 4);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(3);
+        try {
+            assertTrue(bar.m(1) == 5);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(4);
+        try {
+            assertTrue(bar.m(1) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(5);
+        try {
+            bar.m(1);
+            assertTrue(false);
+        } catch (MyException e) {
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in cast context
+     */
+    private static void testCast() {
+        assertTrue(((Foo)A::method1).m(1) == 2);
+        try {
+            assertTrue(((Bar)new A()::method2).m(1) == 3);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in array initializer context
+     */
+    private static void testArrayInitializer() {
+        Object[] oarray = {"a", 1, (Foo)A::method3}; //last element need a cast
+        Object[] oarray2 = {"a", 1, (Bar)new A()::method4}; //last element need a cast
+        Foo[] farray = {A::method1, new A()::method2, A::method3, new A()::method4, new A()::method5};
+        Bar[] barray = {A::method1, new A()::method2, A::method3, new A()::method4, new A()::method5, A::method6};
+    }
+
+    /**
+     * Test SAM conversion of method reference in conditional expression context
+     */
+    private static void testConditionalExpression(boolean b) {
+        Foo f = b ? A::method3 : new A()::method5;
+        if(b)
+            assertTrue(f.m(1) == 4);
+        else
+            assertTrue(f.m(1) == 6);
+
+        Bar bar = b ? A::method1 : A::method6;
+        if(b) {
+            try {
+                assertTrue(bar.m(1) == 2);
+            } catch (Exception e) {
+                assertTrue(false);
+            }
+        }
+        else {
+            try {
+                bar.m(1);
+                assertTrue(false);
+            } catch (MyException e) {
+            } catch (Exception e) {
+                assertTrue(false);
+            }
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in lambda expression body
+     */
+    private static void testLambdaExpressionBody() {
+        Foo f = n -> ((Foo)A::method3).m(n);
+        assertTrue(f.m(1) == 4);
+
+        Bar b = n -> { return ((Foo)new A()::method5).m(n); };
+        try {
+            assertTrue(b.m(1) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    public static void main(String[] args) {
+        testAssignment();
+        testMethodArgument();
+        testReturnStatement();
+        testCast();
+        testArrayInitializer();
+        testConditionalExpression(true);
+        testConditionalExpression(false);
+        testLambdaExpressionBody();
+
+        assertTrue(assertionCount == 38);
+    }
+
+    static class MyException extends Exception {}
+
+    static class A {
+
+        int value = 0;
+
+        A() {
+        }
+
+        A(Foo f) {
+            value = f.m(9);
+        }
+
+        A(Bar b) {
+            try {
+                value = b.m(9);
+            } catch (MyException e){}
+        }
+
+        static Integer method1(int n) {
+            return n + 1;
+        }
+
+        int method2(Integer n) {
+            return value == 0 ? n + 2 : n + value;
+        }
+
+        static int method3(int n) {
+            return n + 3;
+        }
+
+        Integer method4(Integer n) {
+            return value == 0 ? n + 4 : n + value;
+        }
+
+        Integer method5(Integer n) {
+            return value == 0 ? new Integer(n + 5) : new Integer(n + value);
+        }
+
+        static int method6(Integer n) throws MyException{
+            throw new MyException();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/SamConversionComboTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of method references in combinations of different contexts,
+ *           lambda body types(statement/expression), boxing/unboxing etc, to verify
+ *           SAM conversion being conducted successfully as expected.
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import javax.tools.StandardJavaFileManager;
+
+public class SamConversionComboTest {
+
+    enum FInterface {
+        A("A", "interface A { Integer m(int i); }"),
+        B("B", "interface B { int m(Integer i); }"),
+        C("C", "interface C { int m(int i) throws Exception; }");
+
+        String interfaceType;
+        String interfaceDef;
+
+        FInterface(String interfaceType, String interfaceDef) {
+            this.interfaceType = interfaceType;
+            this.interfaceDef = interfaceDef;
+        }
+    }
+
+    enum Context {
+        ASSIGNMENT("#FType f = #MR;"),
+        METHOD_CALL("void method1(#FType f) { }\n" +
+                    "void method2() {\n" +
+                    "    method1(#MR);\n" +
+                    "}"),
+        CONSTRUCTOR("X x = new X(#MR);"),
+        RETURN_OF_METHOD("#FType method1() {\n" +
+                         "    return #MR;\n" +
+                         "}"),
+        ARRAY_INITIALIZER("#FType[] oarray = {#MR};"),
+        LAMBDA_BODY("#FType f = n -> ((#FType)#MR).m(n);"),
+        CAST("void test() throws Exception { int n = ((#FType)#MR).m(1); }"),
+        CONDITIONAL_EXPRESSION("#FType f = 2 > 1 ? #MR : null;");
+
+        String context;
+
+        Context(String context) {
+            this.context = context;
+        }
+
+        String getContext(FInterface f, MethodReference mr) {
+            return context.replace("#FType", f.interfaceType).replace("#MR", mr.mrValue);
+        }
+    }
+
+    enum MethodReference {
+        METHOD1("X::method1"),
+        METHOD2("new X()::method2"),
+        METHOD3("X::method3"),
+        METHOD4("new X()::method4"),
+        METHOD5("new X()::method5"),
+        METHOD6("X::method6"),
+        METHOD7("X::method7"),
+        METHOD8("X::method8");
+
+        String mrValue;
+
+        MethodReference(String mr) {
+            mrValue = mr;
+        }
+    }
+
+    enum MethodDef {
+        METHOD1("    static Integer method1(int n) {\n" +
+                "        return n + 1;\n" +
+                "    }\n", 0),
+        METHOD2("    int method2(Integer n) {\n" +
+                "        return value == 0 ? n + 2 : n + value;\n" +
+                "    }\n", 1),
+        METHOD3("    static int method3(int n) {\n" +
+                "        return n + 3;\n" +
+                "    }\n", 2),
+        METHOD4("    Integer method4(Integer n) {\n" +
+                "        return value == 0 ? n + 4 : n + value;\n" +
+                "    }\n", 3),
+        METHOD5("    Integer method5(Integer n) {\n" +
+                "        return value == 0 ? new Integer(n + 5) : new Integer(n + value);\n" +
+                "    }\n", 4),
+        METHOD6("    static int method6(Integer n) throws Exception{\n" +
+                "        throw new Exception();\n" +
+                "    }\n", 5),
+        METHOD7("    static int method7(String s){\n" +
+                "        return s.length();\n" +
+                "    }\n", 6),
+        METHOD8("    static String method8(Integer n){\n" +
+                "        return n + \"\";\n" +
+                "    }\n", 7);
+
+        String methodStr;
+        int index;
+
+        MethodDef(String ms, int i) {
+            methodStr = ms;
+            index = i;
+        }
+
+        MethodReference getMethodReference() {
+            return MethodReference.values()[index];
+        }
+    }
+
+    SourceFile samSourceFile = new SourceFile("FInterface.java", "#C") {
+        public String toString() {
+            String interfaces = "";
+            for(FInterface fi : FInterface.values())
+                interfaces += fi.interfaceDef + "\n";
+            return template.replace("#C", interfaces);
+        }
+    };
+
+    String clientTemplate = "class Client {\n" +
+                            "    #Context\n" +
+                            "}\n\n" +
+
+                            "class X {\n" +
+                            "    int value = 0;\n\n" +
+
+                            "    X() {\n" +
+                            "    }\n\n" +
+
+                            "    X(A a) {\n" +
+                            "        value = a.m(9);\n" +
+                            "    }\n\n" +
+
+                            "    X(B b) {\n" +
+                            "        value = b.m(9);\n" +
+                            "    }\n\n" +
+
+                            "    X(C c) {\n" +
+                            "        try {\n" +
+                            "            value = c.m(9);\n" +
+                            "        } catch (Exception e){}\n" +
+                            "    }\n\n" +
+
+                            "#MethodDef" +
+                            "}";
+
+    SourceFile clientSourceFile = new SourceFile("Client.java", clientTemplate) {
+        public String toString() {
+            return template.replace("#Context", context.getContext(fInterface, methodReference)).replace("#MethodDef", methodDef.methodStr);
+        }
+    };
+
+    boolean checkSamConversion() {
+        if(methodDef == MethodDef.METHOD7 || methodDef == MethodDef.METHOD8)//method signature mismatch
+            return false;
+        if(context != Context.CONSTRUCTOR && fInterface != FInterface.C && methodDef == MethodDef.METHOD6)
+        //method that throws exceptions not thrown by the interface method is a mismatch
+            return false;
+        if(context == Context.CONSTRUCTOR &&
+           methodReference != MethodReference.METHOD1 &&
+           methodReference != MethodReference.METHOD2 &&
+           methodReference != MethodReference.METHOD3)//ambiguous reference
+               return false;
+        return true;
+    }
+
+    void test() throws Exception {
+        System.out.println("\n====================================");
+        System.out.println(fInterface + ", " +  context + ", " + methodReference);
+        System.out.println(samSourceFile + "\n" + clientSourceFile);
+
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkSamConversion()) {
+            throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile);
+        }
+        count++;
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+    FInterface fInterface;
+    Context context;
+    MethodDef methodDef;
+    MethodReference methodReference;
+    static int count = 0;
+
+    static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+    static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+    SamConversionComboTest(FInterface f, Context c, MethodDef md) {
+        fInterface = f;
+        context = c;
+        methodDef = md;
+        methodReference = md.getMethodReference();
+    }
+
+    public static void main(String[] args) throws Exception {
+        for(Context ct : Context.values()) {
+            for (FInterface fi : FInterface.values()) {
+                for (MethodDef md: MethodDef.values()) {
+                    new SamConversionComboTest(fi, ct, md).test();
+                }
+            }
+        }
+        System.out.println("total tests: " + count);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,303 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  Automatic test for checking correctness of structural most specific test routine
+ * @run main/timeout=360 StructuralMostSpecificTest
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper;
+import com.sun.tools.javac.util.JCDiagnostic;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class StructuralMostSpecificTest {
+
+    static int checkCount = 0;
+
+    enum RetTypeKind {
+        SHORT("short"),
+        INT("int"),
+        OBJECT("Object"),
+        INTEGER("Integer"),
+        VOID("void"),
+        J_L_VOID("Void");
+
+        String retTypeStr;
+
+        RetTypeKind(String retTypeStr) {
+            this.retTypeStr = retTypeStr;
+        }
+
+        boolean moreSpecificThan(RetTypeKind rk) {
+            return moreSpecificThan[this.ordinal()][rk.ordinal()];
+        }
+
+        static boolean[][] moreSpecificThan = {
+                //              SHORT |  INT  | OBJECT | INTEGER | VOID  | J_L_VOID
+                /* SHORT */   { true  , true  , true   , false   , false , false },
+                /* INT */     { false , true  , true   , true    , false , false },
+                /* OBJECT */  { false , false , true   , false   , false , false },
+                /* INTEGER */ { false , false , true   , true    , false , false },
+                /* VOID */    { false , false , false  , false   , true  , true  },
+                /* J_L_VOID */{ false , false , true   , false   , false , true  } };
+    }
+
+    enum ArgTypeKind {
+        SHORT("short"),
+        INT("int"),
+        BOOLEAN("boolean"),
+        OBJECT("Object"),
+        INTEGER("Integer"),
+        DOUBLE("Double");
+
+        String argTypeStr;
+
+        ArgTypeKind(String typeStr) {
+            this.argTypeStr = typeStr;
+        }
+    }
+
+    enum ExceptionKind {
+        NONE(""),
+        EXCEPTION("throws Exception"),
+        SQL_EXCEPTION("throws java.sql.SQLException"),
+        IO_EXCEPTION("throws java.io.IOException");
+
+        String exceptionStr;
+
+        ExceptionKind(String exceptionStr) {
+            this.exceptionStr = exceptionStr;
+        }
+    }
+
+    enum LambdaReturnKind {
+        VOID("return;"),
+        SHORT("return (short)0;"),
+        INT("return 0;"),
+        INTEGER("return (Integer)null"),
+        NULL("return null;");
+
+        String retStr;
+
+        LambdaReturnKind(String retStr) {
+            this.retStr = retStr;
+        }
+
+        boolean compatibleWith(RetTypeKind rk) {
+            return compatibleWith[rk.ordinal()][ordinal()];
+        }
+
+        static boolean[][] compatibleWith = {
+                //              VOID  | SHORT | INT     | INTEGER | NULL
+                /* SHORT */   { false , true  , false   , false   , false },
+                /* INT */     { false , true  , true    , true    , false },
+                /* OBJECT */  { false , true  , true    , true    , true  },
+                /* INTEGER */ { false , false , true    , true    , true  },
+                /* VOID */    { true  , false , false   , false   , false },
+                /* J_L_VOID */{ false , false , false   , false   , true  } };
+
+        boolean needsConversion(RetTypeKind rk) {
+            return needsConversion[rk.ordinal()][ordinal()];
+        }
+
+        static boolean[][] needsConversion = {
+                //              VOID  | SHORT | INT     | INTEGER | NULL
+                /* SHORT */   { false , false , false   , false   , false },
+                /* INT */     { false , false , false   , true    , false },
+                /* OBJECT */  { false , true  , true    , false   , false },
+                /* INTEGER */ { false , false , true    , false   , false },
+                /* VOID */    { false , false , false   , false   , false },
+                /* J_L_VOID */{ true  , false , false   , false   , false } };
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (LambdaReturnKind lrk : LambdaReturnKind.values()) {
+            for (RetTypeKind rk1 : RetTypeKind.values()) {
+                for (RetTypeKind rk2 : RetTypeKind.values()) {
+                    for (ExceptionKind ek1 : ExceptionKind.values()) {
+                        for (ExceptionKind ek2 : ExceptionKind.values()) {
+                            for (ArgTypeKind ak11 : ArgTypeKind.values()) {
+                                for (ArgTypeKind ak12 : ArgTypeKind.values()) {
+                                    new StructuralMostSpecificTest(lrk, rk1, rk2, ek1, ek2, ak11, ak12).run(comp, fm);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    LambdaReturnKind lrk;
+    RetTypeKind rt1, rt2;
+    ArgTypeKind ak1, ak2;
+    ExceptionKind ek1, ek2;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    StructuralMostSpecificTest(LambdaReturnKind lrk, RetTypeKind rt1, RetTypeKind rt2,
+            ExceptionKind ek1, ExceptionKind ek2, ArgTypeKind ak1, ArgTypeKind ak2) {
+        this.lrk = lrk;
+        this.rt1 = rt1;
+        this.rt2 = rt2;
+        this.ek1 = ek1;
+        this.ek2 = ek2;
+        this.ak1 = ak1;
+        this.ak2 = ak2;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "interface SAM1 {\n" +
+                          "   #R1 m(#A1 a1) #E1;\n" +
+                          "}\n" +
+                          "interface SAM2 {\n" +
+                          "   #R2 m(#A2 a1) #E2;\n" +
+                          "}\n" +
+                          "class Test {\n" +
+                          "   void m(SAM1 s) { }\n" +
+                          "   void m(SAM2 s) { }\n" +
+                          "   { m(x->{ #LR }); }\n" +
+                          "}\n";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#LR", lrk.retStr)
+                    .replaceAll("#R1", rt1.retTypeStr)
+                    .replaceAll("#R2", rt2.retTypeStr)
+                    .replaceAll("#A1", ak1.argTypeStr)
+                    .replaceAll("#A2", ak2.argTypeStr)
+                    .replaceAll("#E1", ek1.exceptionStr)
+                    .replaceAll("#E2", ek2.exceptionStr);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                Arrays.asList("-XDverboseResolution=all,-predef,-internal,-object-init"),
+                null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when analyzing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount++;
+
+        if (!lrk.compatibleWith(rt1) || !lrk.compatibleWith(rt2))
+            return;
+
+        if (lrk.needsConversion(rt1) != lrk.needsConversion(rt2))
+            return;
+
+        boolean m1MoreSpecific = moreSpecific(rt1, rt2, ek1, ek2, ak1, ak2);
+        boolean m2MoreSpecific = moreSpecific(rt2, rt1, ek2, ek1, ak2, ak1);
+
+        boolean ambiguous = (m1MoreSpecific == m2MoreSpecific);
+
+        if (ambiguous != diagChecker.ambiguityFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nAmbiguity found: " + diagChecker.ambiguityFound +
+                "\nm1 more specific: " + m1MoreSpecific +
+                "\nm2 more specific: " + m2MoreSpecific +
+                "\nexpected ambiguity: " + ambiguous);
+        }
+
+        if (!ambiguous) {
+            String sigToCheck = m1MoreSpecific ? "m(SAM1)" : "m(SAM2)";
+            if (!sigToCheck.equals(diagChecker.mostSpecificSig)) {
+                throw new Error("invalid most specific method selected:\n" +
+                source.getCharContent(true) +
+                "\nMost specific found: " + diagChecker.mostSpecificSig +
+                "\nm1 more specific: " + m1MoreSpecific +
+                "\nm2 more specific: " + m2MoreSpecific);
+            }
+        }
+    }
+
+    boolean moreSpecific(RetTypeKind rk1, RetTypeKind rk2, ExceptionKind ek1, ExceptionKind ek2,
+            ArgTypeKind ak1, ArgTypeKind ak2) {
+        if (!rk1.moreSpecificThan(rk2))
+            return false;
+
+        if (ak1 != ak2)
+            return false;
+
+        return true;
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean ambiguityFound;
+        String mostSpecificSig;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            try {
+                if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+                        diagnostic.getCode().equals("compiler.err.ref.ambiguous")) {
+                    ambiguityFound = true;
+                } else if (diagnostic.getKind() == Diagnostic.Kind.NOTE &&
+                        diagnostic.getCode().equals("compiler.note.verbose.resolve.multi")) {
+                    ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
+                            (ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic;
+                    JCDiagnostic.MultilineDiagnostic mdiag = (JCDiagnostic.MultilineDiagnostic)dsu.d;
+                    int mostSpecificIndex = (Integer)mdiag.getArgs()[2];
+                    mostSpecificSig = ((JCDiagnostic)mdiag.getSubdiagnostics().get(mostSpecificIndex)).getArgs()[1].toString();
+                }
+            } catch (RuntimeException t) {
+                t.printStackTrace();
+                throw t;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/A.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+
+public class A {
+    public A(NonExistentClass nec) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/DiamondFinder.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, 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 8003280
+ * @summary Add lambda tests
+ *  spurious crashes when running in 'diamond finder' mode
+ * @compile -XDfindDiamond DiamondFinder.java
+ */
+import java.util.*;
+
+class DiamondFinder {
+    Collection<String> f = new HashSet<String>(Arrays.asList("a"));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/Main.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  On-demand symbol completion during speculative attribution round fails to report error messages
+ * @compile/fail/ref=Main.out -XDrawDiagnostics Main.java
+ */
+class Main {
+    void test() {
+        m(new A(new Object()));
+        m(new A(null));
+    }
+
+    void m(Object o) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/speculative/Main.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+A.java:25:14: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, A, null)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest11.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   This test is for self referential and recursive lambda expression that have type inference
+ * @compile InferenceTest11.java
+ * @run main InferenceTest11
+ */
+
+public class InferenceTest11 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    static Func<Integer, Integer> f1;
+    static Func<Integer, ? extends Number> f2;
+
+    public static void main(String[] args) {
+
+        f1 = n -> {
+            if(n <= 0)
+                return 0;
+            if(n == 1)
+                return 1;
+            return f1.m(n-1) + f1.m(n-2);
+        };
+        assertTrue(f1.m(-1) == 0);
+        assertTrue(f1.m(0) == 0);
+        assertTrue(f1.m(10) == 55);
+
+        f2 = n -> {
+            if(n <= 1)
+            return 1.0;
+            return 2 * (Double)f2.m(n-1) + 1;
+        };
+        assertTrue(f2.m(4).doubleValue() == 15.0);
+    }
+
+    interface Func<T, V> {
+        V m(T t);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest2.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.io.Serializable;
+import java.io.File;
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Parameter types inferred from target type in generics without wildcard
+ * @compile InferenceTest2.java
+ * @run main InferenceTest2
+ */
+
+public class InferenceTest2 {
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        InferenceTest2 test = new InferenceTest2();
+
+        //test SAM1<T>
+        SAM1<String> sam1 = para -> { String result = "";
+                                      for(String s : para)
+                                          if(s.compareTo(result) > 0)
+                                              result = s;
+                                      return result; };
+        List<String> list = Arrays.asList("a", "b", "c");
+        assertTrue(sam1.m1(list).equals("c"));
+
+        test.method1(para -> para.get(0));
+
+        //test SAM2<T>
+        SAM2<String> sam2 = para -> {para = para.substring(0);};
+        SAM2<Double> sam2_2 = para -> {};
+        SAM2<File> sam2_3 = para -> { if(para.isDirectory())
+                                          System.out.println("directory");
+                                    };
+
+        //test SAM3<T>
+        SAM3<String> sam3 = para -> para[0].substring(0, para[0].length()-1);
+        assertTrue(sam3.m3("hello+").equals("hello"));
+
+        SAM3<Integer> sam3_2 = para -> para[0] - para[1];
+        assertTrue(sam3_2.m3(1, -1) == 2);
+
+        SAM3<Double> sam3_3 = para -> para[0] + para[1] + para[2] + para[3];
+        assertTrue(sam3_3.m3(1.0, 2.0, 3.0, 4.0) == 10.0);
+
+        test.method3(para -> para[0] + 1);
+
+        //test SAM6<T>
+        SAM6<String> sam6 = (para1, para2) -> para1.concat(para2);
+        assertTrue(sam6.m6("hello", "world").equals("helloworld"));
+
+        test.method6((para1, para2) -> para1 >= para2? para1 : para2);
+    }
+
+    void method1(SAM1<Integer> sam1) {
+        List<Integer> list = Arrays.asList(3,2,1);
+        assertTrue(sam1.m1(list) == 3);
+    }
+
+    void method3(SAM3<Double> sam3) {
+        assertTrue(sam3.m3(2.5) == 3.5);
+    }
+
+    void method6(SAM6<Long> sam6) {
+        assertTrue(sam6.m6(5L, -5L) == 5);
+    }
+
+    interface SAM1<T> {
+        T m1(List<T> x);
+    }
+
+    interface SAM2<T extends Serializable> {
+        void m2(T x);
+    }
+
+    interface SAM3<T> {
+        T m3(T... x);
+    }
+
+    interface SAM6<T> {
+        T m6(T a, T b);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest2b.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+import java.util.*;
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Parameter types inferred from target type in generics with wildcard
+ * @compile InferenceTest2b.java
+ * @run main InferenceTest2b
+ */
+
+public class InferenceTest2b {
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        InferenceTest2b test = new InferenceTest2b();
+
+        test.m1((a, b) -> {return a;});
+        test.m2((a, b) -> {return a;});
+        test.m3((a, b) -> a);
+    }
+
+    interface SAM6<T> {
+        T m6(T a, T b);
+    }
+
+    void m1(SAM6<? super List<?>> s) {
+        System.out.println("m1()");
+        Stack<String> a = new Stack<String>();
+        ArrayList<String> b = new ArrayList<String>();
+        assertTrue(s.m6(a, b) == a);
+
+        Vector<?> c = null;
+        assertTrue(s.m6(c, b) == c);
+    }
+
+    void m2(SAM6<? super Integer> s) {
+        System.out.println("m2()");
+        assertTrue(s.m6(1, 2) == 1);
+    }
+
+    void m3(SAM6<? super Calendar> s) {
+        System.out.println("m3()");
+        Calendar gc = Calendar.getInstance();
+        GregorianCalendar gc2 = new GregorianCalendar();
+        assertTrue(s.m6(gc, gc2) == gc);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest3.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  Interface inheritance, sub-interface resolves the type of the super interface.
+ * @compile InferenceTest3.java
+ * @run main InferenceTest3
+ */
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+public class InferenceTest3 {
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest3 test = new InferenceTest3();
+        test.m1(a -> a.getTime());
+        test.m2(a -> a.toString());
+
+        C<String, Integer> c = a -> a.length();
+        assertTrue(c.m("lambda") == 6);
+
+        E<Double, String> e = a -> Double.toHexString(a);
+        assertTrue(e.m(Double.MAX_VALUE).equals("0x1.fffffffffffffp1023"));
+        assertTrue(e.m(Double.MIN_VALUE).equals("0x0.0000000000001p-1022"));
+        assertTrue(e.m(1.0).equals("0x1.0p0"));
+    }
+
+    private void m1(C<Date, Long> c) {
+        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+        cal.set(1970, 0, 1, 0, 0, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        Date date = cal.getTime();
+        assertTrue(c.m(date) == 0L);
+    }
+
+    private void m2(E<Integer, String> e) {
+        assertTrue(e.m(2).equals("2"));
+    }
+
+    interface A<T extends Serializable, U> {
+        U m(T t);
+    }
+
+    interface C<X extends Serializable, Y extends Number> extends A<X,Y> {}
+
+    interface E<X extends Serializable, Y extends String> extends A<X,Y> {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest4.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  This test is for generic methods whose type is the same as the type
+            of the generic SAM interface that is taken as the parameter of the
+            generic method; the type can be inferred from the value of the other
+            type arguments
+ * @compile InferenceTest4.java
+ * @run main InferenceTest4
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class InferenceTest4 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest4 test = new InferenceTest4();
+        test.method1(n -> n.size(), "abc", "java.lang.String");
+        test.method1(n -> n.size(), 'c', "java.lang.Character");
+        test.method1(n -> n.size(), 0, "java.lang.Integer");
+        test.method1(n -> n.size(), 0.1, "java.lang.Double");
+        test.method1(n -> n.size(), 0.1f, "java.lang.Float");
+        test.method1(n -> n.size(), 0L, "java.lang.Long");
+        test.method1(n -> n.size(), (short)0, "java.lang.Short");
+        test.method1(n -> n.size(), (byte)0, "java.lang.Byte");
+        test.method1(n -> n.size(), true, "java.lang.Boolean");
+        test.method1(n -> n.size(), new int[]{1, 2, 3}, "[I");
+        test.method1(n -> n.size(), new double[]{1.0}, "[D");
+        test.method1(n -> n.size(), new String[]{}, "[Ljava.lang.String;");
+    }
+
+    <T> void method1(SAM1<T> s, T t, String className) {
+        List<T> list = new ArrayList<T>();
+        System.out.println(className + "-" + t.getClass().getName());
+        assertTrue(t.getClass().getName().equals(className));
+        list.add(t);
+        assertTrue(s.m1(list) == 1);
+    }
+
+    interface SAM1<T> {
+        int m1(List<T> x);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest5.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  This test is for overloaded methods, verify that the specific method is
+             selected when type inference occurs
+ * @compile InferenceTest5.java
+ * @run main InferenceTest5
+ */
+
+import java.util.List;
+import java.io.File;
+
+public class InferenceTest5 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest5 test = new InferenceTest5();
+        int n = test.method1((a, b) -> {} );
+        assertTrue(n == 1);
+
+        n = test.method1(() -> null);
+        assertTrue(n == 2);
+
+        n = test.method1(a -> null);
+        assertTrue(n == 3);
+
+        n = test.method1(a -> {});
+        assertTrue(n == 4);
+
+        n = test.method1(() -> {});
+        assertTrue(n == 5);
+
+        n = test.method1((a, b) -> 0);
+        assertTrue(n == 6);
+
+        n = test.method1((a, b) -> null);
+        assertTrue(n == 6);
+
+        n = test.method1((a, b) -> null, (a, b) -> null);
+        assertTrue(n == 7);
+    }
+
+    int method1(SAM1<String> s) {
+        return 1;
+    }
+
+    int method1(SAM2 s) {
+        return 2;
+    }
+
+    int method1(SAM3 s) {
+        return 3;
+    }
+
+    int method1(SAM4 s) {
+        return 4;
+    }
+
+    int method1(SAM5 s) {
+        return 5;
+    }
+
+    int method1(SAM6<?, ? super Integer> s) {
+        return 6;
+    }
+
+    int method1(SAM6<?, ?>... s) {
+        return 7;
+    }
+
+    static interface SAM1<T> {
+        void foo(List<T> a, List<T> b);
+    }
+
+    static interface SAM2 {
+        List<String> foo();
+    }
+
+    static interface SAM3 {
+        String foo(int a);
+    }
+
+    static interface SAM4 {
+        void foo(List<File> a);
+    }
+
+    static interface SAM5 {
+        void foo();
+    }
+
+    static interface SAM6<T, V> {
+        V get(T t, T t2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest789.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+import java.io.Serializable;
+import java.util.Calendar;
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  This test is for when lambda return type is inferred from target type
+ * @compile InferenceTest789.java
+ * @run main InferenceTest789
+ */
+
+public class InferenceTest789 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest789 test = new InferenceTest789();
+        test.method1(() -> 1);
+        SAM1<? extends Number> sam1 = () -> 1.0;
+        SAM1<? extends Serializable> sam1_2 = () -> "a";
+        SAM1<? extends Comparable<?>> sam1_3 = () -> Calendar.getInstance();
+        SAM1<?> sam1_4 = () -> 1.5f;
+
+        SAM2<Number> sam2 = a -> 1;
+        SAM2<? extends Serializable> sam2_2 = a -> 1;
+    }
+
+    void method1(SAM1<?> s) {
+        System.out.println("s.m1()=" + s.m1() + " s.m1().getClass()=" + s.m1().getClass());
+          assertTrue(s.m1().equals(new Integer(1)));
+    }
+
+    interface SAM1<T> {
+        T m1();
+    }
+
+    interface SAM2<T extends Serializable> {
+        T m2(T t);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,58 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Overloaded methods take raw SAM types that have type inference according to SAM descriptor
+             should have ambiguous resolution of method
+ * @compile/fail/ref=InferenceTest_neg1_2.out -XDrawDiagnostics InferenceTest_neg1_2.java
+ */
+
+public class InferenceTest_neg1_2 {
+
+    public static void main(String[] args) {
+        InferenceTest_neg1_2 test = new InferenceTest_neg1_2();
+        test.method(n -> null); //method 1-5 all match
+        test.method(n -> "a"); //method 2, 4 match
+        test.method(n -> 0); //method 1, 3, 5 match
+    }
+
+    void method(SAM1 s) { //method 1
+        Integer i = s.foo("a");
+    }
+
+    void method(SAM2 s) { //method 2
+        String str = s.foo(0);
+    }
+
+    void method(SAM3<Integer> s) { //method 3
+        Integer i = s.get(0);
+    }
+
+    void method(SAM4<Double, String> s) { //method 4
+        String str = s.get(0.0);
+    }
+
+    void method(SAM5<Integer> s) { //method 5
+        Integer i = s.get(0.0);
+    }
+
+    interface SAM1 {
+        Integer foo(String a);
+    }
+
+    interface SAM2 {
+        String foo(Integer a);
+    }
+
+    interface SAM3<T> {
+        T get(T t);
+    }
+
+    interface SAM4<T, V> {
+        V get(T t);
+    }
+
+    interface SAM5<T> {
+        T get(Double i);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,4 @@
+InferenceTest_neg1_2.java:14:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2
+InferenceTest_neg1_2.java:15:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM2), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2
+InferenceTest_neg1_2.java:16:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM3<java.lang.Integer>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Missing cast to SAM type that causes type inference to not work.
+ * @compile/fail/ref=InferenceTest_neg5.out -XDrawDiagnostics InferenceTest_neg5.java
+ */
+
+import java.util.*;
+
+public class InferenceTest_neg5 {
+    public static void main(String[] args) {
+        InferenceTest_neg5 test = new InferenceTest_neg5();
+        test.method1(n -> {});
+        test.method1((SAM1<String>)n -> {});
+        test.method1((SAM1<Integer>)n -> {n++;});
+        test.method1((SAM1<Comparator<String>>)n -> {List<String> list = Arrays.asList("string1", "string2"); Collections.sort(list,n);});
+        test.method1((SAM1<Thread>)n -> {n.start();});
+    }
+
+    interface SAM1<X> {
+        void m1(X arg);
+    }
+
+    <X> void method1(SAM1<X> s) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,2 @@
+InferenceTest_neg5.java:14:13: compiler.err.cant.apply.symbol: kindname.method, method1, InferenceTest_neg5.SAM1<X>, @419, kindname.class, InferenceTest_neg5, (compiler.misc.cyclic.inference: X)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java	Sat Nov 17 19:01:03 2012 +0000
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  perform automated checks in type inference in lambda expressions in different contexts
+ * @compile  TypeInferenceComboTest.java
+ * @run main/timeout=360 TypeInferenceComboTest
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import javax.tools.StandardJavaFileManager;
+
+public class TypeInferenceComboTest {
+    enum Context {
+        ASSIGNMENT("SAM#Type s = #LBody;"),
+        METHOD_CALL("#GenericDeclKind void method1(SAM#Type s) { }\n" +
+                    "void method2() {\n" +
+                    "    method1(#LBody);\n" +
+                    "}"),
+        RETURN_OF_METHOD("SAM#Type method1() {\n" +
+                "    return #LBody;\n" +
+                "}"),
+        LAMBDA_RETURN_EXPRESSION("SAM2 s2 = () -> {return (SAM#Type)#LBody;};\n"),
+        ARRAY_INITIALIZER("Object[] oarray = {\"a\", 1, (SAM#Type)#LBody};");
+
+        String context;
+
+        Context(String context) {
+            this.context = context;
+        }
+
+        String getContext(SamKind sk, TypeKind samTargetT, Keyword kw, TypeKind parameterT, TypeKind returnT, LambdaKind lk, ParameterKind pk, GenericDeclKind gdk, LambdaBody lb) {
+            String result = context;
+            if (sk == SamKind.GENERIC) {
+                if(this == Context.METHOD_CALL) {
+                    result = result.replaceAll("#GenericDeclKind", gdk.getGenericDeclKind(samTargetT));
+                    if(gdk == GenericDeclKind.NON_GENERIC)
+                        result = result.replaceAll("#Type", "<" + samTargetT.typeStr + ">");
+                    else //#GenericDeclKind is <T> or <T extends xxx>
+                        result = result.replaceAll("#Type", "<T>");
+                }
+                else {
+                    if(kw == Keyword.VOID)
+                        result = result.replaceAll("#Type", "<" + samTargetT.typeStr + ">");
+                    else
+                        result = result.replaceAll("#Type", "<? " + kw.keyStr + " " + samTargetT.typeStr + ">");
+                }
+            }
+            else
+                result = result.replaceAll("#Type", "").replaceAll("#GenericDeclKind", "");
+
+            return result.replaceAll("#LBody", lb.getLambdaBody(samTargetT, parameterT, returnT, lk, pk));
+        }
+    }
+
+    enum SamKind {
+        GENERIC("interface SAM<T> { #R m(#ARG); }"),
+        NON_GENERIC("interface SAM { #R m(#ARG); }");
+
+        String sam_str;
+
+        SamKind(String sam_str) {
+            this.sam_str = sam_str;
+        }
+
+        String getSam(TypeKind parameterT, TypeKind returnT) {
+            return sam_str.replaceAll("#ARG", parameterT == TypeKind.VOID ? "" : parameterT.typeStr + " arg")
+                          .replaceAll("#R", returnT.typeStr);
+        }
+    }
+
+    enum TypeKind {
+        VOID("void", ""),
+        STRING("String", "\"hello\""),
+        INTEGER("Integer", "1"),
+        INT("int", "0"),
+        COMPARATOR("java.util.Comparator<String>", "(java.util.Comparator<String>)(a, b) -> a.length()-b.length()"),
+        SAM("SAM2", "null"),
+        GENERIC("T", null);
+
+        String typeStr;
+        String valStr;
+
+        TypeKind(String typeStr, String valStr) {
+            this.typeStr = typeStr;
+            this.valStr = valStr;
+        }
+    }
+
+    enum LambdaKind {
+        EXPRESSION("#VAL"),
+        STATEMENT("{return #VAL;}");
+
+        String stmt;
+
+        LambdaKind(String stmt) {
+            this.stmt = stmt;
+        }
+    }
+
+    enum ParameterKind {
+        EXPLICIT("#TYPE"),
+        IMPLICIT("");
+
+        String paramTemplate;
+
+        ParameterKind(String paramTemplate) {
+             this.paramTemplate = paramTemplate;
+        }
+    }
+
+    enum Keyword {
+        SUPER("super"),
+        EXTENDS("extends"),
+        VOID("");
+
+        String keyStr;
+
+        Keyword(String keyStr) {
+            this.keyStr = keyStr;
+        }
+    }
+
+    enum LambdaBody {
+        RETURN_VOID("() -> #RET"),//no parameters, return type is one of the TypeKind
+        RETURN_ARG("(#PK arg) -> #RET");//has parameters, return type is one of the TypeKind
+
+        String bodyStr;
+
+        LambdaBody(String bodyStr) {
+            this.bodyStr = bodyStr;
+        }
+
+        String getLambdaBody(TypeKind samTargetT, TypeKind parameterT, TypeKind returnT, LambdaKind lk, ParameterKind pk) {
+            String result = bodyStr.replaceAll("#PK", pk.paramTemplate);
+
+            if(result.contains("#TYPE")) {
+                if (parameterT == TypeKind.GENERIC && this != RETURN_VOID)
+                    result = result.replaceAll("#TYPE", samTargetT == null? "": samTargetT.typeStr);
+                else
+                    result = result.replaceAll("#TYPE", parameterT.typeStr);
+            }
+            if (this == RETURN_ARG && parameterT == returnT)
+                return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", "arg"));
+            else {
+                if(returnT != TypeKind.GENERIC)
+                    return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", (returnT==TypeKind.VOID && lk==LambdaKind.EXPRESSION)? "{}" : returnT.valStr));
+                else
+                    return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", samTargetT.valStr));
+            }
+        }
+    }
+
+    enum GenericDeclKind {
+        NON_GENERIC(""),
+        GENERIC_NOBOUND("<T>"),
+        GENERIC_BOUND("<T extends #ExtendedType>");
+        String typeStr;
+
+        GenericDeclKind(String typeStr) {
+            this.typeStr = typeStr;
+        }
+
+        String getGenericDeclKind(TypeKind et) {
+            return typeStr.replaceAll("#ExtendedType", et==null? "":et.typeStr);
+        }
+    }
+
+    boolean checkTypeInference() {
+        if (parameterType == TypeKind.VOID) {
+            if (lambdaBodyType != LambdaBody.RETURN_VOID)
+                return false;
+        }
+        else if (lambdaBodyType != LambdaBody.RETURN_ARG)
+            return false;
+        if (  genericDeclKind == GenericDeclKind.GENERIC_NOBOUND || genericDeclKind == GenericDeclKind.GENERIC_BOUND ) {
+            if ( parameterType == TypeKind.GENERIC && parameterKind == ParameterKind.IMPLICIT) //cyclic inference
+                return false;
+        }
+        return true;
+    }
+
+    String templateStr = "#C\n" +
+                         "interface SAM2 {\n" +
+                         "    SAM m();\n" +
+                         "}\n";
+    SourceFile samSourceFile = new SourceFile("Sam.java", templateStr) {
+        public String toString() {
+            return template.replaceAll("#C", samKind.getSam(parameterType, returnType));
+        }
+    };
+
+    SourceFile clientSourceFile = new SourceFile("Client.java",
+                                                 "class Client { \n" +
+                                                 "    #Context\n" +
+                                                 "}") {
+        public String toString() {
+            return template.replaceAll("#Context", context.getContext(samKind, samTargetType, keyword, parameterType, returnType, lambdaKind, parameterKind, genericDeclKind, lambdaBodyType));
+        }
+    };
+
+    void test() throws Exception {
+        System.out.println("kk:");
+        StringBuilder sb = new StringBuilder("SamKind:");
+        sb.append(samKind).append(" SamTargetType:").append(samTargetType).append(" ParameterType:").append(parameterType)
+            .append(" ReturnType:").append(returnType).append(" Context:").append(context).append(" LambdaKind:").append(lambdaKind)
+            .append(" LambdaBodyType:").append(lambdaBodyType).append(" ParameterKind:").append(parameterKind).append(" Keyword:").append(keyword);
+        System.out.println(sb);
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkTypeInference()) {
+            throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile + "\n" + parameterType + " " + returnType);
+        }
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+    SamKind samKind;
+    TypeKind samTargetType;
+    TypeKind parameterType;
+    TypeKind returnType;
+    Context context;
+    LambdaBody lambdaBodyType;
+    LambdaKind lambdaKind;
+    ParameterKind parameterKind;
+    Keyword keyword;
+    GenericDeclKind genericDeclKind;
+
+    static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+    static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+    TypeInferenceComboTest(SamKind sk, TypeKind samTargetT, TypeKind parameterT, TypeKind returnT, LambdaBody lb, Context c, LambdaKind lk, ParameterKind pk, Keyword kw, GenericDeclKind gdk) {
+        samKind = sk;
+        samTargetType = samTargetT;
+        parameterType = parameterT;
+        returnType = returnT;
+        context = c;
+        lambdaKind = lk;
+        parameterKind = pk;
+        keyword = kw;
+        lambdaBodyType = lb;
+        genericDeclKind = gdk;
+    }
+
+    public static void main(String[] args) throws Exception {
+        for(Context ct : Context.values()) {
+            for (TypeKind returnT : TypeKind.values()) {
+                for (TypeKind parameterT : TypeKind.values()) {
+                    for(LambdaBody lb : LambdaBody.values()) {
+                        for (ParameterKind parameterK : ParameterKind.values()) {
+                            for(LambdaKind lambdaK : LambdaKind.values()) {
+                                for (SamKind sk : SamKind.values()) {
+                                    if (sk == SamKind.NON_GENERIC) {
+                                        if(parameterT != TypeKind.GENERIC && returnT != TypeKind.GENERIC )
+                                            new TypeInferenceComboTest(sk, null, parameterT, returnT, lb, ct, lambdaK, parameterK, null, null).test();
+                                    }
+                                    else if (sk == SamKind.GENERIC) {
+                                        for (Keyword kw : Keyword.values()) {
+                                            for (TypeKind samTargetT : TypeKind.values()) {
+                                                if(samTargetT != TypeKind.VOID && samTargetT != TypeKind.INT && samTargetT != TypeKind.GENERIC
+                                                   && (parameterT == TypeKind.GENERIC || returnT == TypeKind.GENERIC)) {
+                                                    if(ct != Context.METHOD_CALL) {
+                                                        new TypeInferenceComboTest(sk, samTargetT, parameterT, returnT, lb, ct, lambdaK, parameterK, kw, null).test();
+                                                    }
+                                                    else {//Context.METHOD_CALL
+                                                        for (GenericDeclKind gdk : GenericDeclKind.values())
+                                                            new TypeInferenceComboTest(sk, samTargetT, parameterT, returnT, lb, ct, lambdaK, parameterK, kw, gdk).test();
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
--- a/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out	Fri Nov 16 18:27:36 2012 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.out	Sat Nov 17 19:01:03 2012 +0000
@@ -10,7 +10,6 @@
 BasicTest.java:52:31: compiler.err.expected: ';'
 BasicTest.java:52:37: compiler.err.expected: token.identifier
 BasicTest.java:53:30: compiler.err.expected: token.identifier
-BasicTest.java:53:32: compiler.err.lambda.not.supported.in.source: 1.8
 BasicTest.java:53:31: compiler.err.expected: ->
 BasicTest.java:56:23: compiler.err.expected: token.identifier
 BasicTest.java:56:24: compiler.err.expected2: '(', '['
@@ -59,4 +58,4 @@
 BasicTest.java:74:25: compiler.err.illegal.start.of.type
 BasicTest.java:74:33: compiler.err.expected: ';'
 BasicTest.java:77:2: compiler.err.premature.eof
-61 errors
+60 errors