changeset 2448:456161a34bfa

Merge
author henryjen
date Mon, 30 Sep 2013 10:12:33 -0700
parents 985abf1cd327 8e54490a0d1a
children 5a05c8801ecb
files .hgtags .jcheck/conf test/tools/javac/Diagnostics/compressed/T8012003c.java test/tools/javac/Diagnostics/compressed/T8012003c.out test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java test/tools/javac/defaultMethods/separate/Separate.java test/tools/javac/diags/examples/BadArgTypesInLambda.java
diffstat 33 files changed, 1239 insertions(+), 359 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Sep 25 12:24:13 2013 -0700
+++ b/.hgtags	Mon Sep 30 10:12:33 2013 -0700
@@ -156,6 +156,10 @@
 be069d72dde2bfe6f996c46325a320961ca854c2 jdk8-b32
 46831c72b7f6c69fef2cc2935001863643a65f94 jdk8-b33
 6b105afbb77ca9600a99eade31f686d070c70581 jdk8-b34
+42a7a264130d63029c7cd29c24379b32d147cdb3 lambda-b45
+68da3a8292fc7e068f1ca2fd5ad95d90e2872845 lambda-b48
+92ef69a3ba61b4252c2c129bed190f3d2e91d6c9 lambda-b50
+92ef69a3ba61b4252c2c129bed190f3d2e91d6c9 lambda-b56
 defd666a786334465496c8901fa302b779c7e045 jdk8-b35
 94bbaa67686f44a124cd16fd9f1e8a6a3f684d2d jdk8-b36
 5891b38985e8b2502296fc29e726b527d03116d2 jdk8-b37
--- a/.jcheck/conf	Wed Sep 25 12:24:13 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-project=jdk8
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Sep 30 10:12:33 2013 -0700
@@ -26,6 +26,7 @@
 package com.sun.tools.javac.code;
 
 import java.lang.ref.SoftReference;
+import java.util.Comparator;
 import java.util.HashSet;
 import java.util.HashMap;
 import java.util.Locale;
@@ -33,6 +34,7 @@
 import java.util.Set;
 import java.util.WeakHashMap;
 
+import javax.lang.model.type.TypeKind;
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.code.Attribute.RetentionPolicy;
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Sep 30 10:12:33 2013 -0700
@@ -2833,7 +2833,7 @@
             boolean isSpeculativeRound =
                     resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
             checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound);
-            if (!isSpeculativeRound) {
+            if (!isSpeculativeRound && target != Type.recoveryType) {
                 checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, target);
             }
             result = check(that, target, VAL, resultInfo);
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Mon Sep 30 10:12:33 2013 -0700
@@ -503,6 +503,25 @@
                 }
             }
         }
+        
+        /**
+         * Get the list of stuck variables that do not depend on the target
+         * type - this means that inference will lead to same results during
+         * both OVERLOAD and CHECK modes.
+         */
+        List<Type> targetFreevars() {
+            List<Type> freevars = msym.type.getTypeArguments();
+            ListBuffer<Type> targetVars = ListBuffer.lb();
+            outer: for (Type t : inferenceContext.inferencevars) {
+                for (Type t2 : freevars) {
+                    if (msym.type.getReturnType().contains(t2) &&
+                            t.tsym == t2.tsym) {
+                        targetVars.append(t);
+                    }
+                }
+            }
+            return targetVars.toList();
+        }
     }
 
     /**
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Sep 30 10:12:33 2013 -0700
@@ -1048,41 +1048,6 @@
             };
             return g.nodes.get(0);
         }
-
-        boolean isSubtype(Type s, Type t, Warner warn, Infer infer) {
-            return doIncorporationOp(IncorporationBinaryOpKind.IS_SUBTYPE, s, t, warn, infer);
-        }
-
-        boolean isSameType(Type s, Type t, Infer infer) {
-            return doIncorporationOp(IncorporationBinaryOpKind.IS_SAME_TYPE, s, t, null, infer);
-        }
-
-        void addBound(InferenceBound ib, UndetVar uv, Type b, Infer infer) {
-            doIncorporationOp(opFor(ib), uv, b, null, infer);
-        }
-
-        IncorporationBinaryOpKind opFor(InferenceBound boundKind) {
-            switch (boundKind) {
-                case EQ:
-                    return IncorporationBinaryOpKind.ADD_EQ_BOUND;
-                case LOWER:
-                    return IncorporationBinaryOpKind.ADD_LOWER_BOUND;
-                case UPPER:
-                    return IncorporationBinaryOpKind.ADD_UPPER_BOUND;
-                default:
-                    Assert.error("Can't get here!");
-                    return null;
-            }
-        }
-
-        boolean doIncorporationOp(IncorporationBinaryOpKind opKind, Type op1, Type op2, Warner warn, Infer infer) {
-            IncorporationBinaryOp newOp = infer.new IncorporationBinaryOp(opKind, op1, op2);
-            Boolean res = infer.incorporationCache.get(newOp);
-            if (res == null) {
-                infer.incorporationCache.put(newOp, res = newOp.apply(warn));
-            }
-            return res;
-        }
     }
 
     /**
@@ -1208,7 +1173,7 @@
         THROWS(InferenceBound.UPPER) {
             @Override
             public boolean accepts(UndetVar t, InferenceContext inferenceContext) {
-                if ((t.qtype.tsym.flags() & Flags.THROWS) == 0) {
+                if (t.isCaptured() || (t.qtype.tsym.flags() & Flags.THROWS) == 0) {
                     //not a throws undet var
                     return false;
                 }
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Mon Sep 30 10:12:33 2013 -0700
@@ -91,7 +91,10 @@
     /** info about the current class being processed */
     private KlassInfo kInfo;
 
-    /** dump statistics about lambda code generation */
+    /** for testing purposes force all lambdas to take a serializable form */
+    private boolean forceSerializableRepresentation;
+
+	/** dump statistics about lambda code generation */
     private boolean dumpLambdaToMethodStats;
 
     /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */
@@ -163,6 +166,7 @@
         make = TreeMaker.instance(context);
         types = Types.instance(context);
         transTypes = TransTypes.instance(context);
+        // forceSerializableRepresentation = true;
         analyzer = new LambdaAnalyzerPreprocessor();
         Options options = Options.instance(context);
         dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats");
