Merge
authorlana
Thu, 12 Nov 2015 14:13:17 -0800
changeset 33905 1a0b6de8abc2
parent 33704 5a786e03d28a (current diff)
parent 33715 74b1bed86932 (diff)
child 33906 91b6bee06dc1
Merge
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Thu Nov 12 14:13:17 2015 -0800
@@ -126,10 +126,9 @@
      */
     public static final int BLOCK            = 1<<20;
 
-    /** Flag is set for compiler-generated abstract methods that implement
-     *  an interface method (Miranda methods).
+    /** Flag bit 21 is available. (used earlier to tag compiler-generated abstract methods that implement
+     *  an interface method (Miranda methods)).
      */
-    public static final int IPROXY           = 1<<21;
 
     /** Flag is set for nested classes that do not access instance members
      *  or `this' of an outer class and therefore don't need to be passed
@@ -362,7 +361,6 @@
         BLOCK(Flags.BLOCK),
         ENUM(Flags.ENUM),
         MANDATED(Flags.MANDATED),
-        IPROXY(Flags.IPROXY),
         NOOUTERTHIS(Flags.NOOUTERTHIS),
         EXISTS(Flags.EXISTS),
         COMPOUND(Flags.COMPOUND),
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Nov 12 14:13:17 2015 -0800
@@ -180,6 +180,14 @@
                 : metadata.getInitTypeAttributes();
     }
 
+    public void setInitTypeAttributes(List<Attribute.TypeCompound> l) {
+        initedMetadata().setInitTypeAttributes(l);
+    }
+
+    public void setClassInitTypeAttributes(List<Attribute.TypeCompound> l) {
+        initedMetadata().setClassInitTypeAttributes(l);
+    }
+
     public List<Attribute.Compound> getDeclarationAttributes() {
         return (metadata == null)
                 ? List.<Attribute.Compound>nil()
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Thu Nov 12 14:13:17 2015 -0800
@@ -32,6 +32,7 @@
 
 import com.sun.tools.javac.code.Attribute.Array;
 import com.sun.tools.javac.code.Attribute.TypeCompound;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.TypeSymbol;
 import com.sun.tools.javac.code.Type.ArrayType;
 import com.sun.tools.javac.code.Type.CapturedType;
@@ -388,8 +389,21 @@
                 sym.getKind() == ElementKind.RESOURCE_VARIABLE ||
                 sym.getKind() == ElementKind.EXCEPTION_PARAMETER) {
                 // Make sure all type annotations from the symbol are also
-                // on the owner.
-                sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes());
+                // on the owner. If the owner is an initializer block, propagate
+                // to the type.
+                final long ownerFlags = sym.owner.flags();
+                if ((ownerFlags & Flags.BLOCK) != 0) {
+                    // Store init and clinit type annotations with the ClassSymbol
+                    // to allow output in Gen.normalizeDefs.
+                    ClassSymbol cs = (ClassSymbol) sym.owner.owner;
+                    if ((ownerFlags & Flags.STATIC) != 0) {
+                        cs.appendClassInitTypeAttributes(typeAnnotations);
+                    } else {
+                        cs.appendInitTypeAttributes(typeAnnotations);
+                    }
+                } else {
+                    sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes());
+                }
             }
         }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Thu Nov 12 14:13:17 2015 -0800
@@ -2763,7 +2763,7 @@
                 Scope s = c.members();
                 for (Symbol sym : s.getSymbols(NON_RECURSIVE)) {
                     if (sym.kind == MTH &&
-                        (sym.flags() & (ABSTRACT|IPROXY|DEFAULT|PRIVATE)) == ABSTRACT) {
+                        (sym.flags() & (ABSTRACT|DEFAULT|PRIVATE)) == ABSTRACT) {
                         MethodSymbol absmeth = (MethodSymbol)sym;
                         MethodSymbol implmeth = absmeth.implementation(impl, this, true);
                         if (implmeth == null || implmeth == absmeth) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Nov 12 14:13:17 2015 -0800
@@ -1890,7 +1890,8 @@
 
             // Check that value of resulting type is admissible in the
             // current context.  Also, capture the return type
-            result = check(tree, capture(restype), KindSelector.VAL, resultInfo);
+            Type capturedRes = resultInfo.checkContext.inferenceContext().cachedCapture(tree, restype, true);
+            result = check(tree, capturedRes, KindSelector.VAL, resultInfo);
         }
         chk.validate(tree.typeargs, localEnv);
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Nov 12 14:13:17 2015 -0800
@@ -1730,11 +1730,18 @@
         boolean resultTypesOK =
             types.returnTypeSubstitutable(mt, ot, otres, overrideWarner);
         if (!resultTypesOK) {
-            log.error(TreeInfo.diagnosticPositionFor(m, tree),
-                      "override.incompatible.ret",
-                      cannotOverride(m, other),
-                      mtres, otres);
-            m.flags_field |= BAD_OVERRIDE;
+            if ((m.flags() & STATIC) != 0 && (other.flags() & STATIC) != 0) {
+                log.error(TreeInfo.diagnosticPositionFor(m, tree),
+                        Errors.OverrideIncompatibleRet(Fragments.CantHide(m, m.location(), other,
+                                        other.location()), mtres, otres));
+                m.flags_field |= BAD_OVERRIDE;
+            } else {
+                log.error(TreeInfo.diagnosticPositionFor(m, tree),
+                        "override.incompatible.ret",
+                        cannotOverride(m, other),
+                        mtres, otres);
+                m.flags_field |= BAD_OVERRIDE;
+            }
             return;
         } else if (overrideWarner.hasNonSilentLint(LintCategory.UNCHECKED)) {
             warnUnchecked(TreeInfo.diagnosticPositionFor(m, tree),
@@ -2371,7 +2378,6 @@
                     types.isSameType(types.erasure(sym.type), types.erasure(sym2.type)) &&
                     sym != sym2 &&
                     (sym.flags() & Flags.SYNTHETIC) != (sym2.flags() & Flags.SYNTHETIC) &&
-                    (sym.flags() & IPROXY) == 0 && (sym2.flags() & IPROXY) == 0 &&
                     (sym.flags() & BRIDGE) == 0 && (sym2.flags() & BRIDGE) == 0) {
                     syntheticError(pos, (sym2.flags() & SYNTHETIC) == 0 ? sym2 : sym);
                     return;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Nov 12 14:13:17 2015 -0800
@@ -372,6 +372,9 @@
                         resultInfo, inferenceContext);
                 }
             }
+        } else if (rsInfoInfContext.free(resultInfo.pt)) {
+            //propagation - cache captured vars
+            qtype = inferenceContext.asUndetVar(rsInfoInfContext.cachedCapture(tree, from, false));
         }
         Assert.check(allowGraphInference || !rsInfoInfContext.free(to),
                 "legacy inference engine cannot handle constraints on both sides of a subtyping assertion");
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Thu Nov 12 14:13:17 2015 -0800
@@ -55,12 +55,16 @@
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
 
 import static com.sun.tools.javac.comp.LambdaToMethod.LambdaSymbolKind.*;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
+
+import javax.lang.model.element.ElementKind;
 import javax.lang.model.type.TypeKind;
 
 /**
@@ -268,21 +272,34 @@
         MethodSymbol sym = localContext.translatedSym;
         MethodType lambdaType = (MethodType) sym.type;
 
-        {
+        {   /* Type annotation management: Based on where the lambda features, type annotations that
+               are interior to it, may at this point be attached to the enclosing method, or the first
+               constructor in the class, or in the enclosing class symbol or in the field whose
+               initializer is the lambda. In any event, gather up the annotations that belong to the
+               lambda and attach it to the implementation method.
+            */
+
             Symbol owner = localContext.owner;
-            ListBuffer<Attribute.TypeCompound> ownerTypeAnnos = new ListBuffer<>();
-            ListBuffer<Attribute.TypeCompound> lambdaTypeAnnos = new ListBuffer<>();
+            apportionTypeAnnotations(tree,
+                    owner::getRawTypeAttributes,
+                    owner::setTypeAttributes,
+                    sym::setTypeAttributes);
+
 
-            for (Attribute.TypeCompound tc : owner.getRawTypeAttributes()) {
-                if (tc.position.onLambda == tree) {
-                    lambdaTypeAnnos.append(tc);
-                } else {
-                    ownerTypeAnnos.append(tc);
-                }
+            boolean init;
+            if ((init = (owner.name == names.init)) || owner.name == names.clinit) {
+                owner = owner.owner;
+                apportionTypeAnnotations(tree,
+                        init ? owner::getInitTypeAttributes : owner::getClassInitTypeAttributes,
+                        init ? owner::setInitTypeAttributes : owner::setClassInitTypeAttributes,
+                        sym::appendUniqueTypeAttributes);
             }
-            if (lambdaTypeAnnos.nonEmpty()) {
-                owner.setTypeAttributes(ownerTypeAnnos.toList());
-                sym.setTypeAttributes(lambdaTypeAnnos.toList());
+            if (localContext.self != null && localContext.self.getKind() == ElementKind.FIELD) {
+                owner = localContext.self;
+                apportionTypeAnnotations(tree,
+                        owner::getRawTypeAttributes,
+                        owner::setTypeAttributes,
+                        sym::appendUniqueTypeAttributes);
             }
         }
 
@@ -338,6 +355,11 @@
                 syntheticInits.append((JCExpression) captured_local);
             }
         }
+        // add captured outer this instances (used only when `this' capture itself is illegal)
+        for (Symbol fv : localContext.getSymbolMap(CAPTURED_OUTER_THIS).keySet()) {
+            JCTree captured_local = make.QualThis(fv.type);
+            syntheticInits.append((JCExpression) captured_local);
+        }
 
         //then, determine the arguments to the indy call
         List<JCExpression> indy_args = translate(syntheticInits.toList(), localContext.prev);
@@ -349,6 +371,29 @@
         result = makeMetafactoryIndyCall(context, refKind, sym, indy_args);
     }
 
+    // where
+        // Reassign type annotations from the source that should really belong to the lambda
+        private void apportionTypeAnnotations(JCLambda tree,
+                                              Supplier<List<Attribute.TypeCompound>> source,
+                                              Consumer<List<Attribute.TypeCompound>> owner,
+                                              Consumer<List<Attribute.TypeCompound>> lambda) {
+
+            ListBuffer<Attribute.TypeCompound> ownerTypeAnnos = new ListBuffer<>();
+            ListBuffer<Attribute.TypeCompound> lambdaTypeAnnos = new ListBuffer<>();
+
+            for (Attribute.TypeCompound tc : source.get()) {
+                if (tc.position.onLambda == tree) {
+                    lambdaTypeAnnos.append(tc);
+                } else {
+                    ownerTypeAnnos.append(tc);
+                }
+            }
+            if (lambdaTypeAnnos.nonEmpty()) {
+                owner.accept(ownerTypeAnnos.toList());
+                lambda.accept(lambdaTypeAnnos.toList());
+            }
+        }
+
     private JCIdent makeThis(Type type, Symbol owner) {
         VarSymbol _this = new VarSymbol(PARAMETER | FINAL | SYNTHETIC,
                 names._this,
@@ -434,6 +479,32 @@
         }
     }
 