@@ -584,10 +588,10 @@
             DiagnosticPosition pos, List<Object> staticArgs, MethodType indyType) {
         String functionalInterfaceClass = classSig(targetType);
         String functionalInterfaceMethodName = samSym.getSimpleName().toString();
-        String functionalInterfaceMethodSignature = methodSig(types.erasure(samSym.type));
+        String functionalInterfaceMethodSignature = typeSig(types.erasure(samSym.type));
         String implClass = classSig(types.erasure(refSym.owner.type));
         String implMethodName = refSym.getQualifiedName().toString();
-        String implMethodSignature = methodSig(types.erasure(refSym.type));
+        String implMethodSignature = typeSig(types.erasure(refSym.type));
 
         JCExpression kindTest = eqTest(syms.intType, deserGetter("getImplMethodKind", syms.intType), make.Literal(implMethodKind));
         ListBuffer<JCExpression> serArgs = ListBuffer.lb();
@@ -1095,8 +1099,21 @@
          * keep the count of lambda expression defined in given context (used to
          * generate unambiguous names for serializable lambdas)
          */
-        private Map<String, Integer> serializableLambdaCounts =
-                new HashMap<String, Integer>();
+        private class SyntheticMethodNameCounter {
+            private Map<String, Integer> map = new HashMap<String, Integer>();
+            int getIndex(StringBuilder buf) {
+                String temp = buf.toString();
+                Integer count = map.get(temp);
+                if (count == null) {
+                    count = 0;
+                }
+                ++count;
+                map.put(temp, count);
+                return count;
+            }
+        }
+        private SyntheticMethodNameCounter syntheticMethodNameCounts =
+                new SyntheticMethodNameCounter();
 
         private Map<Symbol, JCClassDecl> localClassDefs;
 
@@ -1130,13 +1147,13 @@
         @Override
         public void visitClassDef(JCClassDecl tree) {
             List<Frame> prevStack = frameStack;
-            Map<String, Integer> prevSerializableLambdaCount =
-                    serializableLambdaCounts;
+            SyntheticMethodNameCounter prevSyntheticMethodNameCounts =
+                    syntheticMethodNameCounts;
             Map<ClassSymbol, Symbol> prevClinits = clinits;
             DiagnosticSource prevSource = log.currentSource();
             try {
                 log.useSource(tree.sym.sourcefile);
-                serializableLambdaCounts = new HashMap<String, Integer>();
+                syntheticMethodNameCounts = new SyntheticMethodNameCounter();
                 prevClinits = new HashMap<ClassSymbol, Symbol>();
                 if (tree.sym.owner.kind == MTH) {
                     localClassDefs.put(tree.sym, tree);
@@ -1162,7 +1179,7 @@
             finally {
                 log.useSource(prevSource.getFile());
                 frameStack = prevStack;
-                serializableLambdaCounts = prevSerializableLambdaCount;
+                syntheticMethodNameCounts = prevSyntheticMethodNameCounts;
                 clinits = prevClinits;
             }
         }
@@ -1385,50 +1402,6 @@
             }
         }
 
-        private Name lambdaName() {
-            return names.lambda.append(names.fromString("" + lambdaCount++));
-        }
-
-        /**
-         * For a serializable lambda, generate a name which maximizes name
-         * stability across deserialization.
-         * @param owner
-         * @return Name to use for the synthetic lambda method name
-         */
-        private Name serializedLambdaName(Symbol owner) {
-            StringBuilder buf = new StringBuilder();
-            buf.append(names.lambda);
-            // Append the name of the method enclosing the lambda.
-            String methodName = owner.name.toString();
-            if (methodName.equals("<clinit>"))
-                methodName = "static";
-            else if (methodName.equals("<init>"))
-                methodName = "new";
-            buf.append(methodName);
-            buf.append('$');
-            // Append a hash of the enclosing method signature to differentiate
-            // overloaded enclosing methods.  For lambdas enclosed in lambdas,
-            // the generated lambda method will not have type yet, but the
-            // enclosing method's name will have been generated with this same
-            // method, so it will be unique and never be overloaded.
-            Assert.check(owner.type != null || directlyEnclosingLambda() != null);
-            if (owner.type != null) {
-                int methTypeHash = methodSig(owner.type).hashCode();
-                buf.append(Integer.toHexString(methTypeHash));
-            }
-            buf.append('$');
-            // The above appended name components may not be unique, append a
-            // count based on the above name components.
-            String temp = buf.toString();
-            Integer count = serializableLambdaCounts.get(temp);
-            if (count == null) {
-                count = 0;
-            }
-            buf.append(count++);
-            serializableLambdaCounts.put(temp, count);
-            return names.fromString(buf.toString());
-        }
-
         /**
          * Return a valid owner given the current declaration stack
          * (required to skip synthetic lambda symbols)
@@ -1645,19 +1618,19 @@
         private abstract class TranslationContext<T extends JCFunctionalExpression> {
 
             /** the underlying (untranslated) tree */
-            T tree;
+            final T tree;
 
             /** points to the adjusted enclosing scope in which this lambda/mref expression occurs */
-            Symbol owner;
+            final Symbol owner;
 
             /** the depth of this lambda expression in the frame stack */
-            int depth;
+            final int depth;
 
             /** the enclosing translation context (set for nested lambdas/mref) */
-            TranslationContext<?> prev;
+            final TranslationContext<?> prev;
 
             /** list of methods to be bridged by the meta-factory */
-            List<Symbol> bridges;
+            final List<Symbol> bridges;
 
             TranslationContext(T tree) {
                 this.tree = tree;
@@ -1678,6 +1651,9 @@
 
             /** does this functional expression require serialization support? */
             boolean isSerializable() {
+                if (forceSerializableRepresentation) {
+                    return true;
+                }
                 for (Type target : tree.targets) {
                     if (types.asSuper(target, syms.serializableType.tsym) != null) {
                         return true;
@@ -1685,6 +1661,31 @@
                 }
                 return false;
             }
+            
+            /**
+             * @return Name of the enclosing method to be folded into synthetic
+             * method name
+             */
+            String enclosingMethodName() {
+                return syntheticMethodNameComponent(owner.name);
+            }
+            
+            /**
+             * @return Method name in a form that can be folded into a 
+             * component of a synthetic method name
+             */
+            String syntheticMethodNameComponent(Name name) {
+                if (name == null) {
+                    return "null";
+                }
+                String methodName = name.toString();
+                if (methodName.equals("<clinit>")) {
+                    methodName = "static";
+                } else if (methodName.equals("<init>")) {
+                    methodName = "new";
+                }
+                return methodName;
+            }
         }
 
         /**
@@ -1695,43 +1696,136 @@
          */
         private class LambdaTranslationContext extends TranslationContext<JCLambda> {
 
+            /** variable declaration in the enclosing context to which this lambda is assigned */
+            final Symbol self;
+
             /** variable in the enclosing context to which this lambda is assigned */
-            Symbol self;
+            final Symbol assignedTo;
 
             /** map from original to translated lambda parameters */
-            Map<Symbol, Symbol> lambdaParams = new LinkedHashMap<Symbol, Symbol>();
+            final Map<Symbol, Symbol> lambdaParams = new LinkedHashMap<Symbol, Symbol>();
 
             /** map from original to translated lambda locals */
-            Map<Symbol, Symbol> lambdaLocals = new LinkedHashMap<Symbol, Symbol>();
+            final Map<Symbol, Symbol> lambdaLocals = new LinkedHashMap<Symbol, Symbol>();
 
             /** map from variables in enclosing scope to translated synthetic parameters */
-            Map<Symbol, Symbol> capturedLocals  = new LinkedHashMap<Symbol, Symbol>();
+            final Map<Symbol, Symbol> capturedLocals  = new LinkedHashMap<Symbol, Symbol>();
 
             /** map from class symbols to translated synthetic parameters (for captured member access) */
-            Map<Symbol, Symbol> capturedThis = new LinkedHashMap<Symbol, Symbol>();
+            final Map<Symbol, Symbol> capturedThis = new LinkedHashMap<Symbol, Symbol>();
 
             /** map from original to translated lambda locals */
-            Map<Symbol, Symbol> typeVars = new LinkedHashMap<Symbol, Symbol>();
+            final Map<Symbol, Symbol> typeVars = new LinkedHashMap<Symbol, Symbol>();
 
             /** the synthetic symbol for the method hoisting the translated lambda */
-            Symbol translatedSym;
+            final Symbol translatedSym;
 
             List<JCVariableDecl> syntheticParams;
 
             LambdaTranslationContext(JCLambda tree) {
                 super(tree);
                 Frame frame = frameStack.head;
-                if (frame.tree.hasTag(VARDEF)) {
-                    self = ((JCVariableDecl)frame.tree).sym;
+                switch (frame.tree.getTag()) {
+                    case VARDEF:
+                        assignedTo = self = ((JCVariableDecl) frame.tree).sym;
+                        break;
+                    case ASSIGN:
+                        self = null;
+                        assignedTo = TreeInfo.symbol(((JCAssign) frame.tree).getVariable());
+                        break;
+                    default:
+                        assignedTo = self = null;
+                        break;
                 }
-                Name name = isSerializable() ? serializedLambdaName(owner) : lambdaName();
-                this.translatedSym = makeSyntheticMethod(0, name, null, owner.enclClass());
+                
+                // This symbol will be filled-in in complete
+                this.translatedSym = makeSyntheticMethod(0, null, null, owner.enclClass());
+                
                 if (dumpLambdaToMethodStats) {
                     log.note(tree, "lambda.stat", needsAltMetafactory(), translatedSym);
                 }
             }
 
             /**
+             * For a serializable lambda, generate a disambiguating string
+             * which maximizes stability across deserialization.
+             *
+             * @return String to differentiate synthetic lambda method names
+             */
+            private String serializedLambdaDisambiguation() {
+                StringBuilder buf = new StringBuilder();
+                // Append the enclosing method signature to differentiate
+                // overloaded enclosing methods.  For lambdas enclosed in
+                // lambdas, the generated lambda method will not have type yet,
+                // but the enclosing method's name will have been generated
+                // with this same method, so it will be unique and never be
+                // overloaded.
+                Assert.check(
+                        owner.type != null || 
+                        directlyEnclosingLambda() != null);
+                if (owner.type != null) {
+                    buf.append(typeSig(owner.type));
+                    buf.append(":");
+                }
+                
+                // Add target type info
+                buf.append(types.findDescriptorSymbol(tree.type.tsym).owner.flatName());
+                buf.append(" ");
+                
+                // Add variable assigned to
+                if (assignedTo != null) {
+                    buf.append(assignedTo.flatName());
+                    buf.append("=");
+                }
+                
+                //add captured locals info: type, name, order
+                for (Symbol fv : getSymbolMap(CAPTURED_VAR).keySet()) {
+                    if (fv != self) {
+                        buf.append(typeSig(fv.type));
+                        buf.append(" ");
+                        buf.append(fv.flatName());
+                        buf.append(",");
+                    }
+                }
+
+                return buf.toString();
+            }
+
+            /**
+             * For a non-serializable lambda, generate a simple method.
+             *
+             * @return Name to use for the synthetic lambda method name
+             */
+            private Name lambdaName() {
+                return names.lambda.append(names.fromString(enclosingMethodName() + "$" + lambdaCount++));
+            }
+
+            /**
+             * For a serializable lambda, generate a method name which maximizes
+             * name stability across deserialization.
+             *
+             * @return Name to use for the synthetic lambda method name
+             */
+            private Name serializedLambdaName() {
+                StringBuilder buf = new StringBuilder();
+                buf.append(names.lambda);
+                // Append the name of the method enclosing the lambda.
+                buf.append(enclosingMethodName());
+                buf.append('$');
+                // Append a hash of the disambiguating string : enclosing method 
+                // signature, etc.
+                String disam = serializedLambdaDisambiguation();
+                buf.append(Integer.toHexString(disam.hashCode()));
+                buf.append('$');
+                // The above appended name components may not be unique, append
+                // a count based on the above name components.
+                buf.append(syntheticMethodNameCounts.getIndex(buf));
+                String result = buf.toString();
+                //System.err.printf("serializedLambdaName: %s -- %s\n", result, disam);
+                return names.fromString(result);
+            }
+
+            /**
              * Translate a symbol of a given kind into something suitable for the
              * synthetic lambda body
              */
@@ -1860,6 +1954,11 @@
 
                 syntheticParams = params.toList();
 
+                // Compute and set the lambda name
+                translatedSym.name = isSerializable() ? 
+                     serializedLambdaName()
+                   : lambdaName();
+                
                 //prepend synthetic args to translated lambda method signature
                 translatedSym.type = types.createMethodTypeWithParameters(
                         generatedLambdaSig(),
@@ -1887,7 +1986,7 @@
                 this.isSuper = tree.hasKind(ReferenceKind.SUPER);
                 this.bridgeSym = needsBridge()
                         ? makeSyntheticMethod(isSuper ? 0 : STATIC,
-                                              lambdaName().append(names.fromString("$bridge")), null,
+                                              referenceBridgeName(), null,
                                               owner.enclClass())
                         : null;
                 if (dumpLambdaToMethodStats) {
@@ -1907,6 +2006,63 @@
             boolean needsVarArgsConversion() {
                 return tree.varargsElement != null;
             }
+            
+            /**
+             * Generate a disambiguating string to increase stability (important
+             * if serialized)
+             *
+             * @return String to differentiate synthetic lambda method names
+             */
+            private String referenceBridgeDisambiguation() {
+                StringBuilder buf = new StringBuilder();
+                // Append the enclosing method signature to differentiate
+                // overloaded enclosing methods.  
+                if (owner.type != null) {
+                    buf.append(typeSig(owner.type));
+                    buf.append(":");
+                }
+                
+                // Append qualifier type
+                buf.append(classSig(tree.sym.owner.type));
+                
+                // Note static/instance
+                buf.append(tree.sym.isStatic()? " S " : " I ");
+                
+                // Append referenced signature
+                buf.append(typeSig(tree.sym.erasure(types)));
+                
+                return buf.toString();
+            }
+
+            /**
+             * Construct a unique stable name for the method reference bridge
+             *
+             * @return Name to use for the synthetic method name
+             */
+            private Name referenceBridgeName() {
+                StringBuilder buf = new StringBuilder();
+                // Append lambda ID, this is semantically significant
+                buf.append(names.lambda);
+                // Note that it is a method reference brdieg
+                buf.append("MR$");
+                // Append the enclosing method name
+                buf.append(enclosingMethodName());
+                buf.append('$');
+                // Append the referenced method name
+                buf.append(syntheticMethodNameComponent(tree.sym.name));
+                buf.append('$');
+                // Append a hash of the disambiguating string : enclosing method 
+                // signature, etc.
+                String disam = referenceBridgeDisambiguation();
+                buf.append(Integer.toHexString(disam.hashCode()));
+                buf.append('$');
+                // The above appended name components may not be unique, append
+                // a count based on the above name components.
+                buf.append(syntheticMethodNameCounts.getIndex(buf));
+                String result = buf.toString();
+                //System.err.printf("referenceBridgeName: %s -- %s\n", result, disam);
+                return names.fromString(result);
+            }
 
             /**
              * @return Is this an array operation like clone()
@@ -1963,7 +2119,7 @@
      * ****************************************************************
      */
 
-    private String methodSig(Type type) {
+    private String typeSig(Type type) {
         L2MSignatureGenerator sg = new L2MSignatureGenerator();
         sg.assembleSig(type);
         return sg.toString();
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Sep 30 10:12:33 2013 -0700
@@ -867,6 +867,12 @@
         }
     };
 
+    /** 
+     * This class handles method reference applicability checks; since during
+     * these checks it's sometime possible to have inference variables on
+     * the actual argument types list, the method applicability check must be
+     * extended so that inference variables are 'opened' as needed.
+     */
     class MethodReferenceCheck extends AbstractMethodCheck {
 
         InferenceContext pendingInferenceContext;
@@ -1000,7 +1006,7 @@
     class MostSpecificCheck implements MethodCheck {
 
         boolean strict;
-        List<Type> actuals;
+        List<Type> actuals;        Symbol other;
 
         MostSpecificCheck(boolean strict, List<Type> actuals) {
             this.strict = strict;
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Mon Sep 30 10:12:33 2013 -0700
@@ -29,6 +29,7 @@
 
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.code.Type.ForAll;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.*;
@@ -38,6 +39,7 @@
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.FORALL;
 import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
 import static com.sun.tools.javac.code.TypeTag.VOID;
 import static com.sun.tools.javac.comp.CompileStates.CompileState;
@@ -480,6 +482,10 @@
     /** Visitor argument: proto-type.
      */
     private Type pt;
+    
+    /** Visitor argument: additional synthetic functional interfaces.
+     */
+    private List<JCTree> bridgedFunctionalInterfaces;
 
     /** Visitor method: perform a type translation on tree.
      */
--- a/test/Makefile	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/Makefile	Mon Sep 30 10:12:33 2013 -0700
@@ -7,7 +7,7 @@
 # A full product build (or "control" build) creates a complete JDK image.
 # To test a product build, set TESTJAVA to the path for the image.
 #
-# A langtools build just builds the langtools components of a JDK. 
+# A langtools build just builds the langtools components of a JDK.
 # To test a langtools build, set TESTJAVA to the path for a recent JDK
 # build, and set TESTBOOTCLASSPATH to the compiled langtools classes --
 # for example build/classes or dist/lib/classes.jar.
@@ -122,10 +122,10 @@
   TESTJAVA = $(SLASH_JAVA)/re/jdk/1.7.0/promoted/latest/binaries/$(PLATFORM)-$(ARCH)
 endif
 
-# PRODUCT_HOME is a JPRT variable pointing to a directory containing the output from 
+# PRODUCT_HOME is a JPRT variable pointing to a directory containing the output from
 # make/Makefile
 # For langtools, this is a directory containing build and dist
-# For a control build, this is build/$(PRODUCT)-$(ARCH)/XYZ-image 
+# For a control build, this is build/$(PRODUCT)-$(ARCH)/XYZ-image
 #	(i.e, j2sdk-image or jdk-module-image)
 ifdef PRODUCT_HOME
   ifeq ($(shell [ -r $(PRODUCT_HOME)/dist/lib/classes.jar ]; echo $$?),0)
@@ -139,13 +139,13 @@
 ifdef TESTBOOTCLASSPATH
   JTREG_OPTIONS += -Xbootclasspath/p:$(TESTBOOTCLASSPATH)
 ### In the following, -refvmoptions is an undocumented option
-### The following does not work JCK 7 b30 2/6/2010. Awaiting b31. 
+### The following does not work JCK 7 b30 2/6/2010. Awaiting b31.
   JCK_OPTIONS += \
 	-vmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH) \
 	-refvmoptions:-Xbootclasspath/p:$(TESTBOOTCLASSPATH)
 endif
 
-# Concurrency is the number of tests that can execute at once. 
+# Concurrency is the number of tests that can execute at once.
 # On an otherwise empty machine, suggest setting to (#cpus + 2)
 # If unset, the default is (#cpus)
 ### RFE: determine and use #cpus
@@ -206,7 +206,7 @@
 # Exit -- used for final "normal" exit from "make". Redefine to "true" to avoid
 # having make exit with non-zero return code.
 EXIT = exit
-# Function to exit shell if exit code of preceding command is greater than or equal 
+# Function to exit shell if exit code of preceding command is greater than or equal
 # to a given level. Redefine function or preceding FATAL_*_EXIT codes as needed.
 EXIT_IF_FATAL = status=$$?; if [ $$status -ge $(1) ]; then exit $$status ; fi
 
@@ -250,12 +250,12 @@
 
 # Run jtreg tests
 #
-# JTREG_HOME
+# JT_HOME
 #	Installed location of jtreg
 # JT_JAVA
 #	Version of java used to run jtreg.  Should normally be the same as TESTJAVA
 # TESTJAVA
-# 	Version of java to be tested.  
+# 	Version of java to be tested.
 # JTREG_OPTIONS
 #	Additional options for jtreg
 # JTREG_TESTDIRS
@@ -311,7 +311,7 @@
 #	Version of java used to run JCK.  Should normally be the same as TESTJAVA
 #       Default is JDK 7
 # TESTJAVA
-# 	Version of java to be tested.  
+# 	Version of java to be tested.
 # JCK_COMPILER_OPTIONS
 #	Additional options for JCK-compiler
 # JCK_COMPILER_TESTDIRS
@@ -360,7 +360,7 @@
 # JT_JAVA
 #	Version of java used to run JCK.  Should normally be the same as TESTJAVA
 # TESTJAVA
-# 	Version of java to be tested.  
+# 	Version of java to be tested.
 # JCK_RUNTIME_OPTIONS
 #	Additional options for JCK-runtime
 # JCK_RUNTIME_TESTDIRS
@@ -434,4 +434,3 @@
 
 # No use of suffix rules
 .SUFFIXES:
-
--- a/test/tools/javac/6889255/T6889255.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/tools/javac/6889255/T6889255.java	Mon Sep 30 10:12:33 2013 -0700
@@ -417,6 +417,9 @@
 
     String getExpectedName(VarSymbol v, int i) {
         // special cases:
+        // bridge methods use argN. No LVT for them anymore
+        if ((v.owner.flags() & Flags.BRIDGE) != 0)
+            return "arg" + (i - 1);
         // synthetic method
         if (((v.owner.owner.flags() & Flags.ENUM) != 0)
                 && v.owner.name.toString().equals("valueOf"))
@@ -428,10 +431,7 @@
         // abstract methods don't have saved names
         // -- no Code attribute for the LocalVariableTable attribute
         if ((v.owner.flags() & Flags.ABSTRACT) != 0)
-            return "arg" + (i - 1);
-        // bridge methods use argN. No LVT for them anymore
-        if ((v.owner.flags() & Flags.BRIDGE) != 0)
-            return "arg" + (i - 1);
+            return "arg" + (i - 1);        
 
         // The rest of this method assumes the local conventions in the test program
         Type t = v.type;
--- a/test/tools/javac/Diagnostics/compressed/T8012003c.java	Wed Sep 25 12:24:13 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/**
- * @test /nodynamiccopyright/
- * @bug     8012003
- * @summary Method diagnostics resolution need to be simplified in some cases
- *          test simplification of lambda type-checking error leading to resolution failure
- * @compile/fail/ref=T8012003c.out -XDrawDiagnostics -Xdiags:compact T8012003c.java
- */
-
-class T8012003c {
-
-    interface I {
-        void m(P p);
-    }
-
-    void m(I i) { }
-
-    void test() {
-        m(p->p.m());
-    }
-}
-
-class P {
-    private void m() { }
-}
--- a/test/tools/javac/Diagnostics/compressed/T8012003c.out	Wed Sep 25 12:24:13 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-T8012003c.java:18:15: compiler.err.report.access: m(), private, P
-1 error
--- a/test/tools/javac/T8019486/WrongLVTForLambdaTest.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/tools/javac/T8019486/WrongLVTForLambdaTest.java	Mon Sep 30 10:12:33 2013 -0700
@@ -61,8 +61,6 @@
         {9,           0},       //number -> number / 1
     };
 
-    static final String methodToLookFor = "lambda$0";
-
     public static void main(String[] args) throws Exception {
         new WrongLVTForLambdaTest().run();
     }
@@ -70,7 +68,7 @@
     void run() throws Exception {
         compileTestClass();
         checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
-                "Foo.class").toUri()), methodToLookFor);
+                "Foo.class").toUri()));
     }
 
     void compileTestClass() throws Exception {
@@ -79,12 +77,12 @@
         ToolBox.javac(javacSuccessArgs);
     }
 
-    void checkClassFile(final File cfile, String methodToFind) throws Exception {
+    void checkClassFile(final File cfile) throws Exception {
         ClassFile classFile = ClassFile.read(cfile);
-        boolean methodFound = false;
+        int methodsFound = 0;
         for (Method method : classFile.methods) {
-            if (method.getName(classFile.constant_pool).equals(methodToFind)) {
-                methodFound = true;
+            if (method.getName(classFile.constant_pool).startsWith("lambda$")) {
+                ++methodsFound;
                 Code_attribute code = (Code_attribute) method.attributes.get("Code");
                 LineNumberTable_attribute lnt =
                         (LineNumberTable_attribute) code.attributes.get("LineNumberTable");
@@ -101,7 +99,7 @@
                 }
             }
         }
-        Assert.check(methodFound, "The seek method was not found");
+        Assert.check(methodsFound == 1, "Expected to find one lambda method, found " + methodsFound);
     }
 
     void error(String msg) {
--- a/test/tools/javac/api/TestJavacTaskScanner.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/tools/javac/api/TestJavacTaskScanner.java	Mon Sep 30 10:12:33 2013 -0700
@@ -40,7 +40,10 @@
 import java.nio.*;
 import java.nio.charset.Charset;
 import java.util.Arrays;
+import java.util.Stack;
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Modifier;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.type.TypeMirror;
--- a/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java	Wed Sep 25 12:24:13 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 7192246
- * @summary  check that javac does not generate bridge methods for defaults
- */
-
-import com.sun.tools.classfile.ClassFile;
-import com.sun.tools.classfile.ConstantPool.*;
-import com.sun.tools.classfile.Method;
-
-import java.io.*;
-
-public class TestNoBridgeOnDefaults {
-
-    interface A<X> {
-        default <Y> A<X> m(X x, Y y) { return Impl.<X,Y>m1(this, x, y); }
-    }
-
-    static abstract class B<X> implements A<X> { }
-
-    interface C<X> extends A<X> {
-        default <Y> C<X> m(X x, Y y) { return Impl.<X,Y>m2(this, x, y); }
-    }
-
-    static abstract class D<X> extends B<X> implements C<X> { }
-
-    static class Impl {
-       static <X, Y> A<X> m1(A<X> rec, X x, Y y) { return null; }
-       static <X, Y> C<X> m2(C<X> rec, X x, Y y) { return null; }
-    }
-
-    static final String[] SUBTEST_NAMES = { B.class.getName() + ".class", D.class.getName() + ".class" };
-    static final String TEST_METHOD_NAME = "m";
-
-    public static void main(String... args) throws Exception {
-        new TestNoBridgeOnDefaults().run();
-    }
-
-    public void run() throws Exception {
-        String workDir = System.getProperty("test.classes");
-        for (int i = 0 ; i < SUBTEST_NAMES.length ; i ++) {
-            File compiledTest = new File(workDir, SUBTEST_NAMES[i]);
-            checkNoBridgeOnDefaults(compiledTest);
-        }
-    }
-
-    void checkNoBridgeOnDefaults(File f) {
-        System.err.println("check: " + f);
-        try {
-            ClassFile cf = ClassFile.read(f);
-            for (Method m : cf.methods) {
-                String mname = m.getName(cf.constant_pool);
-                if (mname.equals(TEST_METHOD_NAME)) {
-                    throw new Error("unexpected bridge method found " + m);
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new Error("error reading " + f +": " + e);
-        }
-    }
-}
--- a/test/tools/javac/defaultMethods/separate/Separate.java	Wed Sep 25 12:24:13 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 7192246
- * @summary smoke test for separate compilation of default methods
- * @author  Maurizio Cimadamore
- * @compile  pkg1/A.java
- * @compile  Separate.java
- */
-
-import pkg1.A;
-
-class Separate {
-    interface B extends A.I {
-        default void m() { A.m(this); }
-    }
-
-    interface C extends A.I, B { }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/separate/Separate01.java	Mon Sep 30 10:12:33 2013 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7192246
+ * @summary smoke test for separate compilation of default methods
+ * @author  Maurizio Cimadamore
+ * @compile  pkg1/A.java
+ * @compile  Separate01.java
+ */
+
+import pkg1.A;
+
+class Separate01 {
+    interface B extends A.I {
+        default void m() { A.m(this); }
+    }
+
+    interface C extends A.I, B { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/separate/Separate02.java	Mon Sep 30 10:12:33 2013 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8013789
+ * @summary  Compiler should emit bridges in interfaces
+ * @compile  pkg2/B.java
+ * @compile  Separate02.java
+ */
+
+import pkg2.B;
+
+class Separate02 implements B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/separate/pkg2/A.java	Mon Sep 30 10:12:33 2013 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg2;
+
+public interface A {
+   Object m();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/separate/pkg2/B.java	Mon Sep 30 10:12:33 2013 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg2;
+
+public interface B extends A {
+   default String m() { return ""; }
+}
--- a/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java	Mon Sep 30 10:12:33 2013 -0700
@@ -199,7 +199,7 @@
 
     void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
         JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                Arrays.asList("-XDallowStaticInterfaceMethods"), null, Arrays.asList(source));
+                null, null, Arrays.asList(source));
         try {
             ct.analyze();
         } catch (Throwable ex) {
--- a/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java	Mon Sep 30 10:12:33 2013 -0700
@@ -54,7 +54,7 @@
         }
 
         List<String> getOptions() {
-            return Arrays.asList("-XDallowStaticInterfaceMethods", "-source", versionString);
+            return Arrays.asList("-source", versionString);
         }
     }
 
--- a/test/tools/javac/diags/examples.not-yet.txt	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/tools/javac/diags/examples.not-yet.txt	Mon Sep 30 10:12:33 2013 -0700
@@ -111,4 +111,3 @@
 compiler.warn.unknown.enum.constant                     # in bad class file
 compiler.warn.unknown.enum.constant.reason              # in bad class file
 compiler.warn.override.equals.but.not.hashcode          # when a class overrides equals but not hashCode method from Object
-
--- a/test/tools/javac/diags/examples/BadArgTypesInLambda.java	Wed Sep 25 12:24:13 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.prob.found.req
-// key: compiler.misc.inconvertible.types
-// options: -Xdiags:verbose
-
-class BadArgTypesInLambda {
-    interface SAM {
-        void m(Integer i);
-    }
-
-    void g(SAM s) { }
-
-    void test() {
-        g(x->{ String s = x; });
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/8023364/T8023364a.java	Mon Sep 30 10:12:33 2013 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8023364
+ * @summary Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
+ * @compile T8023364a.java
+ */
+public class T8023364a { 
+    interface SAM<T> { 
+        T get(); 
+    } 
+    
+    public static void main(String[] args) { 
+        SAM<SAM> sam = new SAM<SAM>() { public SAM get() { return null; } };
+        SAM temp = sam.get()::get; 
+    } 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/8023364/T8023364b.java	Mon Sep 30 10:12:33 2013 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8023364
+ * @summary Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
+ * @compile T8023364b.java
+ */
+class Test { 
+    
+    interface Supplier<X> {
+        X get();
+    }
+    
+    static class A { 
+        public A(Supplier<B> supplier) { }
+    }
+
+    static class B { }
+
+    static class C { 
+        public B getB() { 
+            return new B(); 
+        } 
+    } 
+
+    public static void main(String[] args) { 
+        new Test().test(Test::getC); 
+    } 
+
+    private static C getC() { 
+        return new C(); 
+    } 
+
+    public void test(Supplier<C> supplier) { 
+        new A(supplier.get()::getB); 
+    } 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/BadConv01.out	Mon Sep 30 10:12:33 2013 -0700
@@ -0,0 +1,2 @@
+BadConv01.java:35:13: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.invalid.generic.target.for.lambda.conv: m, kindname.interface, BadConv01.Bar)), #int(T), BadConv01.Bar
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/BadConv02.out	Mon Sep 30 10:12:33 2013 -0700
@@ -0,0 +1,3 @@
+BadConv02.java:44:15: compiler.err.cant.apply.symbol: kindname.constructor, FooImpl, int, compiler.misc.no.args, kindname.class, BadConv02.FooImpl, null
+BadConv02.java:45:15: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.target.for.lambda.conv.must.have.default.constr: null, kindname.class, BadConv02.Foo)), #int(), BadConv02.Foo
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/ByteCodeTest.java	Mon Sep 30 10:12:33 2013 -0700
@@ -0,0 +1,647 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     8011738
+ * @author  sogoel
+ * @summary Code translation test for Lambda expressions, method references
+ * @run main ByteCodeTest
+ */
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.BootstrapMethods_attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPool;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.ConstantPool.*;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+public class ByteCodeTest {
+
+    static boolean IS_DEBUG = false;
+    public static void main(String[] args) {
+        File classFile = null;
+        int err = 0;
+        boolean verifyResult = false;
+        for(TestCases tc : TestCases.values()) {
+            classFile = getCompiledFile(tc.name(), tc.srcCode);
+            if(classFile == null) { // either testFile or classFile was not created
+               err++;
+            } else {
+                verifyResult = verifyClassFileAttributes(classFile, tc);
+                if(!verifyResult) 
+                    System.out.println("Bootstrap class file attributes did not match for " + tc.name());
+            }
+        }
+        if(err > 0) 
+            throw new RuntimeException("Found " + err + " found");
+        else 
+            System.out.println("Test passed");
+    }
+
+    private static boolean verifyClassFileAttributes(File classFile, TestCases tc) {
+        ClassFile c = null;
+        try {
+            c = ClassFile.read(classFile);
+        } catch (IOException | ConstantPoolException e) {
+            e.printStackTrace();
+        }
+        ConstantPoolVisitor cpv = new ConstantPoolVisitor(c, c.constant_pool.size());
+        Map<Integer, String> hm = cpv.getBSMMap();
+        
+        List<String> expectedValList = tc.getExpectedArgValues();
+        expectedValList.add(tc.bsmSpecifier.specifier);
+        if(!(hm.values().containsAll(new HashSet<String>(expectedValList)))) {
+            System.out.println("Values do not match");
+            return false;
+        }
+        return true;
+    }
+
+    private static File getCompiledFile(String fname, String srcString) {
+        File testFile = null, classFile = null;
+        boolean isTestFileCreated = true;
+
+        try {
+            testFile = writeTestFile(fname+".java", srcString);
+        } catch(IOException ioe) {
+            isTestFileCreated = false;
+            System.err.println("fail to write" + ioe);
+        }
+
+        if(isTestFileCreated) {
+            try {
+                classFile = compile(testFile);
+            } catch (Error err) {
+                System.err.println("fail compile. Source:\n" + srcString);
+                throw err;
+            }
+        }
+        return classFile;
+    }
+
+    static File writeTestFile(String fname, String source) throws IOException {
+        File f = new File(fname);
+          PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+          out.println(source);
+          out.close();
+          return f;
+    }
+
+    static File compile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] {
+                "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+                throw new Error("compilation failed. rc=" + rc);
+            String path = f.getPath();
+            return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    static void debugln(String str) {
+        if(IS_DEBUG)
+            System.out.println(str);
+    }
+
+    enum BSMSpecifier {
+        SPECIFIER1("REF_invokeStatic java/lang/invoke/LambdaMetafactory metaFactory " +
+                "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;" +
+                "Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)" +
+                "Ljava/lang/invoke/CallSite;"),
+        SPECIFIER2("REF_invokeStatic java/lang/invoke/LambdaMetafactory altMetaFactory " +
+        		"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;" +
+        		"[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;");
+        
+        String specifier;
+        private BSMSpecifier(String specifier) {
+            this.specifier = specifier;
+        }
+    }
+    
+    enum TestCases {
+        // Single line lambda expression
+        TC1("class TC1 {\n" +
+            "    public static void main(String[] args) {\n" +
+            "        Object o = (Runnable) () -> { System.out.println(\"hi\");};\n" +
+            "    }\n"+
+            "}", BSMSpecifier.SPECIFIER1) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeInterface java/lang/Runnable run ()V");
+                valList.add("REF_invokeStatic TC1 lambda$0 ()V");
+                valList.add("()V");
+                return valList;
+            }
+        },
+
+        // Lambda expression in a for loop
+        TC2("import java.util.*;\n" + 
+            "public class TC2 {\n" +
+            "    void TC2_test() {\n" + 
+            "        List<String> list = new ArrayList<>();\n" +
+            "        list.add(\"A\");\n" +
+            "        list.add(\"B\");\n" +
+            "        list.stream().forEach( s -> { System.out.println(s); } );\n" +
+            "    }\n" +
+            "    public static void main(String[] args) {\n" +
+            "        new TC2().TC2_test();\n" +
+            "    }\n" +
+            "}", BSMSpecifier.SPECIFIER1) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeInterface java/util/function/Consumer accept (Ljava/lang/Object;)V");
+                valList.add("REF_invokeStatic TC2 lambda$0 (Ljava/lang/String;)V");
+                valList.add("(Ljava/lang/String;)V");
+                return valList;
+            }
+        },
+
+        // Lambda initializer
+        TC3("class TC3 {\n" +
+            "    interface SAM {\n" +
+            "        void m(int i);\n" +
+            "    }\n" +
+            "    SAM lambda_03 = (int pos) -> { };\n" +
+            "}", BSMSpecifier.SPECIFIER1) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeInterface TC3$SAM m (I)V");
+                valList.add("REF_invokeStatic TC3 lambda$0 (I)V");
+                valList.add("(I)V");
+                return valList;
+            }
+        },
+
+        // Array initializer
+        TC4("class TC4 {\n" +
+            "    interface Block<T> {\n" +
+            "        void m(T t);\n" +
+            "     }\n" +
+            "     void test1() {\n" +
+            "         Block<?>[] arr1 =  { t -> { }, t -> { } };\n" +
+            "     }\n" +
+            "}", BSMSpecifier.SPECIFIER1) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeInterface TC4$Block m (Ljava/lang/Object;)V");
+                valList.add("REF_invokeStatic TC4 lambda$0 (Ljava/lang/Object;)V");
+                valList.add("(Ljava/lang/Object;)V");
+                valList.add("REF_invokeStatic TC4 lambda$1 (Ljava/lang/Object;)V");
+                return valList;
+            }
+        },
+        
+        //Lambda expression as a method arg
+        TC5("class TC5 {\n"+
+            "    interface MapFun<T,R> {  R m( T n); }\n" +
+            "    void meth( MapFun<String,Integer> mf ) {\n" +
+            "        assert( mf.m(\"four\") == 4);\n" +
+            "    }\n"+
+            "    void test(Integer i) {\n" +
+            "        meth(s -> { Integer len = s.length(); return len; } );\n" +
+            "    }\n"+
+            "}", BSMSpecifier.SPECIFIER1) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeInterface TC5$MapFun m (Ljava/lang/Object;)Ljava/lang/Object;");
+                valList.add("REF_invokeStatic TC5 lambda$0 (Ljava/lang/String;)Ljava/lang/Integer;");
+                valList.add("(Ljava/lang/String;)Ljava/lang/Integer;");
+                return valList;
+            }
+        },
+
+        //Inner class of Lambda expression
+        TC6("class TC6 {\n" +
+            "    interface MapFun<T, R> {  R m( T n); }\n" +
+            "    MapFun<Class<?>,String> cs;\n" +
+            "    void test() {\n" + 
+            "        cs = c -> {\n" +
+            "                 class innerClass   {\n" +
+            "                    Class<?> icc;\n" +
+            "                    innerClass(Class<?> _c) { icc = _c; }\n" +
+            "                    String getString() { return icc.toString(); }\n" +
+            "                  }\n" +
+            "             return new innerClass(c).getString();\n"+
+            "             };\n" +
+            "    }\n" +
+            "}\n", BSMSpecifier.SPECIFIER1) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeInterface TC6$MapFun m (Ljava/lang/Object;)Ljava/lang/Object;");
+                valList.add("REF_invokeSpecial TC6 lambda$0 (Ljava/lang/Class;)Ljava/lang/String;");
+                valList.add("(Ljava/lang/Class;)Ljava/lang/String;");
+                return valList;
+            }
+        },
+
+        // Method reference
+        TC7("class TC7 {\n" +
+            "    static interface SAM {\n" +
+            "       void m(Integer i);\n" +
+            "    }\n" +
+            "    void m(Integer i) {}\n" +
+            "       SAM s = this::m;\n" +
+            "}\n", BSMSpecifier.SPECIFIER1) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeInterface TC7$SAM m (Ljava/lang/Integer;)V");
+                valList.add("REF_invokeVirtual TC7 m (Ljava/lang/Integer;)V");
+                valList.add("(Ljava/lang/Integer;)V");
+                return valList;
+            }
+        },
+
+        // Constructor reference
+        TC8("public class TC8 {\n" +
+            "    static interface A {Fee<String> m();}\n" +
+            "    static class Fee<T> {\n" +
+            "        private T t;\n" +
+            "        public Fee() {}\n" +
+            "    }\n" +
+            "    public static void main(String[] args) {\n" +
+            "        A a = Fee<String>::new; \n" +
+            "    }\n" +
+            "}\n", BSMSpecifier.SPECIFIER1) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeInterface TC8$A m ()LTC8$Fee;");
+                valList.add("REF_newInvokeSpecial TC8$Fee <init> ()V");
+                valList.add("()LTC8$Fee;");
+                return valList;
+            }
+        },
+
+        // Recursive lambda expression
+        TC9("class TC9 {\n" +
+            "    interface Recursive<T, R> { T apply(R n); };\n" +
+            "    Recursive<Integer,Integer> factorial;\n" +
+            "    void test(Integer j) {\n" +
+            "        factorial = i -> { return i == 0 ? 1 : i * factorial.apply( i - 1 ); };\n" +
+            "    }\n" +
+            "}\n", BSMSpecifier.SPECIFIER1) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeInterface TC9$Recursive apply (Ljava/lang/Object;)Ljava/lang/Object;");
+                valList.add("REF_invokeSpecial TC9 lambda$0 (Ljava/lang/Integer;)Ljava/lang/Integer;");
+                valList.add("(Ljava/lang/Integer;)Ljava/lang/Integer;");
+                return valList;
+            }
+        },
+
+        //Serializable Lambda
+        TC10("import java.io.Serializable;\n" +
+              "class TC10 {\n" +
+              "    interface Foo { int m(); }\n" +
+              "    public static void main(String[] args) {\n" +
+              "        Foo f1 = (Foo & Serializable)() -> 3;\n" +
+              "    }\n" +
+              "}\n", BSMSpecifier.SPECIFIER2) {
+
+            @Override
+            List<String> getExpectedArgValues() {
+                List<String> valList = new ArrayList<>();
+                valList.add("REF_invokeStatic java/lang/invoke/LambdaMetafactory altMetaFactory (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;");
+                valList.add("REF_invokeInterface TC10$Foo m ()I");
+                valList.add("REF_invokeStatic TC10 lambda$main$3231c38a$0 ()I");
+                valList.add("()I");
+                valList.add("1");
+                return valList;
+            }
+        };
+
+        String srcCode;
+        BSMSpecifier bsmSpecifier;
+
+        TestCases(String src, BSMSpecifier bsmSpecifier) {
+            this.srcCode = src;
+            // By default, all test cases will have bootstrap method specifier as Lambda.MetaFactory
+            // For serializable lambda test cases, bootstrap method specifier changed to altMetaFactory
+            this.bsmSpecifier = bsmSpecifier;
+        }
+
+        List<String> getExpectedArgValues() {
+            return null;
+        }
+        
+        void setSrcCode(String src) {
+            srcCode = src;
+        }
+    }
+
+    static class ConstantPoolVisitor implements ConstantPool.Visitor<String, Integer> {
+        final List<String> slist;
+        final ClassFile cf;
+        final ConstantPool cfpool;
+        final Map<Integer, String> bsmMap;
+
+
+        public ConstantPoolVisitor(ClassFile cf, int size) {
+            slist = new ArrayList<>(size);
+            for (int i = 0 ; i < size; i++) {
+                slist.add(null);
+            }
+            this.cf = cf;
+            this.cfpool = cf.constant_pool;
+            bsmMap = readBSM();
+        }
+
+        public Map<Integer, String> getBSMMap() {
+            return Collections.unmodifiableMap(bsmMap);
+        }
+
+        public String visit(CPInfo c, int index) {
+            return c.accept(this, index);
+        }
+
+        private Map<Integer, String> readBSM() {
+            BootstrapMethods_attribute bsmAttr =
+                    (BootstrapMethods_attribute) cf.getAttribute(Attribute.BootstrapMethods);
+            if (bsmAttr != null) {
+                Map<Integer, String> out =
+                        new HashMap<>(bsmAttr.bootstrap_method_specifiers.length);
+                for (BootstrapMethods_attribute.BootstrapMethodSpecifier bsms :
+                        bsmAttr.bootstrap_method_specifiers) {
+                    int index = bsms.bootstrap_method_ref;
+                    try {
+                        String value = slist.get(index);
+                        if (value == null) {
+                            value = visit(cfpool.get(index), index);
+                            debugln("[SG]: index " + index);
+                            debugln("[SG]: value " + value);
+                            slist.set(index, value);
+                            out.put(index, value);
+                        }
+                        for (int idx : bsms.bootstrap_arguments) {
+                            value = slist.get(idx);
+                            if (value == null) {
+                                value = visit(cfpool.get(idx), idx);
+                                debugln("[SG]: idx " + idx);
+                                debugln("[SG]: value " + value);
+                                slist.set(idx, value);
+                                out.put(idx, value);
+                            }
+                        }
+                    } catch (InvalidIndex ex) {
+                        ex.printStackTrace();
+                    }
+                }
+                return out;
+            }
+            return new HashMap<>(0);
+        }
+
+        @Override
+        public String visitClass(CONSTANT_Class_info c, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                try {
+                    value = visit(cfpool.get(c.name_index), c.name_index);
+                    slist.set(p, value);
+                } catch (ConstantPoolException ex) {
+                    ex.printStackTrace();
+                }
+            }
+            return value;
+        }
+
+        @Override
+        public String visitDouble(CONSTANT_Double_info c, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                value = Double.toString(c.value);
+                slist.set(p, value);
+            }
+            return value;
+        }
+
+        @Override
+        public String visitFieldref(CONSTANT_Fieldref_info c, Integer p) {
+
+        String value = slist.get(p);
+            if (value == null) {
+                try {
+                    value = visit(cfpool.get(c.class_index), c.class_index);
+                    value = value.concat(" " + visit(cfpool.get(c.name_and_type_index),
+                                         c.name_and_type_index));
+                    slist.set(p, value);
+                } catch (ConstantPoolException ex) {
+                    ex.printStackTrace();
+                }
+            }
+            return value;
+        }
+
+        @Override
+        public String visitFloat(CONSTANT_Float_info c, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                value = Float.toString(c.value);
+                slist.set(p, value);
+            }
+            return value;
+        }
+
+        @Override
+        public String visitInteger(CONSTANT_Integer_info cnstnt, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                value = Integer.toString(cnstnt.value);
+                slist.set(p, value);
+            }
+            return value;
+        }
+
+        @Override
+        public String visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info c,
+                                              Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                try {
+                    value = visit(cfpool.get(c.class_index), c.class_index);
+                    value = value.concat(" " +
+                                         visit(cfpool.get(c.name_and_type_index),
+                                         c.name_and_type_index));
+                    slist.set(p, value);
+                } catch (ConstantPoolException ex) {
+                    ex.printStackTrace();
+                }
+            }
+            return value;
+        }
+
+        @Override
+        public String visitInvokeDynamic(CONSTANT_InvokeDynamic_info c, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                try {
+                    value = bsmMap.get(c.bootstrap_method_attr_index) + " "
+                            + visit(cfpool.get(c.name_and_type_index), c.name_and_type_index);
+                    slist.set(p, value);
+                } catch (ConstantPoolException ex) {
+                    ex.printStackTrace();
+                }
+            }
+            return value;
+        }
+
+        @Override
+        public String visitLong(CONSTANT_Long_info c, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                value = Long.toString(c.value);
+                slist.set(p, value);
+            }
+            return value;
+        }
+
+        @Override
+        public String visitNameAndType(CONSTANT_NameAndType_info c, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                try {
+                    value = visit(cfpool.get(c.name_index), c.name_index);
+                    value = value.concat(" " +
+                            visit(cfpool.get(c.type_index), c.type_index));
+                    slist.set(p, value);
+                } catch (InvalidIndex ex) {
+                    ex.printStackTrace();
+                }
+            }
+            return value;
+        }
+
+        @Override
+        public String visitMethodref(CONSTANT_Methodref_info c, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                try {
+                    value = visit(cfpool.get(c.class_index), c.class_index);
+                    value = value.concat(" " +
+                                         visit(cfpool.get(c.name_and_type_index),
+                                         c.name_and_type_index));
+                    slist.set(p, value);
+                } catch (ConstantPoolException ex) {
+                    ex.printStackTrace();
+                }
+            }
+            return value;
+        }
+
+        @Override
+        public String visitMethodHandle(CONSTANT_MethodHandle_info c, Integer p) {
+
+        String value = slist.get(p);
+            if (value == null) {
+                try {
+                    value = c.reference_kind.name();
+                    value = value.concat(" "
+                            + visit(cfpool.get(c.reference_index), c.reference_index));
+                    slist.set(p, value);
+                } catch (ConstantPoolException ex) {
+                    ex.printStackTrace();
+                }
+            }
+            return value;
+        }
+
+        @Override
+        public String visitMethodType(CONSTANT_MethodType_info c, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                try {
+                    value = visit(cfpool.get(c.descriptor_index), c.descriptor_index);
+                    slist.set(p, value);
+                } catch (ConstantPoolException ex) {
+                    ex.printStackTrace();
+                }
+            }
+            return value;
+        }
+
+        @Override
+        public String visitString(CONSTANT_String_info c, Integer p) {
+
+            try {
+                String value = slist.get(p);
+                if (value == null) {
+                    value = c.getString();
+                    slist.set(p, value);
+                }
+                return value;
+            } catch (ConstantPoolException ex) {
+                throw new RuntimeException("Fatal error", ex);
+            }
+        }
+
+        @Override
+        public String  visitUtf8(CONSTANT_Utf8_info cnstnt, Integer p) {
+
+            String value = slist.get(p);
+            if (value == null) {
+                value = cnstnt.value;
+                slist.set(p, value);
+            }
+            return value;
+        }
+    }
+}
+
--- a/test/tools/javac/lambda/LambdaParserTest.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/tools/javac/lambda/LambdaParserTest.java	Mon Sep 30 10:12:33 2013 -0700
@@ -29,7 +29,7 @@
  *  temporarily workaround combo tests are causing time out in several platforms
  * @library ../lib
  * @build JavacTestingAbstractThreadedTest
- * @run main/othervm LambdaParserTest
+ * @run main/othervm/timeout=800 LambdaParserTest
  */
 
 // use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
@@ -51,10 +51,10 @@
         NILARY_STMT("()->{ return x; }"),
         ONEARY_SHORT_EXPR("#PN->x"),
         ONEARY_SHORT_STMT("#PN->{ return x; }"),
-        ONEARY_EXPR("(#M1 #T1 #PN)->x"),
-        ONEARY_STMT("(#M1 #T1 #PN)->{ return x; }"),
-        TWOARY_EXPR("(#M1 #T1 #PN, #M2 #T2 y)->x"),
-        TWOARY_STMT("(#M1 #T1 #PN, #M2 #T2 y)->{ return x; }");
+        ONEARY_EXPR("(#A1 #M1 #T1 #PN)->x"),
+        ONEARY_STMT("(#A1 #M1 #T1 #PN)->{ return x; }"),
+        TWOARY_EXPR("(#A1 #M1 #T1 #PN, #A2 #M2 #T2 y)->x"),
+        TWOARY_STMT("(#A1 #M1 #T1 #PN, #A2 #M2 #T2 y)->{ return x; }");
 
         String lambdaTemplate;
 
@@ -63,9 +63,12 @@
         }
 
         String getLambdaString(LambdaParameterKind pk1, LambdaParameterKind pk2,
-                ModifierKind mk1, ModifierKind mk2, LambdaParameterName pn) {
+                ModifierKind mk1, AnnotationKind ak1, ModifierKind mk2, AnnotationKind ak2,
+                LambdaParameterName pn) {
             return lambdaTemplate.replaceAll("#M1", mk1.modifier)
+                    .replaceAll("#A1", ak1.anno)
                     .replaceAll("#M2", mk2.modifier)
+                    .replaceAll("#A2", ak2.anno)
                     .replaceAll("#T1", pk1.parameterType)
                     .replaceAll("#T2", pk2.parameterType)
                     .replaceAll("#PN", pn.nameStr);
@@ -129,6 +132,22 @@
                     this == EXPLICIT_GENERIC2_VARARGS;
         }
     }