+    /**
+     * Translate qualified `this' references within a lambda to the mapped identifier
+     * @param tree
+     */
+    @Override
+    public void visitSelect(JCFieldAccess tree) {
+        if (context == null || !analyzer.lambdaFieldAccessFilter(tree)) {
+            super.visitSelect(tree);
+        } else {
+            int prevPos = make.pos;
+            try {
+                make.at(tree);
+
+                LambdaTranslationContext lambdaContext = (LambdaTranslationContext) context;
+                JCTree ltree = lambdaContext.translate(tree);
+                if (ltree != null) {
+                    result = ltree;
+                } else {
+                    super.visitSelect(tree);
+                }
+            } finally {
+                make.at(prevPos);
+            }
+        }
+    }
+
     @Override
     public void visitVarDef(JCVariableDecl tree) {
         LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context;
@@ -1128,6 +1199,11 @@
         private int lambdaCount = 0;
 
         /**
+         * List of types undergoing construction via explicit constructor chaining.
+         */
+        private List<ClassSymbol> typesUnderConstruction;
+
+        /**
          * keep the count of lambda expression defined in given context (used to
          * generate unambiguous names for serializable lambdas)
          */
@@ -1157,11 +1233,36 @@
 
         private JCClassDecl analyzeAndPreprocessClass(JCClassDecl tree) {
             frameStack = List.nil();
+            typesUnderConstruction = List.nil();
             localClassDefs = new HashMap<>();
             return translate(tree);
         }
 
         @Override
+        public void visitApply(JCMethodInvocation tree) {
+            List<ClassSymbol> previousNascentTypes = typesUnderConstruction;
+            try {
+                Name methName = TreeInfo.name(tree.meth);
+                if (methName == names._this || methName == names._super) {
+                    typesUnderConstruction = typesUnderConstruction.prepend(currentClass());
+                }
+                super.visitApply(tree);
+            } finally {
+                typesUnderConstruction = previousNascentTypes;
+            }
+        }
+            // where
+            private ClassSymbol currentClass() {
+                for (Frame frame : frameStack) {
+                    if (frame.tree.hasTag(JCTree.Tag.CLASSDEF)) {
+                        JCClassDecl cdef = (JCClassDecl) frame.tree;
+                        return cdef.sym;
+                    }
+                }
+                return null;
+            }
+
+        @Override
         public void visitBlock(JCBlock tree) {
             List<Frame> prevStack = frameStack;
             try {
@@ -1633,6 +1734,22 @@
         }
 
         /**
+         *  This is used to filter out those select nodes that need to be adjusted
+         *  when translating away lambda expressions - at the moment, this is the
+         *  set of nodes that select `this' (qualified this)
+         */
+        private boolean lambdaFieldAccessFilter(JCFieldAccess fAccess) {
+            LambdaTranslationContext lambdaContext =
+                    context instanceof LambdaTranslationContext ?
+                            (LambdaTranslationContext) context : null;
+            return lambdaContext != null
+                    && !fAccess.sym.isStatic()
+                    && fAccess.name == names._this
+                    && (fAccess.sym.owner.kind == TYP)
+                    && !lambdaContext.translatedSymbols.get(CAPTURED_OUTER_THIS).isEmpty();
+        }
+
+        /**
          * This is used to filter out those new class expressions that need to
          * be qualified with an enclosing tree
          */
@@ -1806,6 +1923,7 @@
                 translatedSymbols.put(LOCAL_VAR, new LinkedHashMap<Symbol, Symbol>());
                 translatedSymbols.put(CAPTURED_VAR, new LinkedHashMap<Symbol, Symbol>());
                 translatedSymbols.put(CAPTURED_THIS, new LinkedHashMap<Symbol, Symbol>());
+                translatedSymbols.put(CAPTURED_OUTER_THIS, new LinkedHashMap<Symbol, Symbol>());
                 translatedSymbols.put(TYPE_VAR, new LinkedHashMap<Symbol, Symbol>());
 
                 freeVarProcessedLocalClasses = new HashSet<>();
@@ -1918,6 +2036,16 @@
                             }
                         };
                         break;