+    
+    enum AnnotationKind {
+        NONE(""),
+        ANNO("@Anno");
+
+        String anno;
+
+        AnnotationKind(String anno) {
+            this.anno = anno;
+        }
+        
+        boolean compatibleWith(LambdaParameterKind pk) {
+            return pk != LambdaParameterKind.IMPLICIT ||
+                    this == NONE;
+        }
+    }
 
     enum ModifierKind {
         NONE(""),
@@ -166,8 +185,9 @@
         }
 
         String expressionString(LambdaParameterKind pk1, LambdaParameterKind pk2,
-                ModifierKind mk1, ModifierKind mk2, LambdaKind lk, LambdaParameterName pn, SubExprKind sk) {
-            return expressionTemplate.replaceAll("#L", lk.getLambdaString(pk1, pk2, mk1, mk2, pn))
+                ModifierKind mk1, AnnotationKind ak1, ModifierKind mk2, AnnotationKind ak2,
+                LambdaKind lk, LambdaParameterName pn, SubExprKind sk) {
+            return expressionTemplate.replaceAll("#L", lk.getLambdaString(pk1, pk2, mk1, ak1, mk2, ak2, pn))
                     .replaceAll("#S", sk.subExpression);
         }
     }
@@ -198,17 +218,19 @@
                             continue;
                         for (ModifierKind mk1 : ModifierKind.values()) {
                             if (mk1 != ModifierKind.NONE && lk.isShort())
-                                continue;
-                            if (lk.arity() < 1 && mk1 != ModifierKind.NONE)
-                                continue;
-                            for (ModifierKind mk2 : ModifierKind.values()) {
-                                if (lk.arity() < 2 && mk2 != ModifierKind.NONE)
-                                    continue;
-                                for (SubExprKind sk : SubExprKind.values()) {
-                                    for (ExprKind ek : ExprKind.values()) {
-                                        pool.execute(
-                                            new LambdaParserTest(pk1, pk2, mk1,
-                                                                 mk2, lk, sk, ek, pn));
+								continue;
+                            for (AnnotationKind ak1 : AnnotationKind.values()) {
+                                if (lk.arity() < 1 && mk1 != ModifierKind.NONE)
+									continue;
+                                for (ModifierKind mk2 : ModifierKind.values()) {
+                                    for (AnnotationKind ak2 : AnnotationKind.values()) {
+                                        if (lk.arity() < 2 && mk2 != ModifierKind.NONE)
+											continue;
+                                        for (SubExprKind sk : SubExprKind.values()) {
+                                            for (ExprKind ek : ExprKind.values()) {
+                                                pool.execute(new LambdaParserTest(pk1, pk2, mk1, ak1, mk2, ak2, lk, pn, sk, ek));
+                                            }
+                                        }
                                     }
                                 }
                             }
@@ -223,8 +245,8 @@
 
     LambdaParameterKind pk1;
     LambdaParameterKind pk2;
-    ModifierKind mk1;
-    ModifierKind mk2;
+    ModifierKind mk1, mk2;
+    AnnotationKind ak1, ak2;
     LambdaKind lk;
     LambdaParameterName pn;
     SubExprKind sk;
@@ -232,13 +254,15 @@
     JavaSource source;
     DiagnosticChecker diagChecker;
 
-    LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2,
-            ModifierKind mk1, ModifierKind mk2, LambdaKind lk,
-            SubExprKind sk, ExprKind ek, LambdaParameterName pn) {
+    LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2, ModifierKind mk1,
+            AnnotationKind ak1, ModifierKind mk2, AnnotationKind ak2, LambdaKind lk,
+            LambdaParameterName pn, SubExprKind sk, ExprKind ek) {
         this.pk1 = pk1;
         this.pk2 = pk2;
         this.mk1 = mk1;
+        this.ak1 = ak1;
         this.mk2 = mk2;
+        this.ak2 = ak2;
         this.lk = lk;
         this.pn = pn;
         this.sk = sk;
@@ -249,7 +273,8 @@
 
     class JavaSource extends SimpleJavaFileObject {
 
-        String template = "class Test {\n" +
+        String template = "@interface Anno { }\n" +
+                          "class Test {\n" +
                           "   SAM s = #E;\n" +
                           "}";
 
@@ -257,8 +282,7 @@
 
         public JavaSource() {
             super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
-            source = template.replaceAll("#E",
-                    ek.expressionString(pk1, pk2, mk1, mk2, lk, pn, sk));
+            source = template.replaceAll("#E", ek.expressionString(pk1, pk2, mk1, ak1, mk2, ak2, lk, pn, sk));
         }
 
         @Override
@@ -284,16 +308,19 @@
 
         boolean errorExpected = (lk.arity() > 0 && !mk1.compatibleWith(pk1)) ||
                 (lk.arity() > 1 && !mk2.compatibleWith(pk2));
-
+        
+        errorExpected |= !lk.isShort() && ((lk.arity() > 0 && !ak1.compatibleWith(pk1)) ||
+                (lk.arity() > 1 && !ak2.compatibleWith(pk2)));
+        
+        errorExpected |= pn == LambdaParameterName.UNDERSCORE &&
+                lk.arity() > 0;
+        
         if (lk.arity() == 2 &&
                 (pk1.explicit() != pk2.explicit() ||
                 pk1.isVarargs())) {
             errorExpected = true;
         }
 
-        errorExpected |= pn == LambdaParameterName.UNDERSCORE &&
-                lk.arity() > 0;
-
         if (errorExpected != diagChecker.errorFound) {
             throw new Error("invalid diagnostics for source:\n" +
                 source.getCharContent(true) +
--- a/test/tools/javac/lambda/methodReference/SamConversionComboTest.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/tools/javac/lambda/methodReference/SamConversionComboTest.java	Mon Sep 30 10:12:33 2013 -0700
@@ -7,7 +7,7 @@
  * 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
+ * ANY WARRANTY; without even the implied warranty of MERzCHANTABILITY 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).
--- a/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java	Wed Sep 25 12:24:13 2013 -0700
+++ b/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java	Mon Sep 30 10:12:33 2013 -0700
@@ -165,7 +165,7 @@
 
         checkAfterExec();
     }
-
+    
     LambdaReturnKind lrk;
     RetTypeKind rt1, rt2;
     ArgTypeKind ak1, ak2;
@@ -235,6 +235,12 @@
 
     void check() {
         checkCount.incrementAndGet();
+        
+        if (ak1 != ak2)
+            return;
+
+        if (ak1 != ak2)
+            return;
 
         if (ak1 != ak2)
             return;