+                    case CAPTURED_OUTER_THIS:
+                        Name name = names.fromString(new String(sym.flatName().toString() + names.dollarThis));
+                        ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) {
+                            @Override
+                            public Symbol baseSymbol() {
+                                //keep mapping with original captured symbol
+                                return sym;
+                            }
+                        };
+                        break;
                     case LOCAL_VAR:
                         ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym);
                         ((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
@@ -1938,6 +2066,14 @@
             }
 
             void addSymbol(Symbol sym, LambdaSymbolKind skind) {
+                if (skind == CAPTURED_THIS && sym != null && sym.kind == TYP && !typesUnderConstruction.isEmpty()) {
+                    ClassSymbol currentClass = currentClass();
+                    if (currentClass != null && typesUnderConstruction.contains(currentClass)) {
+                        // reference must be to enclosing outer instance, mutate capture kind.
+                        Assert.check(sym != currentClass); // should have been caught right in Attr
+                        skind = CAPTURED_OUTER_THIS;
+                    }
+                }
                 Map<Symbol, Symbol> transMap = getSymbolMap(skind);
                 if (!transMap.containsKey(sym)) {
                     transMap.put(sym, translate(sym, skind));
@@ -1951,17 +2087,49 @@
             }
 
             JCTree translate(JCIdent lambdaIdent) {
-                for (Map<Symbol, Symbol> m : translatedSymbols.values()) {
-                    if (m.containsKey(lambdaIdent.sym)) {
-                        Symbol tSym = m.get(lambdaIdent.sym);
-                        JCTree t = make.Ident(tSym).setType(lambdaIdent.type);
-                        tSym.setTypeAttributes(lambdaIdent.sym.getRawTypeAttributes());
-                        return t;
+                for (LambdaSymbolKind kind : LambdaSymbolKind.values()) {
+                    Map<Symbol, Symbol> m = getSymbolMap(kind);
+                    switch(kind) {
+                        default:
+                            if (m.containsKey(lambdaIdent.sym)) {
+                                Symbol tSym = m.get(lambdaIdent.sym);
+                                JCTree t = make.Ident(tSym).setType(lambdaIdent.type);
+                                tSym.setTypeAttributes(lambdaIdent.sym.getRawTypeAttributes());
+                                return t;
+                            }
+                            break;
+                        case CAPTURED_OUTER_THIS:
+                            if (lambdaIdent.sym.owner.kind == TYP && m.containsKey(lambdaIdent.sym.owner)) {
+                                // Transform outer instance variable references anchoring them to the captured synthetic.
+                                Symbol tSym = m.get(lambdaIdent.sym.owner);
+                                JCExpression t = make.Ident(tSym).setType(lambdaIdent.sym.owner.type);
+                                tSym.setTypeAttributes(lambdaIdent.sym.owner.getRawTypeAttributes());
+                                t = make.Select(t, lambdaIdent.name);
+                                t.setType(lambdaIdent.type);
+                                TreeInfo.setSymbol(t, lambdaIdent.sym);
+                                return t;
+                            }
+                            break;
                     }
                 }
                 return null;
             }
 
+            /* Translate away qualified this expressions, anchoring them to synthetic parameters that
+               capture the qualified this handle. `fieldAccess' is guaranteed to one such.
+            */
+            public JCTree translate(JCFieldAccess fieldAccess) {
+                Assert.check(fieldAccess.name == names._this);
+                Map<Symbol, Symbol> m = translatedSymbols.get(LambdaSymbolKind.CAPTURED_OUTER_THIS);
+                if (m.containsKey(fieldAccess.sym.owner)) {
+                    Symbol tSym = m.get(fieldAccess.sym.owner);
+                    JCExpression t = make.Ident(tSym).setType(fieldAccess.sym.owner.type);
+                    tSym.setTypeAttributes(fieldAccess.sym.owner.getRawTypeAttributes());
+                    return t;
+                }
+                return null;
+            }
+
             /**
              * The translatedSym is not complete/accurate until the analysis is
              * finished.  Once the analysis is finished, the translatedSym is
@@ -1999,6 +2167,10 @@
                     params.append(make.VarDef((VarSymbol) thisSym, null));
                     parameterSymbols.append((VarSymbol) thisSym);
                 }
+                for (Symbol thisSym : getSymbolMap(CAPTURED_OUTER_THIS).values()) {
+                    params.append(make.VarDef((VarSymbol) thisSym, null));
+                    parameterSymbols.append((VarSymbol) thisSym);
+                }
                 for (Symbol thisSym : getSymbolMap(PARAM).values()) {
                     params.append(make.VarDef((VarSymbol) thisSym, null));
                     parameterSymbols.append((VarSymbol) thisSym);
@@ -2096,9 +2268,6 @@
              */
             boolean interfaceParameterIsIntersectionType() {
                 List<Type> tl = tree.getDescriptorType(types).getParameterTypes();
-                if (tree.kind == ReferenceKind.UNBOUND) {
-                    tl = tl.tail;
-                }
                 for (; tl.nonEmpty(); tl = tl.tail) {
                     Type pt = tl.head;
                     if (pt.getKind() == TypeKind.TYPEVAR) {
@@ -2147,6 +2316,7 @@
         LOCAL_VAR,      // original to translated lambda locals
         CAPTURED_VAR,   // variables in enclosing scope to translated synthetic parameters
         CAPTURED_THIS,  // class symbols to translated synthetic parameters (for captured member access)
+        CAPTURED_OUTER_THIS, // used when `this' capture is illegal, but outer this capture is legit (JDK-8129740)
         TYPE_VAR       // original to translated lambda type variables
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Nov 12 14:13:17 2015 -0800
@@ -1740,7 +1740,7 @@
     private JCStatement makeResourceCloseInvocation(JCExpression resource) {
         // convert to AutoCloseable if needed
         if (types.asSuper(resource.type, syms.autoCloseableType.tsym) == null) {
-            resource = (JCExpression) convert(resource, syms.autoCloseableType);
+            resource = convert(resource, syms.autoCloseableType);
         }
 
         // create resource.close() method invocation
@@ -2179,7 +2179,7 @@
  *************************************************************************/
 
     interface TreeBuilder {
-        JCTree build(JCTree arg);
+        JCExpression build(JCExpression arg);
     }
 
     /** Construct an expression using the builder, with the given rval
@@ -2197,7 +2197,7 @@
      *  where <code><b>TEMP</b></code> is a newly declared variable
      *  in the let expression.
      */
-    JCTree abstractRval(JCTree rval, Type type, TreeBuilder builder) {
+    JCExpression abstractRval(JCExpression rval, Type type, TreeBuilder builder) {
         rval = TreeInfo.skipParens(rval);
         switch (rval.getTag()) {
         case LITERAL:
@@ -2215,15 +2215,15 @@
                                       type,
                                       currentMethodSym);
         rval = convert(rval,type);
-        JCVariableDecl def = make.VarDef(var, (JCExpression)rval); // XXX cast
-        JCTree built = builder.build(make.Ident(var));
-        JCTree res = make.LetExpr(def, built);
+        JCVariableDecl def = make.VarDef(var, rval); // XXX cast
+        JCExpression built = builder.build(make.Ident(var));
+        JCExpression res = make.LetExpr(def, built);
         res.type = built.type;
         return res;
     }
 
     // same as above, with the type of the temporary variable computed
-    JCTree abstractRval(JCTree rval, TreeBuilder builder) {
+    JCExpression abstractRval(JCExpression rval, TreeBuilder builder) {
         return abstractRval(rval, rval.type, builder);
     }
 
@@ -2232,30 +2232,28 @@
     // Select expressions, where we place the left-hand-side of the
     // select in a temporary, and for Indexed expressions, where we
     // place both the indexed expression and the index value in temps.
-    JCTree abstractLval(JCTree lval, final TreeBuilder builder) {
+    JCExpression abstractLval(JCExpression lval, final TreeBuilder builder) {
         lval = TreeInfo.skipParens(lval);
         switch (lval.getTag()) {
         case IDENT:
             return builder.build(lval);
         case SELECT: {
             final JCFieldAccess s = (JCFieldAccess)lval;
-            JCTree selected = TreeInfo.skipParens(s.selected);
             Symbol lid = TreeInfo.symbol(s.selected);
             if (lid != null && lid.kind == TYP) return builder.build(lval);
             return abstractRval(s.selected, new TreeBuilder() {
-                    public JCTree build(final JCTree selected) {
-                        return builder.build(make.Select((JCExpression)selected, s.sym));
+                    public JCExpression build(final JCExpression selected) {
+                        return builder.build(make.Select(selected, s.sym));
                     }
                 });
         }
         case INDEXED: {
             final JCArrayAccess i = (JCArrayAccess)lval;
             return abstractRval(i.indexed, new TreeBuilder() {
-                    public JCTree build(final JCTree indexed) {
+                    public JCExpression build(final JCExpression indexed) {
                         return abstractRval(i.index, syms.intType, new TreeBuilder() {
-                                public JCTree build(final JCTree index) {
-                                    JCTree newLval = make.Indexed((JCExpression)indexed,
-                                                                (JCExpression)index);
+                                public JCExpression build(final JCExpression index) {
+                                    JCExpression newLval = make.Indexed(indexed, index);
                                     newLval.setType(i.type);
                                     return builder.build(newLval);
                                 }
@@ -2271,9 +2269,9 @@
     }
 
     // evaluate and discard the first expression, then evaluate the second.
-    JCTree makeComma(final JCTree expr1, final JCTree expr2) {
+    JCExpression makeComma(final JCExpression expr1, final JCExpression expr2) {
         return abstractRval(expr1, new TreeBuilder() {
-                public JCTree build(final JCTree discarded) {
+                public JCExpression build(final JCExpression discarded) {
                     return expr2;
                 }
             });
@@ -2306,7 +2304,7 @@
 
     /** Visitor method: Translate a single node, boxing or unboxing if needed.
      */
-    public <T extends JCTree> T translate(T tree, Type type) {
+    public <T extends JCExpression> T translate(T tree, Type type) {
         return (tree == null) ? null : boxIfNeeded(translate(tree), type);
     }
 
@@ -2332,7 +2330,7 @@
 
     /** Visitor method: Translate list of trees.
      */
-    public <T extends JCTree> List<T> translate(List<T> trees, Type type) {
+    public <T extends JCExpression> List<T> translate(List<T> trees, Type type) {
         if (trees == null) return null;
         for (List<T> l = trees; l.nonEmpty(); l = l.tail)
             l.head = translate(l.head, type);
@@ -2907,10 +2905,10 @@
         }
     }
 //where
-    private JCTree convert(JCTree tree, Type pt) {
+    private JCExpression convert(JCExpression tree, Type pt) {
         if (tree.type == pt || tree.type.hasTag(BOT))
             return tree;
-        JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree);
+        JCExpression result = make_at(tree.pos()).TypeCast(make.Type(pt), tree);
         result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt)
                                                        : pt;
         return result;
@@ -3075,7 +3073,7 @@
 
     /** Expand a boxing or unboxing conversion if needed. */
     @SuppressWarnings("unchecked") // XXX unchecked
-    <T extends JCTree> T boxIfNeeded(T tree, Type type) {
+    <T extends JCExpression> T boxIfNeeded(T tree, Type type) {
         boolean havePrimitive = tree.type.isPrimitive();
         if (havePrimitive == type.isPrimitive())
             return tree;
@@ -3084,12 +3082,12 @@
             if (!unboxedTarget.hasTag(NONE)) {
                 if (!types.isSubtype(tree.type, unboxedTarget)) //e.g. Character c = 89;
                     tree.type = unboxedTarget.constType(tree.type.constValue());
-                return (T)boxPrimitive((JCExpression)tree, types.erasure(type));
+                return (T)boxPrimitive(tree, types.erasure(type));
             } else {
-                tree = (T)boxPrimitive((JCExpression)tree);
+                tree = (T)boxPrimitive(tree);
             }
         } else {
-            tree = (T)unbox((JCExpression)tree, type);
+            tree = (T)unbox(tree, type);
         }
         return tree;
     }
@@ -3172,7 +3170,7 @@
             // or if x == (typeof x)z then z = (unbox typeof x)((typeof x)z op y)
             // (but without recomputing x)
             JCTree newTree = abstractLval(tree.lhs, new TreeBuilder() {
-                    public JCTree build(final JCTree lhs) {
+                    public JCExpression build(final JCExpression lhs) {
                         JCTree.Tag newTag = tree.getTag().noAssignOp();
                         // Erasure (TransTypes) can change the type of
                         // tree.lhs.  However, we can still get the
@@ -3182,7 +3180,7 @@
                                                                       newTag,
                                                                       tree.type,
                                                                       tree.rhs.type);
-                        JCExpression expr = (JCExpression)lhs;
+                        JCExpression expr = lhs;
                         if (expr.type != tree.type)
                             expr = make.TypeCast(tree.type, expr);
                         JCBinary opResult = make.Binary(newTag, expr, tree.rhs);
@@ -3191,7 +3189,7 @@
                         JCExpression newRhs = boxingReq ?
                             make.TypeCast(types.unboxedType(tree.type), opResult) :
                             opResult;
-                        return make.Assign((JCExpression)lhs, newRhs).setType(tree.type);
+                        return make.Assign(lhs, newRhs).setType(tree.type);
                     }
                 });
             result = translate(newTree);
@@ -3218,22 +3216,22 @@
     }
 
     /** Lower a tree of the form e++ or e-- where e is an object type */
-    JCTree lowerBoxedPostop(final JCUnary tree) {
+    JCExpression lowerBoxedPostop(final JCUnary tree) {
         // translate to tmp1=lval(e); tmp2=tmp1; tmp1 OP 1; tmp2
         // or
         // translate to tmp1=lval(e); tmp2=tmp1; (typeof tree)tmp1 OP 1; tmp2
         // where OP is += or -=
         final boolean cast = TreeInfo.skipParens(tree.arg).hasTag(TYPECAST);
         return abstractLval(tree.arg, new TreeBuilder() {
-                public JCTree build(final JCTree tmp1) {
+                public JCExpression build(final JCExpression tmp1) {
                     return abstractRval(tmp1, tree.arg.type, new TreeBuilder() {
-                            public JCTree build(final JCTree tmp2) {
+                            public JCExpression build(final JCExpression tmp2) {
                                 JCTree.Tag opcode = (tree.hasTag(POSTINC))
                                     ? PLUS_ASG : MINUS_ASG;
                                 JCTree lhs = cast
-                                    ? make.TypeCast(tree.arg.type, (JCExpression)tmp1)
+                                    ? make.TypeCast(tree.arg.type, tmp1)
                                     : tmp1;
-                                JCTree update = makeAssignop(opcode,
+                                JCExpression update = makeAssignop(opcode,
                                                              lhs,
                                                              make.Literal(1));
                                 return makeComma(update, tmp2);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Nov 12 14:13:17 2015 -0800
@@ -32,6 +32,7 @@
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
@@ -834,10 +835,6 @@
     public void visitSelect(JCFieldAccess tree) {
         Type t = types.skipTypeVars(tree.selected.type, false);
         if (t.isCompound()) {
-            if ((tree.sym.flags() & IPROXY) != 0) {
-                tree.sym = ((MethodSymbol)tree.sym).
-                    implemented((TypeSymbol)tree.sym.owner, types);
-            }
             tree.selected = coerce(
                 translate(tree.selected, erasure(tree.selected.type)),
                 erasure(tree.sym.owner.type));
@@ -859,7 +856,14 @@
     }
 
     public void visitReference(JCMemberReference tree) {
-        tree.expr = translate(tree.expr, erasure(tree.expr.type));
+        Type t = types.skipTypeVars(tree.expr.type, false);
+        Type receiverTarget = t.isCompound() ? erasure(tree.sym.owner.type) : erasure(t);
+        if (tree.kind == ReferenceKind.UNBOUND) {
+            tree.expr = make.Type(receiverTarget);
+        } else {
+            tree.expr = translate(tree.expr, receiverTarget);
+        }
+
         tree.type = erasure(tree.type);
         if (tree.varargsElement != null)
             tree.varargsElement = erasure(tree.varargsElement);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Nov 12 14:13:17 2015 -0800
@@ -1112,7 +1112,8 @@
                 acount += writeMethodParametersAttr(m);
         }
         acount += writeMemberAttrs(m);
-        acount += writeParameterAttrs(m);
+        if (!m.isLambdaMethod())
+            acount += writeParameterAttrs(m);
         endAttrs(acountIdx, acount);
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Nov 12 14:13:17 2015 -0800
@@ -2284,6 +2284,10 @@
     {0} in {1} cannot override {2} in {3}
 
 # 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.cant.hide=\
+    {0} in {1} cannot hide {2} in {3}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
 compiler.misc.cant.implement=\
     {0} in {1} cannot implement {2} in {3}
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Nov 12 14:13:17 2015 -0800
@@ -2623,8 +2623,8 @@
     /** (let int x = 3; in x+2) */
     public static class LetExpr extends JCExpression {
         public List<JCVariableDecl> defs;
-        public JCTree expr;
-        protected LetExpr(List<JCVariableDecl> defs, JCTree expr) {
+        public JCExpression expr;
+        protected LetExpr(List<JCVariableDecl> defs, JCExpression expr) {
             this.defs = defs;
             this.expr = expr;
         }
@@ -2731,7 +2731,7 @@
         JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
         JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
         JCErroneous Erroneous(List<? extends JCTree> errs);
-        LetExpr LetExpr(List<JCVariableDecl> defs, JCTree expr);
+        LetExpr LetExpr(List<JCVariableDecl> defs, JCExpression expr);
     }
 
     /** A generic visitor class for trees.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Nov 12 14:13:17 2015 -0800
@@ -512,7 +512,7 @@
             case LETEXPR: {
                 LetExpr t = (LetExpr) node;
                 List<JCVariableDecl> defs = copy(t.defs, p);
-                JCTree expr = copy(t.expr, p);
+                JCExpression expr = copy(t.expr, p);
                 return M.at(t.pos).LetExpr(defs, expr);
             }
             default:
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Nov 12 14:13:17 2015 -0800
@@ -552,7 +552,7 @@
         return tree;
     }
 
-    public LetExpr LetExpr(List<JCVariableDecl> defs, JCTree expr) {
+    public LetExpr LetExpr(List<JCVariableDecl> defs, JCExpression expr) {
         LetExpr tree = new LetExpr(defs, expr);
         tree.pos = pos;
         return tree;
@@ -573,7 +573,7 @@
                         defs);
     }
 
-    public LetExpr LetExpr(JCVariableDecl def, JCTree expr) {
+    public LetExpr LetExpr(JCVariableDecl def, JCExpression expr) {
         LetExpr tree = new LetExpr(List.of(def), expr);
         tree.pos = pos;
         return tree;
@@ -628,6 +628,12 @@
         return Ident(new VarSymbol(FINAL, names._this, t, t.tsym));
     }
 
+    /** Create a tree representing qualified `this' given its type
+     */
+    public JCExpression QualThis(Type t) {
+        return Select(Type(t), new VarSymbol(FINAL, names._this, t, t.tsym));
+    }
+
     /** Create a tree representing a class literal.
      */
     public JCExpression ClassLiteral(ClassSymbol clazz) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java	Thu Nov 12 14:13:17 2015 -0800
@@ -177,6 +177,7 @@
     public final Name lambda;
     public final Name metafactory;
     public final Name altMetafactory;
+    public final Name dollarThis;
 
     public final Name.Table table;
 
@@ -235,6 +236,7 @@
         value = fromString("value");
         valueOf = fromString("valueOf");
         values = fromString("values");
+        dollarThis = fromString("$this");
 
         // class names
         java_io_Serializable = fromString("java.io.Serializable");
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Thu Nov 12 14:13:17 2015 -0800
@@ -675,6 +675,9 @@
         registerCommand(new Command("/classes", "/c", null, "list the declared classes",
                                     arg -> cmdClasses(),
                                     EMPTY_COMPLETION_PROVIDER));
+        registerCommand(new Command("/imports", "/i", null, "list the imported items",
+                                    arg -> cmdImports(),
+                                    EMPTY_COMPLETION_PROVIDER));
         registerCommand(new Command("/exit", "/x", null, "exit the REPL",
                                     arg -> cmdExit(),
                                     EMPTY_COMPLETION_PROVIDER));
@@ -1256,6 +1259,12 @@
         }
     }
 
+    private void cmdImports() {
+        state.imports().forEach(ik -> {
+            hard("  import %s%s", ik.isStatic() ? "static " : "", ik.fullname());
+        });
+    }
+
     private void cmdUseHistoryEntry(int index) {
         List<Snippet> keys = state.snippets();
         if (index < 0)
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java	Thu Nov 12 14:13:17 2015 -0800
@@ -68,6 +68,29 @@
         return key().name();
     }
 
+    /**
+     *
+     * The qualified name of the import. For any imports
+     * ({@link jdk.jshell.Snippet.SubKind#TYPE_IMPORT_ON_DEMAND_SUBKIND},
+     * ({@link jdk.jshell.Snippet.SubKind#STATIC_IMPORT_ON_DEMAND_SUBKIND}),
+     * ({@link jdk.jshell.Snippet.SubKind#SINGLE_TYPE_IMPORT_SUBKIND} or
+     * ({@link jdk.jshell.Snippet.SubKind#SINGLE_STATIC_IMPORT_SUBKIND})
+     * that is the full specifier including any
+     * qualifiers and the asterisks.
+     * @return the fullname of the import
+     */
+    public String fullname() {
+        return fullname;
+    }
+
+    /**
+     * When this snippet represent static import, this method returns true.
+     * @return true when this snippet represent static import, otherwise false
+     */
+    public boolean isStatic() {
+        return isStatic;
+    }
+
     /**** internal access ****/
 
     @Override
@@ -75,10 +98,6 @@
         return (ImportKey) super.key();
     }
 
-    boolean isStatic() {
-        return isStatic;
-    }
-
     @Override
     String importLine(JShell state) {
         return source();
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java	Thu Nov 12 14:13:17 2015 -0800
@@ -93,7 +93,7 @@
 
 
     private ExecutionControl executionControl = null;
-    private SourceCodeAnalysis sourceCodeAnalysis = null;
+    private SourceCodeAnalysisImpl sourceCodeAnalysis = null;
 
 
     JShell(Builder b) {
@@ -378,6 +378,9 @@
     public void addToClasspath(String path) {
         taskFactory.addToClasspath(path);  // Compiler
         executionControl().commandAddToClasspath(path);       // Runtime
+        if (sourceCodeAnalysis != null) {
+            sourceCodeAnalysis.classpathChanged();
+        }
     }
 
     /**
@@ -469,6 +472,22 @@
     }
 
     /**
+     * Returns the active import snippets.
+     * This convenience method is equivalent to <code>snippets()</code> filtered for
+     * {@link jdk.jshell.Snippet.Status#isActive status(snippet).isActive}
+     * <code>&amp;&amp; snippet.kind() == Kind.IMPORT</code>
+     * and cast to ImportSnippet.
+     * @return the active declared import declarations.
+     * @throws IllegalStateException if this JShell instance is closed.
+     */
+    public List<ImportSnippet> imports() throws IllegalStateException {
+        return snippets().stream()
+                .filter(sn -> status(sn).isActive && sn.kind() == Snippet.Kind.IMPORT)
+                .map(sn -> (ImportSnippet) sn)
+                .collect(collectingAndThen(toList(), Collections::unmodifiableList));
+    }
+
+    /**
      * Return the status of the snippet.
      * This is updated either because of an explicit <code>eval()</code> call or
      * an automatic update triggered by a dependency.
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java	Thu Nov 12 14:13:17 2015 -0800
@@ -42,6 +42,7 @@
 import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.TreeMap;
+
 import javax.tools.JavaFileObject.Kind;
 import static javax.tools.StandardLocation.CLASS_PATH;
 import javax.tools.FileObject;
@@ -49,6 +50,7 @@
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
 import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
 
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
@@ -77,6 +79,10 @@
     private Method inferModuleNameMethod = null;
     private Method listModuleLocationsMethod = null;
 
+    Iterable<? extends Path> getLocationAsPaths(Location loc) {
+        return this.stdFileManager.getLocationAsPaths(loc);
+    }
+
     static abstract class MemoryJavaFileObject extends SimpleJavaFileObject {
 
         public MemoryJavaFileObject(String name, JavaFileObject.Kind kind) {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Thu Nov 12 14:13:17 2015 -0800
@@ -75,8 +75,14 @@
 import static jdk.internal.jshell.debug.InternalDebugControl.DBG_COMPA;
 
 import java.io.IOException;
+import java.net.URI;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Comparator;
-import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.NoSuchElementException;
 import java.util.Set;
@@ -92,6 +98,7 @@
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
+import javax.lang.model.SourceVersion;
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.QualifiedNameable;
@@ -100,10 +107,8 @@
 import javax.lang.model.type.ExecutableType;
 import javax.lang.model.type.TypeKind;
 import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
 import javax.tools.JavaFileManager.Location;
-import javax.tools.JavaFileObject;
 import javax.tools.StandardLocation;
 
 import static jdk.jshell.Util.REPL_DOESNOTMATTER_CLASS_NAME;
@@ -584,42 +589,114 @@
                 .collect(toList());
     }
 
+    private Set<String> emptyContextPackages = null;
+
+    void classpathChanged() {
+        emptyContextPackages = null;
+    }
+
     private Set<PackageElement> listPackages(AnalyzeTask at, String enclosingPackage) {
-        Set<PackageElement> packs = new HashSet<>();
-        listPackages(at, StandardLocation.PLATFORM_CLASS_PATH, enclosingPackage, packs);
-        listPackages(at, StandardLocation.CLASS_PATH, enclosingPackage, packs);
-        listPackages(at, StandardLocation.SOURCE_PATH, enclosingPackage, packs);
-        return packs;
+        Set<String> packs;
+
+        if (enclosingPackage.isEmpty() && emptyContextPackages != null) {
+            packs = emptyContextPackages;
+        } else {
+            packs = new HashSet<>();
+
+            listPackages(StandardLocation.PLATFORM_CLASS_PATH, enclosingPackage, packs);
+            listPackages(StandardLocation.CLASS_PATH, enclosingPackage, packs);
+            listPackages(StandardLocation.SOURCE_PATH, enclosingPackage, packs);
+
+            if (enclosingPackage.isEmpty()) {
+                emptyContextPackages = packs;
+            }
+        }
+
+        return packs.stream()
+                    .map(pkg -> createPackageElement(at, pkg))
+                    .collect(Collectors.toSet());
+    }
+
+    private PackageElement createPackageElement(AnalyzeTask at, String packageName) {
+        Names names = Names.instance(at.getContext());
+        Symtab syms = Symtab.instance(at.getContext());
+        PackageElement existing = syms.enterPackage(names.fromString(packageName));
+
+        return existing;
+    }
+
+    private void listPackages(Location loc, String enclosing, Set<String> packs) {
+        Iterable<? extends Path> paths = proc.taskFactory.fileManager().getLocationAsPaths(loc);
+
+        if (paths == null)
+            return ;
+
+        for (Path p : paths) {
+            listPackages(p, enclosing, packs);
+        }
     }
 
-    private void listPackages(AnalyzeTask at, Location loc, String currentPackage, Set<PackageElement> packs) {
+    private void listPackages(Path path, String enclosing, Set<String> packages) {
         try {
-            MemoryFileManager fm = proc.taskFactory.fileManager();
-            for (JavaFileObject file : fm.list(loc, currentPackage, fileKinds, true)) {
-                String binaryName = fm.inferBinaryName(loc, file);
-                if (!currentPackage.isEmpty() && !binaryName.startsWith(currentPackage + "."))
-                    continue;
-                int nextDot = binaryName.indexOf('.', !currentPackage.isEmpty() ? currentPackage.length() + 1 : 0);
-                if (nextDot == (-1))
-                    continue;
-                Elements elements = at.getElements();
-                PackageElement pack =
-                        elements.getPackageElement(binaryName.substring(0, nextDot));
-                if (pack == null) {
-                    //if no types in the package have ever been seen, the package will be unknown
-                    //try to load a type, and then try to recognize the package again:
-                    elements.getTypeElement(binaryName);
-                    pack = elements.getPackageElement(binaryName.substring(0, nextDot));
+            if (path.equals(Paths.get("JRT_MARKER_FILE"))) {
+                FileSystem jrtfs = FileSystems.getFileSystem(URI.create("jrt:/"));
+                Path modules = jrtfs.getPath("modules");
+                try (DirectoryStream<Path> stream = Files.newDirectoryStream(modules)) {
+                    for (Path c : stream) {
+                        listDirectory(c, enclosing, packages);
+                    }
                 }
-                if (pack != null)
-                    packs.add(pack);
+            } else if (!Files.isDirectory(path)) {
+                if (Files.exists(path)) {
+                    ClassLoader cl = SourceCodeAnalysisImpl.class.getClassLoader();
+
+                    try (FileSystem zip = FileSystems.newFileSystem(path, cl)) {
+                        listDirectory(zip.getRootDirectories().iterator().next(), enclosing, packages);
+                    }
+                }
+            } else {
+                listDirectory(path, enclosing, packages);
             }
         } catch (IOException ex) {
-            //TODO: should log?
+            proc.debug(ex, "SourceCodeAnalysisImpl.listPackages(" + path.toString() + ", " + enclosing + ", " + packages + ")");
         }
     }
-    //where:
-        private final Set<JavaFileObject.Kind> fileKinds = EnumSet.of(JavaFileObject.Kind.CLASS);
+
+    private void listDirectory(Path path, String enclosing, Set<String> packages) throws IOException {
+        String separator = path.getFileSystem().getSeparator();
+        Path resolved = path.resolve(enclosing.replace(".", separator));
+
+        if (Files.isDirectory(resolved)) {
+            try (DirectoryStream<Path> ds = Files.newDirectoryStream(resolved)) {
+                for (Path entry : ds) {
+                    String name = pathName(entry);
+
+                    if (SourceVersion.isIdentifier(name) &&
+                        Files.isDirectory(entry) &&
+                        validPackageCandidate(entry)) {
+                        packages.add(enclosing + (enclosing.isEmpty() ? "" : ".") + name);
+                    }
+                }
+            }
+        }
+    }
+
+    private boolean validPackageCandidate(Path p) throws IOException {
+        try (Stream<Path> dir = Files.list(p)) {
+            return dir.anyMatch(e -> Files.isDirectory(e) && SourceVersion.isIdentifier(pathName(e)) ||
+                                e.getFileName().toString().endsWith(".class"));
+        }
+    }
+
+    private String pathName(Path p) {
+        String separator = p.getFileSystem().getSeparator();
+        String name = p.getFileName().toString();
+
+        if (name.endsWith(separator)) //jars have '/' appended
+            name = name.substring(0, name.length() - separator.length());
+
+        return name;
+    }
 
     private Element createArrayLengthSymbol(AnalyzeTask at, TypeMirror site) {
         Name length = Names.instance(at.getContext()).length;
--- a/langtools/test/jdk/jshell/CompletionSuggestionTest.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/test/jdk/jshell/CompletionSuggestionTest.java	Thu Nov 12 14:13:17 2015 -0800
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8141092
  * @summary Test Completion
  * @library /tools/lib
  * @build KullaTesting TestingInputStream ToolBox Compiler
@@ -45,6 +46,9 @@
 @Test
 public class CompletionSuggestionTest extends KullaTesting {
 
+    private final Compiler compiler = new Compiler();
+    private final Path outDir = Paths.get("completion_suggestion_test");
+
     public void testMemberExpr() {
         assertEval("class Test { static void test() { } }");
         assertCompletion("Test.t|", "test()");
@@ -232,6 +236,23 @@
 
         assertCompletion("Object.notElement.|");
         assertCompletion("Object o = com.su|", "sun");
+
+        Path p1 = outDir.resolve("dir1");
+        compiler.compile(p1,
+                "package p1.p2;\n" +
+                "public class Test {\n" +
+                "}",
+                "package p1.p3;\n" +
+                "public class Test {\n" +
+                "}");
+        String jarName = "test.jar";
+        compiler.jar(p1, jarName, "p1/p2/Test.class", "p1/p3/Test.class");
+        addToClasspath(compiler.getPath(p1.resolve(jarName)));
+
+        assertCompletionIncludesExcludes("|", new HashSet<>(Collections.singletonList("p1")), Collections.emptySet());
+        assertCompletion("p1.|", "p2", "p3");
+        assertCompletion("p1.p2.|", "Test");
+        assertCompletion("p1.p3.|", "Test");
     }
 
     public void testCheckAccessibility() {
--- a/langtools/test/jdk/jshell/ReplToolTesting.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/test/jdk/jshell/ReplToolTesting.java	Thu Nov 12 14:13:17 2015 -0800
@@ -27,11 +27,10 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.function.Consumer;
+import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -62,6 +61,7 @@
     private Map<String, VariableInfo> variables;
     private Map<String, MethodInfo> methods;
     private Map<String, ClassInfo> classes;
+    private Map<String, ImportInfo> imports;
     private boolean isDefaultStartUp = true;
 
     public JShellTool repl = null;
@@ -127,6 +127,10 @@
         return assertMembers("Classes", classes);
     }
 
+    public Consumer<String> assertImports() {
+        return assertMembers("Imports", imports);
+    }
+
     public String getCommandOutput() {
         String s = cmdout.toString();
         cmdout.reset();
@@ -184,9 +188,21 @@
         variables = new HashMap<>();
         methods = new HashMap<>();
         classes = new HashMap<>();
+        imports = new HashMap<>();
         if (isDefaultStartUp) {
             methods.put("printf (String,Object...)void",
                     new MethodInfo("", "(String,Object...)void", "printf"));
+            imports.putAll(
+                Stream.of(
+                    "java.util.*",
+                    "java.io.*",
+                    "java.math.*",
+                    "java.net.*",
+                    "java.util.concurrent.*",
+                    "java.util.prefs.*",
+                    "java.util.regex.*")
+                    .map(s -> new ImportInfo("", "", s))
+                    .collect(Collectors.toMap(Object::toString, Function.identity())));
         }
     }
 
@@ -300,6 +316,19 @@
         addKey(after, clazz);
     }
 
+    public void loadImport(boolean after, String src, String type, String name) {
+        ImportInfo i = new ImportInfo(src, type, name);
+        addKey(after, i, imports);
+        addKey(after, i);
+    }
+
+    public void assertImport(boolean after, String src, String type, String name) {
+        ImportInfo i = new ImportInfo(src, type, name);
+        assertCommandCheckOutput(after, src, i.checkOutput());
+        addKey(after, i, imports);
+        addKey(after, i);
+    }
+
     private <T extends MemberInfo> void addKey(boolean after, T memberInfo, Map<String, T> map) {
         if (after) {
             map.entrySet().removeIf(e -> e.getValue().equals(memberInfo));
@@ -347,6 +376,10 @@
         dropKey(after, cmd, name, classes);
     }
 
+    public void dropImport(boolean after, String cmd, String name) {
+        dropKey(after, cmd, name, imports);
+    }
+
     public void assertCommand(boolean after, String cmd, String out) {
         assertCommand(after, cmd, out, "", null, "", "");
     }
@@ -580,6 +613,31 @@
         }
     }
 
+    public static class ImportInfo extends MemberInfo {
+        public ImportInfo(String source, String type, String fullname) {
+            super(source, type, fullname);
+        }
+
+        @Override
+        public Consumer<String> checkOutput() {
+            return s -> assertTrue("".equals(s), "Expected: '', actual: " + s);
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (o instanceof ImportInfo) {
+                ImportInfo i = (ImportInfo) o;
+                return name.equals(i.name) && type.equals(i.type);
+            }
+            return false;
+        }
+
+        @Override
+        public String toString() {
+            return String.format("import %s%s", type.equals("static") ? "static " : "", name);
+        }
+    }
+
     class WaitingTestingInputStream extends TestingInputStream {
 
         @Override
--- a/langtools/test/jdk/jshell/ToolBasicTest.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java	Thu Nov 12 14:13:17 2015 -0800
@@ -24,7 +24,6 @@
 /*
  * @test
  * @summary Tests for Basic tests for REPL tool
- * @ignore 8139873
  * @library /tools/lib
  * @build KullaTesting TestingInputStream ToolBox Compiler
  * @run testng ToolBasicTest
@@ -139,7 +138,13 @@
                     (a) -> assertCommand(a, "class A {}\u0003", ""),
                     (a) -> assertCommandCheckOutput(a, "/c", assertClasses()),
                     (a) -> assertClass(a, "interface A {}", "interface", "A"),
-                    (a) -> assertCommandCheckOutput(a, "/c", assertClasses())
+                    (a) -> assertCommandCheckOutput(a, "/c", assertClasses()),
+                    (a) -> assertCommand(a, "import java.util.stream." + s, ""),
+                    interrupt,
+                    (a) -> assertCommand(a, "import java.util.stream.\u0003", ""),
+                    (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+                    (a) -> assertImport(a, "import java.util.stream.Stream", "", "java.util.stream.Stream"),
+                    (a) -> assertCommandCheckOutput(a, "/i", assertImports())
             );
         }
     }
@@ -364,6 +369,35 @@
         );
     }
 
+    public void defineImports() {
+        test(
+                (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+                (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+                (a) -> assertImport(a, "import java.util.stream.Stream;", "", "java.util.stream.Stream"),
+                (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+                (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+                (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+                (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+                (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+                (a) -> assertImport(a, "import static java.lang.Math.PI;", "static", "java.lang.Math.PI"),
+                (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+                (a) -> assertCommandCheckOutput(a, "/imports", assertImports()),
+                (a) -> assertImport(a, "import static java.lang.Math.*;", "static", "java.lang.Math.*"),
+                (a) -> assertCommandCheckOutput(a, "/l", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/list", assertList()),
+                (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
+                (a) -> assertCommandCheckOutput(a, "/imports", assertImports())
+        );
+    }
+
     public void testClasspathDirectory() {
         Compiler compiler = new Compiler();
         Path outDir = Paths.get("testClasspathDirectory");
@@ -443,10 +477,13 @@
                 (a) -> assertCommandCheckOutput(a, "/m", assertMethods()),
                 (a) -> assertClass(a, "class A { }", "class", "A"),
                 (a) -> assertCommandCheckOutput(a, "/c", assertClasses()),
+                (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+                (a) -> assertCommandCheckOutput(a, "/i", assertImports()),
                 (a) -> assertReset(a, "/reset"),
                 (a) -> assertCommandCheckOutput(a, "/v", assertVariables()),
                 (a) -> assertCommandCheckOutput(a, "/m", assertMethods()),
-                (a) -> assertCommandCheckOutput(a, "/c", assertClasses())
+                (a) -> assertCommandCheckOutput(a, "/c", assertClasses()),
+                (a) -> assertCommandCheckOutput(a, "/i", assertImports())
         );
     }
 
@@ -455,22 +492,26 @@
         Path path = compiler.getPath("testOpen.repl");
         compiler.writeToFile(path,
                 "int a = 10;\ndouble x = 20;\ndouble a = 10;\n" +
-                        "class A { public String toString() { return \"A\"; } }");
+                        "class A { public String toString() { return \"A\"; } }\nimport java.util.stream.*;");
         for (String s : new String[]{"/o", "/open"}) {
             test(
                     (a) -> assertCommand(a, s + " " + path.toString(), ""),
                     (a) -> assertCommand(a, "a", "|  Variable a of type double has value 10.0\n"),
                     (a) -> evaluateExpression(a, "A", "new A();", "\"A\""),
+                    (a) -> evaluateExpression(a, "long", "Stream.of(\"A\").count();", "1"),
                     (a) -> {
                         loadVariable(a, "double", "x", "20.0", "20.0");
                         loadVariable(a, "double", "a", "10.0", "10.0");
-                        loadVariable(a, "A", "$6", "new A();", "A");
+                        loadVariable(a, "A", "$7", "new A();", "A");
+                        loadVariable(a, "long", "$8", "Stream.of(\"A\").count();", "1");
                         loadClass(a, "class A { public String toString() { return \"A\"; } }",
                                 "class", "A");
+                        loadImport(a, "import java.util.stream.*;", "", "java.util.stream.*");
                         assertCommandCheckOutput(a, "/c", assertClasses());
                     },
                     (a) -> assertCommandCheckOutput(a, "/m", assertMethods()),
-                    (a) -> assertCommandCheckOutput(a, "/v", assertVariables())
+                    (a) -> assertCommandCheckOutput(a, "/v", assertVariables()),
+                    (a) -> assertCommandCheckOutput(a, "/i", assertImports())
             );
             Path unknown = compiler.getPath("UNKNOWN.repl");
             test(
@@ -536,6 +577,7 @@
                     (a) -> assertVariable(a, "int", "a"),
                     (a) -> assertVariable(a, "double", "b", "10", "10.0"),
                     (a) -> assertMethod(a, "void f() {}", "()V", "f"),
+                    (a) -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
                     (a) -> assertCommand(a, "/s " + startUpFile.toString(), null),
                     (a) -> assertCommand(a, "/setstart " + startUpFile.toString(), null)
             );
@@ -549,10 +591,12 @@
                         loadVariable(a, "int", "a");
                         loadVariable(a, "double", "b", "10.0", "10.0");
                         loadMethod(a, "void f() {}", "()void", "f");
+                        loadImport(a, "import java.util.stream.*;", "", "java.util.stream.*");
                         assertCommandCheckOutput(a, "/c", assertClasses());
                     },
                     (a) -> assertCommandCheckOutput(a, "/v", assertVariables()),
-                    (a) -> assertCommandCheckOutput(a, "/m", assertMethods())
+                    (a) -> assertCommandCheckOutput(a, "/m", assertMethods()),
+                    (a) -> assertCommandCheckOutput(a, "/i", assertImports())
             );
         } finally {
             removeStartup();
@@ -768,9 +812,12 @@
                     a -> dropMethod(a, drop + " 2", "b ()I"),
                     a -> assertClass(a, "class A {}", "class", "A"),
                     a -> dropClass(a, drop + " 3", "class A"),
+                    a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+                    a -> dropImport(a, drop + " 4", "import java.util.stream.*"),
                     a -> assertCommandCheckOutput(a, "/v", assertVariables()),
                     a -> assertCommandCheckOutput(a, "/m", assertMethods()),
-                    a -> assertCommandCheckOutput(a, "/c", assertClasses())
+                    a -> assertCommandCheckOutput(a, "/c", assertClasses()),
+                    a -> assertCommandCheckOutput(a, "/i", assertImports())
             );
             test(false, new String[]{"-nostartup"},
                     a -> assertVariable(a, "int", "a"),
@@ -781,7 +828,8 @@
                     a -> dropClass(a, drop + " A", "class A"),
                     a -> assertCommandCheckOutput(a, "/v", assertVariables()),
                     a -> assertCommandCheckOutput(a, "/m", assertMethods()),
-                    a -> assertCommandCheckOutput(a, "/c", assertClasses())
+                    a -> assertCommandCheckOutput(a, "/c", assertClasses()),
+                    a -> assertCommandCheckOutput(a, "/i", assertImports())
             );
         }
     }
@@ -814,7 +862,8 @@
                     a -> assertCommandCheckOutput(a, drop + " a", check),
                     a -> assertCommandCheckOutput(a, "/v", assertVariables()),
                     a -> assertCommandCheckOutput(a, "/m", assertMethods()),
-                    a -> assertCommandCheckOutput(a, "/c", assertClasses())
+                    a -> assertCommandCheckOutput(a, "/c", assertClasses()),
+                    a -> assertCommandCheckOutput(a, "/i", assertImports())
             );
             test(
                     a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
--- a/langtools/test/tools/javac/OverrideChecks/T4720359a.out	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/test/tools/javac/OverrideChecks/T4720359a.out	Thu Nov 12 14:13:17 2015 -0800
@@ -1,2 +1,2 @@
-T4720359a.java:16:23: compiler.err.override.incompatible.ret: (compiler.misc.cant.override: m(), p1.T4720359c, m(), p1.T4720359a), int, void
+T4720359a.java:16:23: compiler.err.override.incompatible.ret: (compiler.misc.cant.hide: m(), p1.T4720359c, m(), p1.T4720359a), int, void
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/OverrideChecks/T8139255.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,14 @@
+/*
+ * @test    /nodynamiccopyright/
+ * @bug     8139255
+ * @summary javac emits diagnostic message as overriding instead of hiding for class methods.
+ * @compile/fail/ref=T8139255.out -XDrawDiagnostics  T8139255.java
+ */
+
+public class T8139255 {
+   static void func() { }
+}
+
+class T8139255_1  extends T8139255 {
+   static int func() { return 0; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/OverrideChecks/T8139255.out	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,2 @@
+T8139255.java:13:15: compiler.err.override.incompatible.ret: (compiler.misc.cant.hide: func(), T8139255_1, func(), T8139255), int, void
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/InstanceInitializer.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015, 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.lang.annotation.*;
+import java.util.ArrayList;
+
+import com.sun.tools.classfile.*;
+
+/*
+ * @test
+ * @bug 8136419
+ * @summary test that type annotations on entities in initializers are emitted to classfile
+ * @modules jdk.jdeps/com.sun.tools.classfile
+ */
+
+public class InstanceInitializer extends ClassfileTestHelper {
+    public static void main(String[] args) throws Exception {
+        new InstanceInitializer().run();
+    }
+
+    public void run() throws Exception {
+        expected_tinvisibles = 4;
+        expected_tvisibles = 0;
+
+        ClassFile cf = getClassFile("InstanceInitializer$Test.class");
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m, true);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    /*********************** Test class *************************/
+    static class Test {
+        @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+        @interface T {}
+
+        {
+            @T String s = null;
+            Runnable r = () -> new ArrayList<@T String>();
+        }
+        @T String s = null;
+        Runnable r = () -> new ArrayList<@T String>();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/StaticInitializer.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015, 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.lang.annotation.*;
+import java.util.ArrayList;
+
+import com.sun.tools.classfile.*;
+
+/*
+ * @test
+ * @bug 8136419
+ * @summary test that type annotations on entities in static initializers are emitted to classfile
+ * @modules jdk.jdeps/com.sun.tools.classfile
+ */
+
+public class StaticInitializer extends ClassfileTestHelper {
+    public static void main(String[] args) throws Exception {
+        new StaticInitializer().run();
+    }
+
+    public void run() throws Exception {
+        expected_tinvisibles = 4;
+        expected_tvisibles = 0;
+
+        ClassFile cf = getClassFile("StaticInitializer$Test.class");
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m, true);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    /*********************** Test class *************************/
+    static class Test {
+        @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+        @interface T {}
+
+        static {
+            @T String s = null;
+            Runnable r = () -> new ArrayList<@T String>();
+        }
+        @T static String s = null;
+        static Runnable r = () -> new ArrayList<@T String>();
+    }
+}
--- a/langtools/test/tools/javac/classfiles/attributes/annotations/RuntimeParameterAnnotationsForLambdaTest.java	Thu Nov 12 10:39:10 2015 -0800
+++ b/langtools/test/tools/javac/classfiles/attributes/annotations/RuntimeParameterAnnotationsForLambdaTest.java	Thu Nov 12 14:13:17 2015 -0800
@@ -23,10 +23,9 @@
 
 /*
  * @test
- * @bug 8044411 8079060
+ * @bug 8044411 8079060 8138612
  * @summary Tests the RuntimeParameterVisibleAnnotations/RuntimeParameterInvisibleAnnotations attribute.
  * @library /tools/lib /tools/javac/lib ../lib
- * @ignore 8079060 javac does not generate RuntimeParameterAnnotation attributes for lambda expressions
  * @build WorkAnnotations TestBase TestResult InMemoryFileManager ToolBox
  * @build TestCase ClassType TestAnnotationInfo
  * @build RuntimeParameterAnnotationsForLambdaTest AnnotationsTestBase RuntimeParameterAnnotationsTestBase
@@ -36,12 +35,11 @@
 import java.util.List;
 import java.util.stream.Collectors;
 
-import com.sun.tools.classfile.ClassFile;
-import com.sun.tools.classfile.Method;
+import com.sun.tools.classfile.*;
 
 /**
  * RuntimeParameterAnnotationsForLambdaTest is a test which checks that RuntimeVisibleParameterAnnotationsAttribute
- * and RuntimeInvisibleParameterAnnotationsAttribute are generated properly for lambda expressions.
+ * and RuntimeInvisibleParameterAnnotationsAttribute are not generated at all for lambda expressions.
  * The test checks both single and repeatable annotations.
  * All possible combinations of retention policies are tested.
  *
@@ -74,8 +72,8 @@
                     TestCase.TestParameterInfo p3 = testMethodInfo.addParameter("String", "c");
                     annotations.annotate(p3);
                     String source = SOURCE_TEMPLATE.replace("%SOURCE%", generateLambdaSource(testMethodInfo));
+                    addTestCase(source);
                     echo("Testing:\n" + source);
-                    addTestCase(source);
                     ClassFile classFile = readClassFile(compile(source).getClasses().get(CLASS_NAME));
                     boolean isFoundLambda = false;
                     for (Method method : classFile.methods) {
@@ -94,6 +92,17 @@
         }
     }
 
+    protected void testAttributes(
+            TestCase.TestMethodInfo testMethod,
+            ClassFile classFile,
+            Method method) throws ConstantPoolException {
+        Attributes attributes = method.attributes;
+        RuntimeParameterAnnotations_attribute attr = (RuntimeParameterAnnotations_attribute) attributes.get(Attribute.RuntimeInvisibleParameterAnnotations);
+        checkNull(attr, String.format("%s should be null", Attribute.RuntimeInvisibleParameterAnnotations));
+        attr = (RuntimeParameterAnnotations_attribute) attributes.get(Attribute.RuntimeVisibleParameterAnnotations);
+        checkNull(attr, String.format("%s should be null", Attribute.RuntimeVisibleParameterAnnotations));
+    }
+
     public String generateLambdaSource(TestCase.TestMethodInfo method) {
         return method.parameters.stream()
                 .map(TestCase.TestParameterInfo::generateSource)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/HideStatic.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015, 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.override.incompatible.ret
+// key: compiler.misc.cant.hide
+
+class Base {
+   static void func() { }
+}
+
+class HideStatic extends Base {
+   static int func() { return 0; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/8141613/T8141613.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8141613
+ * @summary Compiler fails to infer generic type
+ * @compile T8141613.java
+ */
+class T8141613 {
+
+    static class Sub<V, L> implements Sup<V, L> {
+        Sub(Bar<V> barv) { }
+    }
+
+    interface Bar<V> { }
+
+    interface Sup<V, L> { }
+
+    <L> void test() {
+        Sup<?, L> res1 = makeSub(makeBar());
+        Sup<?, L> res2 = new Sub<>(makeBar());
+    }
+
+    <S, U> Sub<S, U> makeSub(Bar<S> bars) { return null; }
+
+    <B> Bar<?> makeBar() {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/SE5AnnotationsOnLambdaParameters.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, 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 8138612
+ * @summary Do not retain declaration annotations on lambda formal parameters
+ * @run main SE5AnnotationsOnLambdaParameters
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Method;
+
+public class SE5AnnotationsOnLambdaParameters {
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Annot {}
+
+    interface Runnable {
+        void run(int x);
+    }
+
+    public void run(Runnable r) {}
+
+    public static void main(@Annot String [] args) throws ClassNotFoundException {
+        new SE5AnnotationsOnLambdaParameters().run((@Annot int x) -> { System.out.println(x + args.length); });
+        Class<?> clazz = Class.forName("SE5AnnotationsOnLambdaParameters");
+        for (Method m : clazz.getDeclaredMethods()) {
+            if (m.getName().startsWith("lambda$")) {
+                for (Annotation[] annots : m.getParameterAnnotations()) {
+                    if (annots.length > 0) {
+                        throw new AssertionError("Unexpected annotations on lambda parameters");
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8129740/AllowEnclosingVarCaptureTest.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, 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 8129740 8133111
+ * @summary Incorrect class file created when passing lambda in inner class constructor
+ * @run main AllowEnclosingVarCaptureTest
+ */
+
+public class AllowEnclosingVarCaptureTest {
+
+    int var = 0;
+
+    void foo() {
+        var *= 2;
+    }
+
+    public static void main(String[] args) {
+        new AllowEnclosingVarCaptureTest().new Inner(9764);
+    }
+
+    public class Inner {
+        public Inner(Runnable r) {
+            r.run();
+            if (var != 66704)
+                throw new AssertionError("Unexpected output: " + var);
+        }
+
+        public Inner(int x) {
+            this(() -> {
+                var = x + 1234;
+                AllowEnclosingVarCaptureTest.this.var += 5678;
+                foo();
+                AllowEnclosingVarCaptureTest.this.foo();
+            });
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8129740/CaptureInCtorChainingTest.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, 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 8129740 8133111
+ * @summary Incorrect class file created when passing lambda in inner class constructor
+ * @run main CaptureInCtorChainingTest
+ */
+
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+public class CaptureInCtorChainingTest {
+
+    CaptureInCtorChainingTest(Function<Function<Function<Consumer<Void>, Void>, Void>, Void> innerClass) {
+        new InnerClass(innerClass);
+    }
+
+    void foo(Void v) { }
+
+    class InnerClass {
+
+        InnerClass(Function<Function<Function<Consumer<Void>, Void>, Void>, Void> factory) {
+            this(factory.apply(o -> o.apply(CaptureInCtorChainingTest.this::foo)));
+        }
+
+        InnerClass(Void unused) { }
+    }
+
+    public static void main(String[] args) {
+        new CaptureInCtorChainingTest(o -> null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8129740/QualifiedThisAccessTest.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2015, 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 8129740 8133111
+ * @summary Incorrect class file created when passing lambda in inner class constructor
+ * @run main QualifiedThisAccessTest
+ */
+
+public class QualifiedThisAccessTest { // Not referenced by lambda, so should not be captured.
+
+    public class Universe { // Not referenced by lambda, so should not be captured.
+
+        public String name;
+        public int galaxiesCount;
+
+        public Universe(String name, int galaxiesCount) {
+            this.name = name;
+            this.galaxiesCount = galaxiesCount;
+        }
+
+        public String toString() {
+            return "Universe" + name + " of " + galaxiesCount + " galaxies";
+        }
+
+        class Galaxy {
+
+            String name;
+            private int starsCount;
+
+            Galaxy(String name, int starsCount) {
+                this.name = name;
+                this.starsCount = starsCount;
+            }
+
+            public String toString() {
+                return "galaxy " + name + " of " + starsCount + " solar systems";
+            }
+
+            int starsCount() {
+                return starsCount;
+            }
+
+            private String name() {
+                return name;
+            }
+
+            class SolarSystem {
+
+                String name;
+                int planetsCount;
+
+                SolarSystem(String name, int planetsCount) {
+                    this.name = name;
+                    this.planetsCount = planetsCount;
+                }
+
+                public String toString() {
+                    return "Solar System of " + name + " with " + planetsCount + " planets";
+                }
+
+                int planetsCount() {
+                    return planetsCount;
+                }
+
+                SolarSystem copy(SolarSystem s) {
+                    return s;
+                }
+
+                class Planet {
+
+                    String name;
+                    int moonsCount;
+
+                    Planet(String name, int moonsCount, Runnable r) {
+                        this.name = name;
+                        this.moonsCount = moonsCount;
+                        r.run();
+                    }
+                    Planet (String name, int moonsCount) {
+                        this(name, moonsCount, ()-> {
+                            StringBuffer buf = new StringBuffer();
+                            buf.append("This planet belongs to the galaxy "
+                                        + Galaxy.this.name + " with " + starsCount + " stars\n");
+                            buf.append("This planet belongs to the galaxy "
+                                        + Universe.Galaxy.this.name + " with " + starsCount() + " stars\n");
+                            buf.append("This planet belongs to the galaxy "
+                                        + Galaxy.this.name() + " with " + starsCount() + " stars\n");
+                            buf.append("This planet belongs to the galaxy "
+                                        + Universe.Galaxy.this.name() + " with "
+                                        + (Universe.Galaxy.this).starsCount() + " stars\n");
+
+                            buf.append("This planet belongs to the solar system "
+                                        + SolarSystem.this.name + " with " + planetsCount + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + Galaxy.SolarSystem.this.name + " with " + planetsCount() + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + (SolarSystem.this).name + " with " + planetsCount + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + Universe.Galaxy.SolarSystem.this.name + " with "
+                                        + Universe.Galaxy.SolarSystem.this.planetsCount + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + Universe.Galaxy.SolarSystem.this.name.toLowerCase().toUpperCase()
+                                        + " with " + Universe.Galaxy.SolarSystem.this.planetsCount + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + copy(Universe.Galaxy.SolarSystem.this).name.toLowerCase().toUpperCase()
+                                        + " with " + Universe.Galaxy.SolarSystem.this.planetsCount + " planets\n");
+                            if (!buf.toString().equals(output))
+                                throw new AssertionError("Unexpected value\n" + buf);
+                        });
+                    }
+
+                    static final String output =
+                        "This planet belongs to the galaxy Mily way with 23456789 stars\n" +
+                        "This planet belongs to the galaxy Mily way with 23456789 stars\n" +
+                        "This planet belongs to the galaxy Mily way with 23456789 stars\n" +
+                        "This planet belongs to the galaxy Mily way with 23456789 stars\n" +
+                        "This planet belongs to the solar system Sun with 9 planets\n" +
+                        "This planet belongs to the solar system Sun with 9 planets\n" +
+                        "This planet belongs to the solar system Sun with 9 planets\n" +
+                        "This planet belongs to the solar system Sun with 9 planets\n" +
+                        "This planet belongs to the solar system SUN with 9 planets\n" +
+                        "This planet belongs to the solar system SUN with 9 planets\n";
+
+
+                    public String toString() {
+                        return "Planet " + name + " with " + moonsCount + " moon(s)";
+                    }
+                }
+            }
+        }
+    }
+    public static void main(String[] args) {
+        new QualifiedThisAccessTest().new Universe("Universe", 12345678).new Galaxy("Mily way", 23456789).new SolarSystem("Sun", 9).new Planet("Earth", 1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8129740/SourceForTranslation.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,122 @@
+    class Universe { // Not referenced by lambda, so should not be captured.
+
+        public String name;
+        public int galaxiesCount;
+
+        public Universe(String name, int galaxiesCount) {
+            this.name = name;
+            this.galaxiesCount = galaxiesCount;
+        }
+
+        public String toString() {
+            return "Universe" + name + " of " + galaxiesCount + " galaxies";
+        }
+
+        class Galaxy {
+
+            String name;
+            private int starsCount;
+
+            Galaxy(String name, int starsCount) {
+                this.name = name;
+                this.starsCount = starsCount;
+            }
+
+            public String toString() {
+                return "galaxy " + name + " of " + starsCount + " solar systems";
+            }
+
+            int starsCount() {
+                return starsCount;
+            }
+
+            private String name() {
+                return name;
+            }
+
+            class SolarSystem {
+
+                String name;
+                int planetsCount;
+
+                SolarSystem(String name, int planetsCount) {
+                    this.name = name;
+                    this.planetsCount = planetsCount;
+                }
+
+                public String toString() {
+                    return "Solar System of " + name + " with " + planetsCount + " planets";
+                }
+
+                int planetsCount() {
+                    return planetsCount;
+                }
+
+                SolarSystem copy(SolarSystem s) {
+                    return s;
+                }
+
+                class Planet {
+
+                    String name;
+                    int moonsCount;
+
+                    Planet(String name, int moonsCount, Runnable r) {
+                        this.name = name;
+                        this.moonsCount = moonsCount;
+                        r.run();
+                    }
+                    Planet (String name, int moonsCount) {
+                        this(name, moonsCount, ()-> {
+                            String n = name;
+                            StringBuffer buf = new StringBuffer();
+                            buf.append("This planet belongs to the galaxy "
+                                        + Galaxy.this.name + " with " + starsCount + " stars\n");
+                            buf.append("This planet belongs to the galaxy "
+                                        + Universe.Galaxy.this.name + " with " + starsCount() + " stars\n");
+                            buf.append("This planet belongs to the galaxy "
+                                        + Galaxy.this.name() + " with " + starsCount() + " stars\n");
+                            buf.append("This planet belongs to the galaxy "
+                                        + Universe.Galaxy.this.name() + " with "
+                                        + (Universe.Galaxy.this).starsCount() + " stars\n");
+
+                            buf.append("This planet belongs to the solar system "
+                                        + SolarSystem.this.name + " with " + planetsCount + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + Galaxy.SolarSystem.this.name + " with " + planetsCount() + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + (SolarSystem.this).name + " with " + planetsCount + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + Universe.Galaxy.SolarSystem.this.name + " with "
+                                        + Universe.Galaxy.SolarSystem.this.planetsCount + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + Universe.Galaxy.SolarSystem.this.name.toLowerCase().toUpperCase()
+                                        + " with " + Universe.Galaxy.SolarSystem.this.planetsCount + " planets\n");
+                            buf.append("This planet belongs to the solar system "
+                                        + copy(Universe.Galaxy.SolarSystem.this).name.toLowerCase().toUpperCase()
+                                        + " with " + Universe.Galaxy.SolarSystem.this.planetsCount + " planets\n");
+                            if (!buf.toString().equals(output))
+                                throw new AssertionError("Unexpected value\n" + buf);
+                        });
+                    }
+
+                    static final String output =
+                        "This planet belongs to the galaxy Mily way with 23456789 stars\n" +
+                        "This planet belongs to the galaxy Mily way with 23456789 stars\n" +
+                        "This planet belongs to the galaxy Mily way with 23456789 stars\n" +
+                        "This planet belongs to the galaxy Mily way with 23456789 stars\n" +
+                        "This planet belongs to the solar system Sun with 9 planets\n" +
+                        "This planet belongs to the solar system Sun with 9 planets\n" +
+                        "This planet belongs to the solar system Sun with 9 planets\n" +
+                        "This planet belongs to the solar system Sun with 9 planets\n" +
+                        "This planet belongs to the solar system SUN with 9 planets\n" +
+                        "This planet belongs to the solar system SUN with 9 planets\n";
+
+
+                    public String toString() {
+                        return "Planet " + name + " with " + moonsCount + " moon(s)";
+                    }
+                }
+            }
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8129740/SourceToSourceTranslationTest.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, 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 8129740 8133111
+ * @summary Incorrect class file created when passing lambda in inner class constructor
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.file
+ *          jdk.compiler/com.sun.tools.javac.main
+ * @build ToolBox
+ * @run compile -XD-printsource SourceForTranslation.java
+ * @run main SourceToSourceTranslationTest
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+public class SourceToSourceTranslationTest {
+
+    public static void main(String[] args) throws Exception {
+        ToolBox tb = new ToolBox();
+        Path path1 = Paths.get(ToolBox.testClasses, "Universe.java");
+        List<String> file1 = tb.readAllLines(path1);
+
+        Path path2 = Paths.get(ToolBox.testSrc, "Universe.java.out");
+        List<String> file2 = tb.readAllLines(path2);
+        tb.checkEqual(file1, file2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/T8129740/Universe.java.out	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,98 @@
+
+class Universe {
+    public String name;
+    public int galaxiesCount;
+    
+    public Universe(String name, int galaxiesCount) {
+        super();
+        this.name = name;
+        this.galaxiesCount = galaxiesCount;
+    }
+    
+    public String toString() {
+        return "Universe" + name + " of " + galaxiesCount + " galaxies";
+    }
+    
+    class Galaxy {
+        String name;
+        private int starsCount;
+        
+        Galaxy(String name, int starsCount) {
+            super();
+            this.name = name;
+            this.starsCount = starsCount;
+        }
+        
+        public String toString() {
+            return "galaxy " + name + " of " + starsCount + " solar systems";
+        }
+        
+        int starsCount() {
+            return starsCount;
+        }
+        
+        private String name() {
+            return name;
+        }
+        
+        class SolarSystem {
+            String name;
+            int planetsCount;
+            
+            SolarSystem(String name, int planetsCount) {
+                super();
+                this.name = name;
+                this.planetsCount = planetsCount;
+            }
+            
+            public String toString() {
+                return "Solar System of " + name + " with " + planetsCount + " planets";
+            }
+            
+            int planetsCount() {
+                return planetsCount;
+            }
+            
+            SolarSystem copy(SolarSystem s) {
+                return s;
+            }
+            
+            class Planet {
+                String name;
+                int moonsCount;
+                
+                Planet(String name, int moonsCount, Runnable r) {
+                    super();
+                    this.name = name;
+                    this.moonsCount = moonsCount;
+                    r.run();
+                }
+                
+                Planet(String name, int moonsCount) {
+                    this(name, moonsCount, java.lang.invoke.LambdaMetafactory.metafactory(name, Universe.Galaxy.this, Universe.Galaxy.SolarSystem.this));
+                }
+                static final String output = "This planet belongs to the galaxy Mily way with 23456789 stars\nThis planet belongs to the galaxy Mily way with 23456789 stars\nThis planet belongs to the galaxy Mily way with 23456789 stars\nThis planet belongs to the galaxy Mily way with 23456789 stars\nThis planet belongs to the solar system Sun with 9 planets\nThis planet belongs to the solar system Sun with 9 planets\nThis planet belongs to the solar system Sun with 9 planets\nThis planet belongs to the solar system Sun with 9 planets\nThis planet belongs to the solar system SUN with 9 planets\nThis planet belongs to the solar system SUN with 9 planets\n";
+                
+                public String toString() {
+                    return "Planet " + name + " with " + moonsCount + " moon(s)";
+                }
+                
+                /*synthetic*/ private static void lambda$new$0(/*synthetic*/ final String name, /*synthetic*/ final Universe.Galaxy Universe$Galaxy$this, /*synthetic*/ final Universe.Galaxy.SolarSystem Universe$Galaxy$SolarSystem$this) {
+                    String n = name;
+                    StringBuffer buf = new StringBuffer();
+                    buf.append("This planet belongs to the galaxy " + Universe$Galaxy$this.name + " with " + Universe$Galaxy$this.starsCount + " stars\n");
+                    buf.append("This planet belongs to the galaxy " + Universe$Galaxy$this.name + " with " + Universe$Galaxy$this.starsCount() + " stars\n");
+                    buf.append("This planet belongs to the galaxy " + Universe$Galaxy$this.name() + " with " + Universe$Galaxy$this.starsCount() + " stars\n");
+                    buf.append("This planet belongs to the galaxy " + Universe$Galaxy$this.name() + " with " + (Universe$Galaxy$this).starsCount() + " stars\n");
+                    buf.append("This planet belongs to the solar system " + Universe$Galaxy$SolarSystem$this.name + " with " + Universe$Galaxy$SolarSystem$this.planetsCount + " planets\n");
+                    buf.append("This planet belongs to the solar system " + Universe$Galaxy$SolarSystem$this.name + " with " + Universe$Galaxy$SolarSystem$this.planetsCount() + " planets\n");
+                    buf.append("This planet belongs to the solar system " + (Universe$Galaxy$SolarSystem$this).name + " with " + Universe$Galaxy$SolarSystem$this.planetsCount + " planets\n");
+                    buf.append("This planet belongs to the solar system " + Universe$Galaxy$SolarSystem$this.name + " with " + Universe$Galaxy$SolarSystem$this.planetsCount + " planets\n");
+                    buf.append("This planet belongs to the solar system " + Universe$Galaxy$SolarSystem$this.name.toLowerCase().toUpperCase() + " with " + Universe$Galaxy$SolarSystem$this.planetsCount + " planets\n");
+                    buf.append("This planet belongs to the solar system " + Universe$Galaxy$SolarSystem$this.copy(Universe$Galaxy$SolarSystem$this).name.toLowerCase().toUpperCase() + " with " + Universe$Galaxy$SolarSystem$this.planetsCount + " planets\n");
+                    if (!buf.toString().equals(output)) throw new AssertionError("Unexpected value\n" + buf);
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/IntersectionTypeReceiverTest.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2015, 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 8141508
+ * @summary Test that Call site initialization exception is not thrown when the method
+   reference receiver is of intersection type.
+ * @run main IntersectionTypeReceiverTest
+ */
+
+import java.time.LocalDate;
+import java.util.EnumSet;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+public class IntersectionTypeReceiverTest {
+
+    public static void main(String[] args) {
+        String output = valueOfKey(Size.class, LocalDate.now()).toString();
+        if (!"Optional[S]".equals(output))
+            throw new AssertionError("Unexpected output: " + output);
+    }
+
+    enum Size implements Supplier<LocalDate> {
+        S, M, L;
+
+        @Override
+        public LocalDate get() {
+            return LocalDate.now();
+        }
+
+    }
+
+    public static <K, T extends Enum<T> & Supplier<K>> Optional<T> valueOfKey(Class<T> enumType, K key) {
+        return valueOf(enumType, key, T::get);
+    }
+
+    public static <K, T extends Enum<T>> Optional<T> valueOf(Class<T> enumType, K key, Function<T, K> keyExtractor) {
+        return EnumSet.allOf(enumType).stream().filter(t -> Objects.equals(keyExtractor.apply(t), key)).findFirst();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/methodReference/IntersectionTypeReceiverTest2.java	Thu Nov 12 14:13:17 2015 -0800
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015, 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 8142476
+ * @summary Test that Call site initialization exception is not thrown when the method
+   reference receiver is of intersection type.
+ * @run main IntersectionTypeReceiverTest2
+ */
+
+public class IntersectionTypeReceiverTest2 {
+    interface I {
+    }
+
+    interface J {
+        void foo();
+    }
+
+    static <T extends I & J> void bar(T t) {
+        Runnable r = t::foo;
+    }
+
+    public static void main(String[] args) {
+        class A implements I, J {
+            public void foo() {
+            }
+        }
+        bar(new A());
+    }
+}