changeset 2399:9a7967dcfb03

Merge
author jjg
date Wed, 10 Apr 2013 12:50:05 -0700
parents 58cee2b8890b a4be2c2fe0a1
children 83865a913aa0
files .hgtags src/share/classes/com/sun/javadoc/ExecutableMemberDoc.java src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java src/share/classes/com/sun/tools/javac/code/Type.java src/share/classes/com/sun/tools/javac/code/Types.java src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/Infer.java src/share/classes/com/sun/tools/javac/comp/Lower.java src/share/classes/com/sun/tools/javac/comp/Resolve.java src/share/classes/com/sun/tools/javac/jvm/Code.java src/share/classes/com/sun/tools/javac/jvm/Gen.java src/share/classes/com/sun/tools/javac/parser/JavacParser.java src/share/classes/com/sun/tools/javac/resources/compiler.properties src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java test/tools/javac/diags/examples/SecondaryBoundMustBeMarkerIntf.java test/tools/javac/lambda/Intersection01.out test/tools/javac/lambda/TargetType01.out
diffstat 48 files changed, 1632 insertions(+), 324 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Apr 04 17:44:59 2013 -0700
+++ b/.hgtags	Wed Apr 10 12:50:05 2013 -0700
@@ -206,3 +206,4 @@
 ed69d087fdfd394491657a28ba9bc58e7849b7db jdk8-b81
 825da6847791994a8f405ee397df9e7fa638a458 jdk8-b82
 22ba3f92d4ae43bbc19793e854171cae2586f644 jdk8-b83
+cfb65ca92082b2412aed66c8422c2466bde544ef jdk8-b84
--- a/src/share/classes/com/sun/javadoc/ExecutableMemberDoc.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/javadoc/ExecutableMemberDoc.java	Wed Apr 10 12:50:05 2013 -0700
@@ -88,6 +88,14 @@
     Parameter[] parameters();
 
     /**
+     * Get the receiver type of this executable element.
+     *
+     * @return the receiver type of this executable element.
+     * @since 1.8
+     */
+    Type receiverType();
+
+    /**
      * Get the receiver annotations of this executable element.
      * Return an empty array if there are none.
      *
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java	Wed Apr 10 12:50:05 2013 -0700
@@ -139,12 +139,24 @@
         }
     }
 
-    protected void addReceiverAnnotations(ExecutableMemberDoc member,
-            Content tree) {
-        if (member.receiverAnnotations().length > 0) {
-            tree.addContent(writer.getSpace());
-            writer.addReceiverAnnotationInfo(member, tree);
-        }
+    /**
+     * Add the receiver annotations information.
+     *
+     * @param member the member to write receiver annotations for.
+     * @param rcvrType the receiver type.
+     * @param descList list of annotation description.
+     * @param tree the content tree to which the information will be added.
+     */
+    protected void addReceiverAnnotations(ExecutableMemberDoc member, Type rcvrType,
+            AnnotationDesc[] descList, Content tree) {
+        writer.addReceiverAnnotationInfo(member, descList, tree);
+        tree.addContent(writer.getSpace());
+        tree.addContent(rcvrType.typeName());
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, rcvrType);
+        tree.addContent(new RawHtml(writer.getTypeParameterLinks(linkInfo)));
+        tree.addContent(writer.getSpace());
+        tree.addContent("this");
     }
 
 
@@ -168,14 +180,24 @@
     protected void addParameters(ExecutableMemberDoc member,
             boolean includeAnnotations, Content htmltree) {
         htmltree.addContent("(");
+        String sep = "";
         Parameter[] params = member.parameters();
         String indent = makeSpace(writer.displayLength);
         if (configuration.linksource) {
             //add spaces to offset indentation changes caused by link.
             indent+= makeSpace(member.name().length());
         }
+        Type rcvrType = member.receiverType();
+        if (includeAnnotations && rcvrType instanceof AnnotatedType) {
+            AnnotationDesc[] descList = rcvrType.asAnnotatedType().annotations();
+            if (descList.length > 0) {
+                addReceiverAnnotations(member, rcvrType, descList, htmltree);
+                sep = "," + DocletConstants.NL + indent;
+            }
+        }
         int paramstart;
         for (paramstart = 0; paramstart < params.length; paramstart++) {
+            htmltree.addContent(sep);
             Parameter param = params[paramstart];
             if (!param.name().startsWith("this$")) {
                 if (includeAnnotations) {
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java	Wed Apr 10 12:50:05 2013 -0700
@@ -137,7 +137,6 @@
             addName(constructor.name(), pre);
         }
         addParameters(constructor, pre);
-        writer.addReceiverAnnotationInfo(constructor, pre);
         addExceptions(constructor, pre);
         return pre;
     }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Apr 10 12:50:05 2013 -0700
@@ -1860,11 +1860,13 @@
      * Add the annotation types of the executable receiver.
      *
      * @param method the executable to write the receiver annotations for.
+     * @param descList list of annotation description.
      * @param htmltree the documentation tree to which the annotation info will be
      *        added
      */
-    public void addReceiverAnnotationInfo(ExecutableMemberDoc method, Content htmltree) {
-        addAnnotationInfo(method, method.receiverAnnotations(), htmltree);
+    public void addReceiverAnnotationInfo(ExecutableMemberDoc method, AnnotationDesc[] descList,
+            Content htmltree) {
+        addAnnotationInfo(0, method, descList, false, htmltree);
     }
 
     /**
@@ -1915,13 +1917,16 @@
     private boolean addAnnotationInfo(int indent, Doc doc,
             AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
         List<String> annotations = getAnnotations(indent, descList, lineBreak);
+        String sep ="";
         if (annotations.size() == 0) {
             return false;
         }
         Content annotationContent;
         for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) {
+            htmltree.addContent(sep);
             annotationContent = new RawHtml(iter.next());
             htmltree.addContent(annotationContent);
+            sep = " ";
         }
         return true;
     }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java	Wed Apr 10 12:50:05 2013 -0700
@@ -130,7 +130,6 @@
             addName(method.name(), pre);
         }
         addParameters(method, pre);
-        addReceiverAnnotations(method, pre);
         addExceptions(method, pre);
         return pre;
     }
--- a/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Apr 10 12:50:05 2013 -0700
@@ -907,6 +907,12 @@
             return interfaces_field.prepend(supertype_field);
         }
 
+        public List<Type> getExplicitComponents() {
+            return allInterfaces ?
+                    interfaces_field :
+                    getComponents();
+        }
+
         @Override
         public TypeKind getKind() {
             return TypeKind.INTERSECTION;
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Apr 10 12:50:05 2013 -0700
@@ -607,7 +607,7 @@
 
    /**
     * Scope filter used to skip methods that should be ignored (such as methods
-    * overridden by j.l.Object) during function interface conversion/marker interface checks
+    * overridden by j.l.Object) during function interface conversion interface check
     */
     class DescriptorFilter implements Filter<Symbol> {
 
@@ -626,64 +626,6 @@
        }
     };
 
-    // <editor-fold defaultstate="collapsed" desc="isMarker">
-
-    /**
-     * A cache that keeps track of marker interfaces
-     */
-    class MarkerCache {
-
-        private WeakHashMap<TypeSymbol, Entry> _map = new WeakHashMap<TypeSymbol, Entry>();
-
-        class Entry {
-            final boolean isMarkerIntf;
-            final int prevMark;
-
-            public Entry(boolean isMarkerIntf,
-                    int prevMark) {
-                this.isMarkerIntf = isMarkerIntf;
-                this.prevMark = prevMark;
-            }
-
-            boolean matches(int mark) {
-                return  this.prevMark == mark;
-            }
-        }
-
-        boolean get(TypeSymbol origin) throws FunctionDescriptorLookupError {
-            Entry e = _map.get(origin);
-            CompoundScope members = membersClosure(origin.type, false);
-            if (e == null ||
-                    !e.matches(members.getMark())) {
-                boolean isMarkerIntf = isMarkerInterfaceInternal(origin, members);
-                _map.put(origin, new Entry(isMarkerIntf, members.getMark()));
-                return isMarkerIntf;
-            }
-            else {
-                return e.isMarkerIntf;
-            }
-        }
-
-        /**
-         * Is given symbol a marker interface
-         */
-        public boolean isMarkerInterfaceInternal(TypeSymbol origin, CompoundScope membersCache) throws FunctionDescriptorLookupError {
-            return !origin.isInterface() ?
-                    false :
-                    !membersCache.getElements(new DescriptorFilter(origin)).iterator().hasNext();
-        }
-    }
-
-    private MarkerCache markerCache = new MarkerCache();
-
-    /**
-     * Is given type a marker interface?
-     */
-    public boolean isMarkerInterface(Type site) {
-        return markerCache.get(site.tsym);
-    }
-    // </editor-fold>
-
     // <editor-fold defaultstate="collapsed" desc="isSubtype">
     /**
      * Is t an unchecked subtype of s?
@@ -2622,15 +2564,15 @@
     public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) {
         Filter<Symbol> filter = new MethodFilter(ms, site);
         List<MethodSymbol> candidates = List.nil();
-        for (Symbol s : membersClosure(site, false).getElements(filter)) {
-            if (!site.tsym.isInterface() && !s.owner.isInterface()) {
-                return List.of((MethodSymbol)s);
-            } else if (!candidates.contains(s)) {
-                candidates = candidates.prepend((MethodSymbol)s);
+            for (Symbol s : membersClosure(site, false).getElements(filter)) {
+                if (!site.tsym.isInterface() && !s.owner.isInterface()) {
+                    return List.of((MethodSymbol)s);
+                } else if (!candidates.contains(s)) {
+                    candidates = candidates.prepend((MethodSymbol)s);
+                }
             }
+            return prune(candidates);
         }
-        return prune(candidates);
-    }
 
     public List<MethodSymbol> prune(List<MethodSymbol> methods) {
         ListBuffer<MethodSymbol> methodsMin = ListBuffer.lb();
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Apr 10 12:50:05 2013 -0700
@@ -2334,7 +2334,7 @@
 
             Type lambdaType;
             if (pt() != Type.recoveryType) {
-                target = checkIntersectionTarget(that, target, resultInfo.checkContext);
+                target = targetChecker.visit(target, that);
                 lambdaType = types.findDescriptorType(target);
                 chk.checkFunctionalInterface(that, target);
             } else {
@@ -2342,7 +2342,7 @@
                 lambdaType = fallbackDescriptorType(that);
             }
 
-            setFunctionalInfo(that, pt(), lambdaType, resultInfo.checkContext.inferenceContext());
+            setFunctionalInfo(that, pt(), lambdaType, target, resultInfo.checkContext.inferenceContext());
 
             if (lambdaType.hasTag(FORALL)) {
                 //lambda expression target desc cannot be a generic method
@@ -2401,11 +2401,34 @@
                 new ResultInfo(VAL, lambdaType.getReturnType(), funcContext);
             localEnv.info.returnResult = bodyResultInfo;
 
-            if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) {
-                attribTree(that.getBody(), localEnv, bodyResultInfo);
-            } else {
-                JCBlock body = (JCBlock)that.body;
-                attribStats(body.stats, localEnv);
+            Log.DeferredDiagnosticHandler lambdaDeferredHandler = new Log.DeferredDiagnosticHandler(log);
+            try {
+                if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) {
+                    attribTree(that.getBody(), localEnv, bodyResultInfo);
+                } else {
+                    JCBlock body = (JCBlock)that.body;
+                    attribStats(body.stats, localEnv);
+                }
+
+                if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) {
+                    //check for errors in lambda body
+                    for (JCDiagnostic deferredDiag : lambdaDeferredHandler.getDiagnostics()) {
+                        if (deferredDiag.getKind() == JCDiagnostic.Kind.ERROR) {
+                            resultInfo.checkContext
+                                    .report(that, diags.fragment("bad.arg.types.in.lambda", TreeInfo.types(that.params)));
+                            //we mark the lambda as erroneous - this is crucial in the recovery step
+                            //as parameter-dependent type error won't be reported in that stage,
+                            //meaning that a lambda will be deemed erroeneous only if there is
+                            //a target-independent error (which will cause method diagnostic
+                            //to be skipped).
+                            result = that.type = types.createErrorType(target);
+                            return;
+                        }
+                    }
+                }
+            } finally {
+                lambdaDeferredHandler.reportDeferredDiagnostics();
+                log.popDiagnosticHandler(lambdaDeferredHandler);
             }
 
             result = check(that, target, VAL, resultInfo);
@@ -2434,26 +2457,55 @@
             }
         }
     }
-
-    private Type checkIntersectionTarget(DiagnosticPosition pos, Type pt, CheckContext checkContext) {
-        if (pt != Type.recoveryType && pt.isCompound()) {
-            IntersectionClassType ict = (IntersectionClassType)pt;
-            List<Type> bounds = ict.allInterfaces ?
-                    ict.getComponents().tail :
-                    ict.getComponents();
-            types.findDescriptorType(bounds.head); //propagate exception outwards!
-            for (Type bound : bounds.tail) {
-                if (!types.isMarkerInterface(bound)) {
-                    checkContext.report(pos, diags.fragment("secondary.bound.must.be.marker.intf", bound));
+    //where
+        Types.MapVisitor<DiagnosticPosition> targetChecker = new Types.MapVisitor<DiagnosticPosition>() {
+
+            @Override
+            public Type visitClassType(ClassType t, DiagnosticPosition pos) {
+                return t.isCompound() ?
+                        visitIntersectionClassType((IntersectionClassType)t, pos) : t;
+            }
+
+            public Type visitIntersectionClassType(IntersectionClassType ict, DiagnosticPosition pos) {
+                Symbol desc = types.findDescriptorSymbol(makeNotionalInterface(ict));
+                Type target = null;
+                for (Type bound : ict.getExplicitComponents()) {
+                    TypeSymbol boundSym = bound.tsym;
+                    if (types.isFunctionalInterface(boundSym) &&
+                            types.findDescriptorSymbol(boundSym) == desc) {
+                        target = bound;
+                    } else if (!boundSym.isInterface() || (boundSym.flags() & ANNOTATION) != 0) {
+                        //bound must be an interface
+                        reportIntersectionError(pos, "not.an.intf.component", boundSym);
+                    }
                 }
+                return target != null ?
+                        target :
+                        ict.getExplicitComponents().head; //error recovery
             }
-            //for now (translation doesn't support intersection types)
-            return bounds.head;
-        } else {
-            return pt;
-        }
-    }
-    //where
+
+            private TypeSymbol makeNotionalInterface(IntersectionClassType ict) {
+                ListBuffer<Type> targs = ListBuffer.lb();
+                ListBuffer<Type> supertypes = ListBuffer.lb();
+                for (Type i : ict.interfaces_field) {
+                    if (i.isParameterized()) {
+                        targs.appendList(i.tsym.type.allparams());
+                    }
+                    supertypes.append(i.tsym.type);
+                }
+                IntersectionClassType notionalIntf =
+                        (IntersectionClassType)types.makeCompoundType(supertypes.toList());
+                notionalIntf.allparams_field = targs.toList();
+                notionalIntf.tsym.flags_field |= INTERFACE;
+                return notionalIntf.tsym;
+            }
+
+            private void reportIntersectionError(DiagnosticPosition pos, String key, Object... args) {
+                resultInfo.checkContext.report(pos, diags.fragment("bad.intersection.target.for.functional.expr",
+                        diags.fragment(key, args)));
+            }
+        };
+
         private Type fallbackDescriptorType(JCExpression tree) {
             switch (tree.getTag()) {
                 case LAMBDA:
@@ -2624,7 +2676,7 @@
             Type target;
             Type desc;
             if (pt() != Type.recoveryType) {
-                target = checkIntersectionTarget(that, pt(), resultInfo.checkContext);
+                target = targetChecker.visit(pt(), that);
                 desc = types.findDescriptorType(target);
                 chk.checkFunctionalInterface(that, target);
             } else {
@@ -2632,11 +2684,12 @@
                 desc = fallbackDescriptorType(that);
             }
 
-            setFunctionalInfo(that, pt(), desc, resultInfo.checkContext.inferenceContext());
+            setFunctionalInfo(that, pt(), desc, target, resultInfo.checkContext.inferenceContext());
             List<Type> argtypes = desc.getParameterTypes();
 
-            Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = rs.resolveMemberReference(that.pos(), localEnv, that,
-                    that.expr.type, that.name, argtypes, typeargtypes, true);
+            Pair<Symbol, Resolve.ReferenceLookupHelper> refResult =
+                    rs.resolveMemberReference(that.pos(), localEnv, that,
+                        that.expr.type, that.name, argtypes, typeargtypes, true, rs.resolveMethodCheck);
 
             Symbol refSym = refResult.fst;
             Resolve.ReferenceLookupHelper lookupHelper = refResult.snd;
@@ -2826,19 +2879,24 @@
      * might contain inference variables, we might need to register an hook in the
      * current inference context.
      */
-    private void setFunctionalInfo(final JCFunctionalExpression fExpr, final Type pt, final Type descriptorType, InferenceContext inferenceContext) {
+    private void setFunctionalInfo(final JCFunctionalExpression fExpr, final Type pt,
+            final Type descriptorType, final Type primaryTarget, InferenceContext inferenceContext) {
         if (inferenceContext.free(descriptorType)) {
             inferenceContext.addFreeTypeListener(List.of(pt, descriptorType), new FreeTypeListener() {
                 public void typesInferred(InferenceContext inferenceContext) {
-                    setFunctionalInfo(fExpr, pt, inferenceContext.asInstType(descriptorType), inferenceContext);
+                    setFunctionalInfo(fExpr, pt, inferenceContext.asInstType(descriptorType),
+                            inferenceContext.asInstType(primaryTarget), inferenceContext);
                 }
             });
         } else {
             ListBuffer<TypeSymbol> targets = ListBuffer.lb();
             if (pt.hasTag(CLASS)) {
                 if (pt.isCompound()) {
+                    targets.append(primaryTarget.tsym); //this goes first
                     for (Type t : ((IntersectionClassType)pt()).interfaces_field) {
-                        targets.append(t.tsym);
+                        if (t != primaryTarget) {
+                            targets.append(t.tsym);
+                        }
                     }
                 } else {
                     targets.append(pt.tsym);
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Wed Apr 10 12:50:05 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -28,6 +28,7 @@
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.comp.Attr.ResultInfo;
@@ -531,12 +532,13 @@
                             attr.memberReferenceQualifierResult(tree));
                     ListBuffer<Type> argtypes = ListBuffer.lb();
                     for (Type t : types.findDescriptorType(pt).getParameterTypes()) {
-                        argtypes.append(syms.errType);
+                        argtypes.append(Type.noType);
                     }
                     JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree);
                     mref2.expr = exprTree;
                     Pair<Symbol, ?> lookupRes =
-                            rs.resolveMemberReference(tree, env, mref2, exprTree.type, tree.name, argtypes.toList(), null, true);
+                            rs.resolveMemberReference(tree, env, mref2, exprTree.type,
+                                tree.name, argtypes.toList(), null, true, rs.arityMethodCheck);
                     switch (lookupRes.fst.kind) {
                         //note: as argtypes are erroneous types, type-errors must
                         //have been caused by arity mismatch
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Apr 10 12:50:05 2013 -0700
@@ -143,7 +143,6 @@
                                   boolean allowBoxing,
                                   boolean useVarargs,
                                   Resolve.MethodResolutionContext resolveContext,
-                                  Resolve.MethodCheck methodCheck,
                                   Warner warn) throws InferenceException {
         //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
         final InferenceContext inferenceContext = new InferenceContext(tvars);
@@ -152,7 +151,7 @@
             DeferredAttr.DeferredAttrContext deferredAttrContext =
                     resolveContext.deferredAttrContext(msym, inferenceContext, resultInfo, warn);
 
-            methodCheck.argumentsAcceptable(env, deferredAttrContext,
+            resolveContext.methodCheck.argumentsAcceptable(env, deferredAttrContext,
                     argtypes, mt.getParameterTypes(), warn);
 
             if (allowGraphInference &&
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Apr 10 12:50:05 2013 -0700
@@ -48,6 +48,7 @@
 import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.jvm.ByteCodes.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
+import javax.lang.model.type.TypeKind;
 
 /** This pass translates away some syntactic sugar: inner classes,
  *  class literals, assertions, foreach loops, etc.
@@ -3400,8 +3401,11 @@
             if (iterableType.getTypeArguments().nonEmpty())
                 iteratorTarget = types.erasure(iterableType.getTypeArguments().head);
             Type eType = tree.expr.type;
+            while (eType.hasTag(TYPEVAR)) {
+                eType = eType.getUpperBound();
+            }
             tree.expr.type = types.erasure(eType);
-            if (eType.hasTag(TYPEVAR) && eType.getUpperBound().isCompound())
+            if (eType.isCompound())
                 tree.expr = make.TypeCast(types.erasure(iterableType), tree.expr);
             Symbol iterator = lookupMethod(tree.expr.pos(),
                                            names.iterator,
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Apr 10 12:50:05 2013 -0700
@@ -508,7 +508,6 @@
                         List<Type> typeargtypes,
                         boolean allowBoxing,
                         boolean useVarargs,
-                        MethodCheck methodCheck,
                         Warner warn) throws Infer.InferenceException {
 
         Type mt = types.memberType(site, m);
@@ -561,10 +560,9 @@
                                     allowBoxing,
                                     useVarargs,
                                     currentResolutionContext,
-                                    methodCheck,
                                     warn);
 
-        methodCheck.argumentsAcceptable(env, currentResolutionContext.deferredAttrContext(m, infer.emptyContext, resultInfo, warn),
+        currentResolutionContext.methodCheck.argumentsAcceptable(env, currentResolutionContext.deferredAttrContext(m, infer.emptyContext, resultInfo, warn),
                                 argtypes, mt.getParameterTypes(), warn);
         return mt;
     }
@@ -582,7 +580,7 @@
             currentResolutionContext.attrMode = DeferredAttr.AttrMode.CHECK;
             MethodResolutionPhase step = currentResolutionContext.step = env.info.pendingResolutionPhase;
             return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes,
-                    step.isBoxingRequired(), step.isVarargsRequired(), resolveMethodCheck, warn);
+                    step.isBoxingRequired(), step.isVarargsRequired(), warn);
         }
         finally {
             currentResolutionContext = prevContext;
@@ -599,11 +597,10 @@
                      List<Type> typeargtypes,
                      boolean allowBoxing,
                      boolean useVarargs,
-                     MethodCheck methodCheck,
                      Warner warn) {
         try {
             return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes,
-                                  allowBoxing, useVarargs, methodCheck, warn);
+                                  allowBoxing, useVarargs, warn);
         } catch (InapplicableMethodException ex) {
             return null;
         }
@@ -628,6 +625,12 @@
                                 List<Type> argtypes,
                                 List<Type> formals,
                                 Warner warn);
+
+        /**
+         * Retrieve the method check object that will be used during a
+         * most specific check.
+         */
+        MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict);
     }
 
     /**
@@ -661,6 +664,100 @@
     }
 
     /**
+     * Dummy method check object. All methods are deemed applicable, regardless
+     * of their formal parameter types.
+     */
+    MethodCheck nilMethodCheck = new MethodCheck() {
+        public void argumentsAcceptable(Env<AttrContext> env, DeferredAttrContext deferredAttrContext, List<Type> argtypes, List<Type> formals, Warner warn) {
+            //do nothing - method always applicable regardless of actuals
+        }
+
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            return this;
+        }
+    };
+
+    /**
+     * Base class for 'real' method checks. The class defines the logic for
+     * iterating through formals and actuals and provides and entry point
+     * that can be used by subclasses in order to define the actual check logic.
+     */
+    abstract class AbstractMethodCheck implements MethodCheck {
+        @Override
+        public void argumentsAcceptable(final Env<AttrContext> env,
+                                    DeferredAttrContext deferredAttrContext,
+                                    List<Type> argtypes,
+                                    List<Type> formals,
+                                    Warner warn) {
+            //should we expand formals?
+            boolean useVarargs = deferredAttrContext.phase.isVarargsRequired();
+
+            //inference context used during this method check
+            InferenceContext inferenceContext = deferredAttrContext.inferenceContext;
+
+            Type varargsFormal = useVarargs ? formals.last() : null;
+
+            if (varargsFormal == null &&
+                    argtypes.size() != formals.size()) {
+                reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
+            }
+
+            while (argtypes.nonEmpty() && formals.head != varargsFormal) {
+                checkArg(false, argtypes.head, formals.head, deferredAttrContext, warn);
+                argtypes = argtypes.tail;
+                formals = formals.tail;
+            }
+
+            if (formals.head != varargsFormal) {
+                reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
+            }
+
+            if (useVarargs) {
+                //note: if applicability check is triggered by most specific test,
+                //the last argument of a varargs is _not_ an array type (see JLS 15.12.2.5)
+                final Type elt = types.elemtype(varargsFormal);
+                while (argtypes.nonEmpty()) {
+                    checkArg(true, argtypes.head, elt, deferredAttrContext, warn);
+                    argtypes = argtypes.tail;
+                }
+            }
+        }
+
+        /**
+         * Does the actual argument conforms to the corresponding formal?
+         */
+        abstract void checkArg(boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn);
+
+        protected void reportMC(MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
+            boolean inferDiag = inferenceContext != infer.emptyContext;
+            InapplicableMethodException ex = inferDiag ?
+                    infer.inferenceException : inapplicableMethodException;
+            if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
+                Object[] args2 = new Object[args.length + 1];
+                System.arraycopy(args, 0, args2, 1, args.length);
+                args2[0] = inferenceContext.inferenceVars();
+                args = args2;
+            }
+            throw ex.setMessage(inferDiag ? diag.inferKey : diag.basicKey, args);
+        }
+
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            return nilMethodCheck;
+        }
+    }
+
+    /**
+     * Arity-based method check. A method is applicable if the number of actuals
+     * supplied conforms to the method signature.
+     */
+    MethodCheck arityMethodCheck = new AbstractMethodCheck() {
+        @Override
+        void checkArg(boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
+            //do nothing - actual always compatible to formals
+        }
+    };
+
+    /**
      * Main method applicability routine. Given a list of actual types A,
      * a list of formal types F, determines whether the types in A are
      * compatible (by method invocation conversion) with the types in F.
@@ -678,62 +775,27 @@
      *
      * A method check handler (see above) is used in order to report errors.
      */
-    MethodCheck resolveMethodCheck = new MethodCheck() {
+    MethodCheck resolveMethodCheck = new AbstractMethodCheck() {
+
+        @Override
+        void checkArg(boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
+            ResultInfo mresult = methodCheckResult(varargs, formal, deferredAttrContext, warn);
+            mresult.check(null, actual);
+        }
+
         @Override
         public void argumentsAcceptable(final Env<AttrContext> env,
                                     DeferredAttrContext deferredAttrContext,
                                     List<Type> argtypes,
                                     List<Type> formals,
                                     Warner warn) {
+            super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn);
             //should we expand formals?
-            boolean useVarargs = deferredAttrContext.phase.isVarargsRequired();
-
-            //inference context used during this method check
-            InferenceContext inferenceContext = deferredAttrContext.inferenceContext;
-
-            Type varargsFormal = useVarargs ? formals.last() : null;
-
-            if (varargsFormal == null &&
-                    argtypes.size() != formals.size()) {
-                reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
+            if (deferredAttrContext.phase.isVarargsRequired()) {
+                //check varargs element type accessibility
+                varargsAccessible(env, types.elemtype(formals.last()),
+                        deferredAttrContext.inferenceContext);
             }
-
-            while (argtypes.nonEmpty() && formals.head != varargsFormal) {
-                ResultInfo mresult = methodCheckResult(false, formals.head, deferredAttrContext, warn);
-                mresult.check(null, argtypes.head);
-                argtypes = argtypes.tail;
-                formals = formals.tail;
-            }
-
-            if (formals.head != varargsFormal) {
-                reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
-            }
-
-            if (useVarargs) {
-                //note: if applicability check is triggered by most specific test,
-                //the last argument of a varargs is _not_ an array type (see JLS 15.12.2.5)
-                final Type elt = types.elemtype(varargsFormal);
-                ResultInfo mresult = methodCheckResult(true, elt, deferredAttrContext, warn);
-                while (argtypes.nonEmpty()) {
-                    mresult.check(null, argtypes.head);
-                    argtypes = argtypes.tail;
-                }
-                //check varargs element type accessibility
-                varargsAccessible(env, elt, inferenceContext);
-            }
-        }
-
-        private void reportMC(MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) {
-            boolean inferDiag = inferenceContext != infer.emptyContext;
-            InapplicableMethodException ex = inferDiag ?
-                    infer.inferenceException : inapplicableMethodException;
-            if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
-                Object[] args2 = new Object[args.length + 1];
-                System.arraycopy(args, 0, args2, 1, args.length);
-                args2[0] = inferenceContext.inferenceVars();
-                args = args2;
-            }
-            throw ex.setMessage(inferDiag ? diag.inferKey : diag.basicKey, args);
         }
 
         private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) {
@@ -765,6 +827,11 @@
             };
             return new MethodResultInfo(to, checkContext);
         }
+
+        @Override
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            return new MostSpecificCheck(strict, actuals);
+        }
     };
 
     /**
@@ -1042,6 +1109,11 @@
                 }
             }
         }
+
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            Assert.error("Cannot get here!");
+            return null;
+        }
     }
 
     public static class InapplicableMethodException extends RuntimeException {
@@ -1254,7 +1326,7 @@
         Assert.check(sym.kind < AMBIGUOUS);
         try {
             Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
-                               allowBoxing, useVarargs, resolveMethodCheck, types.noWarnings);
+                               allowBoxing, useVarargs, types.noWarnings);
             if (!operator)
                 currentResolutionContext.addApplicableCandidate(sym, mt);
         } catch (InapplicableMethodException ex) {
@@ -1358,11 +1430,20 @@
         int maxLength = Math.max(
                             Math.max(m1.type.getParameterTypes().length(), actuals.length()),
                             m2.type.getParameterTypes().length());
-        Type mst = instantiate(env, site, m2, null,
-                adjustArgs(types.lowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null,
-                allowBoxing, useVarargs, new MostSpecificCheck(!allowBoxing, actuals), noteWarner);
-        return mst != null &&
-                !noteWarner.hasLint(Lint.LintCategory.UNCHECKED);
+        MethodResolutionContext prevResolutionContext = currentResolutionContext;
+        try {
+            currentResolutionContext = new MethodResolutionContext();
+            currentResolutionContext.step = prevResolutionContext.step;
+            currentResolutionContext.methodCheck =
+                    prevResolutionContext.methodCheck.mostSpecificCheck(actuals, !allowBoxing);
+            Type mst = instantiate(env, site, m2, null,
+                    adjustArgs(types.lowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null,
+                    allowBoxing, useVarargs, noteWarner);
+            return mst != null &&
+                    !noteWarner.hasLint(Lint.LintCategory.UNCHECKED);
+        } finally {
+            currentResolutionContext = prevResolutionContext;
+        }
     }
     private List<Type> adjustArgs(List<Type> args, Symbol msym, int length, boolean allowVarargs) {
         if ((msym.flags() & VARARGS) != 0 && allowVarargs) {
@@ -2124,14 +2205,14 @@
                          Name name,
                          List<Type> argtypes,
                          List<Type> typeargtypes) {
-        return lookupMethod(env, pos, env.enclClass.sym, new BasicLookupHelper(name, env.enclClass.sym.type, argtypes, typeargtypes) {
-            @Override
-            Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
-                return findFun(env, name, argtypes, typeargtypes,
-                        phase.isBoxingRequired(),
-                        phase.isVarargsRequired());
-            }
-        });
+        return lookupMethod(env, pos, env.enclClass.sym, resolveMethodCheck,
+                new BasicLookupHelper(name, env.enclClass.sym.type, argtypes, typeargtypes) {
+                    @Override
+                    Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+                        return findFun(env, name, argtypes, typeargtypes,
+                                phase.isBoxingRequired(),
+                                phase.isVarargsRequired());
+                    }});
     }
 
     /** Resolve a qualified method identifier
@@ -2313,36 +2394,36 @@
                               Type site,
                               List<Type> argtypes,
                               List<Type> typeargtypes) {
-        return lookupMethod(env, pos, site.tsym, new BasicLookupHelper(names.init, site, argtypes, typeargtypes) {
-            @Override
-            Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
-                return findDiamond(env, site, argtypes, typeargtypes,
-                        phase.isBoxingRequired(),
-                        phase.isVarargsRequired());
-            }
-            @Override
-            Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
-                if (sym.kind >= AMBIGUOUS) {
-                    final JCDiagnostic details = sym.kind == WRONG_MTH ?
-                                    ((InapplicableSymbolError)sym).errCandidate().details :
-                                    null;
-                    sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) {
-                        @Override
-                        JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos,
-                                Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
-                            String key = details == null ?
-                                "cant.apply.diamond" :
-                                "cant.apply.diamond.1";
-                            return diags.create(dkind, log.currentSource(), pos, key,
-                                    diags.fragment("diamond", site.tsym), details);
+        return lookupMethod(env, pos, site.tsym, resolveMethodCheck,
+                new BasicLookupHelper(names.init, site, argtypes, typeargtypes) {
+                    @Override
+                    Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+                        return findDiamond(env, site, argtypes, typeargtypes,
+                                phase.isBoxingRequired(),
+                                phase.isVarargsRequired());
+                    }
+                    @Override
+                    Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
+                        if (sym.kind >= AMBIGUOUS) {
+                            final JCDiagnostic details = sym.kind == WRONG_MTH ?
+                                            ((InapplicableSymbolError)sym).errCandidate().details :
+                                            null;
+                            sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) {
+                                @Override
+                                JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos,
+                                        Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
+                                    String key = details == null ?
+                                        "cant.apply.diamond" :
+                                        "cant.apply.diamond.1";
+                                    return diags.create(dkind, log.currentSource(), pos, key,
+                                            diags.fragment("diamond", site.tsym), details);
+                                }
+                            };
+                            sym = accessMethod(sym, pos, site, names.init, true, argtypes, typeargtypes);
+                            env.info.pendingResolutionPhase = currentResolutionContext.step;
                         }
-                    };
-                    sym = accessMethod(sym, pos, site, names.init, true, argtypes, typeargtypes);
-                    env.info.pendingResolutionPhase = currentResolutionContext.step;
-                }
-                return sym;
-            }
-        });
+                        return sym;
+                    }});
     }
 
     /** This method scans all the constructor symbol in a given class scope -
@@ -2475,7 +2556,8 @@
                                   Type site,
                                   Name name, List<Type> argtypes,
                                   List<Type> typeargtypes,
-                                  boolean boxingAllowed) {
+                                  boolean boxingAllowed,
+                                  MethodCheck methodCheck) {
         MethodResolutionPhase maxPhase = boxingAllowed ? VARARITY : BASIC;
 
         ReferenceLookupHelper boundLookupHelper;
@@ -2495,12 +2577,12 @@
 
         //step 1 - bound lookup
         Env<AttrContext> boundEnv = env.dup(env.tree, env.info.dup());
-        Symbol boundSym = lookupMethod(boundEnv, env.tree.pos(), site.tsym, boundLookupHelper);
+        Symbol boundSym = lookupMethod(boundEnv, env.tree.pos(), site.tsym, methodCheck, boundLookupHelper);
 
         //step 2 - unbound lookup
         ReferenceLookupHelper unboundLookupHelper = boundLookupHelper.unboundLookup();
         Env<AttrContext> unboundEnv = env.dup(env.tree, env.info.dup());
-        Symbol unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym, unboundLookupHelper);
+        Symbol unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym, methodCheck, unboundLookupHelper);
 
         //merge results
         Pair<Symbol, ReferenceLookupHelper> res;
@@ -2671,7 +2753,7 @@
         ReferenceLookupHelper unboundLookup() {
             if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
                     argtypes.nonEmpty() &&
-                    types.isSubtypeUnchecked(argtypes.head, site)) {
+                    (argtypes.head.hasTag(NONE) || types.isSubtypeUnchecked(argtypes.head, site))) {
                 return new UnboundMethodReferenceLookupHelper(referenceTree, name,
                         site, argtypes, typeargtypes, maxPhase);
             } else {
@@ -2704,8 +2786,8 @@
         UnboundMethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
                 List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
             super(referenceTree, name, site, argtypes.tail, typeargtypes, maxPhase);
-            Type asSuperSite = types.asSuper(argtypes.head, site.tsym);
-            if (site.isRaw() && !asSuperSite.isErroneous()) {
+            if (site.isRaw() && !argtypes.head.hasTag(NONE)) {
+                Type asSuperSite = types.asSuper(argtypes.head, site.tsym);
                 this.site = asSuperSite;
             }
         }
@@ -2800,8 +2882,10 @@
      * at the end of the lookup, the helper is used to validate the results
      * (this last step might trigger overload resolution diagnostics).
      */
-    Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, LookupHelper lookupHelper) {
-        return lookupMethod(env, pos, location, new MethodResolutionContext(), lookupHelper);
+    Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, MethodCheck methodCheck, LookupHelper lookupHelper) {
+        MethodResolutionContext resolveContext = new MethodResolutionContext();
+        resolveContext.methodCheck = methodCheck;
+        return lookupMethod(env, pos, location, resolveContext, lookupHelper);
     }
 
     Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location,
@@ -3595,6 +3679,8 @@
 
         MethodResolutionPhase step = null;
 
+        MethodCheck methodCheck = resolveMethodCheck;
+
         private boolean internalResolution = false;
         private DeferredAttr.AttrMode attrMode = DeferredAttr.AttrMode.SPECULATIVE;
 
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Wed Apr 10 12:50:05 2013 -0700
@@ -470,7 +470,15 @@
     public void emitInvokedynamic(int desc, Type mtype) {
         // N.B. this format is under consideration by the JSR 292 EG
         int argsize = width(mtype.getParameterTypes());
-        emitop(invokedynamic);
+        int prevPos = pendingStatPos;
+        try {
+            //disable line number generation (we could have used 'emit1', that
+            //bypasses stackmap generation - which is needed for indy calls)
+            pendingStatPos = Position.NOPOS;
+            emitop(invokedynamic);
+        } finally {
+            pendingStatPos = prevPos;
+        }
         if (!alive) return;
         emit2(desc);
         emit2(0);
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Wed Apr 10 12:50:05 2013 -0700
@@ -1775,10 +1775,13 @@
         // Generate code for all arguments, where the expected types are
         // the parameters of the method's external type (that is, any implicit
         // outer instance of a super(...) call appears as first parameter).
+        MethodSymbol msym = (MethodSymbol)TreeInfo.symbol(tree.meth);
         genArgs(tree.args,
-                TreeInfo.symbol(tree.meth).externalType(types).getParameterTypes());
-        code.statBegin(tree.pos);
-        code.markStatBegin();
+                msym.externalType(types).getParameterTypes());
+        if (!msym.isDynamic()) {
+            code.statBegin(tree.pos);
+            code.markStatBegin();
+        }
         result = m.invoke();
     }
 
--- a/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Wed Apr 10 12:50:05 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -770,7 +770,7 @@
     * (which is treated as the beginning of the first line).
     * Stops positioned at the closing '/'.
     */
-    protected class BasicComment<U extends UnicodeReader> implements Comment {
+    protected static class BasicComment<U extends UnicodeReader> implements Comment {
 
         CommentStyle cs;
         U comment_reader;
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed Apr 10 12:50:05 2013 -0700
@@ -171,8 +171,8 @@
 
     protected AbstractEndPosTable newEndPosTable(boolean keepEndPositions) {
         return  keepEndPositions
-                ? new SimpleEndPosTable()
-                : new EmptyEndPosTable();
+                ? new SimpleEndPosTable(this)
+                : new EmptyEndPosTable(this);
     }
 
     protected DocCommentTable newDocCommentTable(boolean keepDocComments, ParserFactory fac) {
@@ -3113,6 +3113,7 @@
             toplevel.docComments = docComments;
         if (keepLineMap)
             toplevel.lineMap = S.getLineMap();
+        this.endPosTable.setParser(null); // remove reference to parser
         toplevel.endPositions = this.endPosTable;
         return toplevel;
     }
@@ -4028,11 +4029,12 @@
     /*
      * a functional source tree and end position mappings
      */
-    protected class SimpleEndPosTable extends AbstractEndPosTable {
+    protected static class SimpleEndPosTable extends AbstractEndPosTable {
 
         private final Map<JCTree, Integer> endPosMap;
 
-        SimpleEndPosTable() {
+        SimpleEndPosTable(JavacParser parser) {
+            super(parser);
             endPosMap = new HashMap<JCTree, Integer>();
         }
 
@@ -4041,12 +4043,12 @@
         }
 
         protected <T extends JCTree> T to(T t) {
-            storeEnd(t, token.endPos);
+            storeEnd(t, parser.token.endPos);
             return t;
         }
 
         protected <T extends JCTree> T toP(T t) {
-            storeEnd(t, S.prevToken().endPos);
+            storeEnd(t, parser.S.prevToken().endPos);
             return t;
         }
 
@@ -4068,7 +4070,11 @@
     /*
      * a default skeletal implementation without any mapping overhead.
      */
-    protected class EmptyEndPosTable extends AbstractEndPosTable {
+    protected static class EmptyEndPosTable extends AbstractEndPosTable {
+
+        EmptyEndPosTable(JavacParser parser) {
+            super(parser);
+        }
 
         protected void storeEnd(JCTree tree, int endpos) { /* empty */ }
 
@@ -4090,13 +4096,21 @@
 
     }
 
-    protected abstract class AbstractEndPosTable implements EndPosTable {
+    protected static abstract class AbstractEndPosTable implements EndPosTable {
+        /**
+         * The current parser.
+         */
+        protected JavacParser parser;
 
         /**
          * Store the last error position.
          */
         protected int errorEndPos;
 
+        public AbstractEndPosTable(JavacParser parser) {
+            this.parser = parser;
+        }
+
         /**
          * Store ending position for a tree, the value of which is the greater
          * of last error position and the given ending position.
@@ -4131,5 +4145,9 @@
                 errorEndPos = errPos;
             }
         }
+
+        protected void setParser(JavacParser parser) {
+            this.parser = parser;
+        }
     }
 }
--- a/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Wed Apr 10 12:50:05 2013 -0700
@@ -206,7 +206,7 @@
          }
      }
 
-     protected class JavadocComment extends JavaTokenizer.BasicComment<DocReader> {
+     protected static class JavadocComment extends JavaTokenizer.BasicComment<DocReader> {
 
         /**
         * Translated and stripped contents of doc comment
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Apr 10 12:50:05 2013 -0700
@@ -216,9 +216,14 @@
 compiler.misc.no.suitable.functional.intf.inst=\
     cannot infer functional interface descriptor for {0}
 
+# 0: message segment
+compiler.misc.bad.intersection.target.for.functional.expr=\
+    bad intersection type target for lambda or method reference\n\
+    {0}
+
 # 0: type
-compiler.misc.secondary.bound.must.be.marker.intf=\
-    secondary bound {0} must be a marker interface
+compiler.misc.not.an.intf.component=\
+    component type {0} is not an interface
 
 # 0: symbol kind, 1: message segment
 compiler.err.invalid.mref=\
@@ -731,6 +736,11 @@
 compiler.misc.incompatible.arg.types.in.mref=\
     incompatible parameter types in method reference
 
+# 0: list of type
+compiler.misc.bad.arg.types.in.lambda=\
+    cannot type-check lambda expression with inferred parameter types\n\
+    inferred types: {0}
+
 compiler.err.new.not.allowed.in.annotation=\
     ''new'' not allowed in an annotation
 
--- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Wed Apr 10 12:50:05 2013 -0700
@@ -395,6 +395,9 @@
 
         @Override
         public String visitClassSymbol(ClassSymbol s, Locale locale) {
+            if (s.type.isCompound()) {
+                return visit(s.type, locale);
+            }
             String name = nameSimplifier.simplify(s);
             if (name.length() == 0 ||
                     !getConfiguration().isEnabled(RichFormatterFeature.SIMPLE_NAMES)) {
@@ -583,7 +586,11 @@
 
         @Override
         public Void visitClassSymbol(ClassSymbol s, Void ignored) {
-            nameSimplifier.addUsage(s);
+            if (s.type.isCompound()) {
+                typePreprocessor.visit(s.type);
+            } else {
+                nameSimplifier.addUsage(s);
+            }
             return null;
         }
 
--- a/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Wed Apr 10 12:50:05 2013 -0700
@@ -199,6 +199,17 @@
         return result;
     }
 
+    /**
+     * Get the receiver type of this executable element.
+     *
+     * @return the receiver type of this executable element.
+     * @since 1.8
+     */
+    public com.sun.javadoc.Type receiverType() {
+        Type recvtype = sym.type.asMethodType().recvtype;
+        return (recvtype != null) ? TypeMaker.getType(env, recvtype, false, true) : null;
+    }
+
     public AnnotationDesc[] receiverAnnotations() {
         // TODO: change how receiver annotations are output!
         Type recvtype = sym.type.asMethodType().recvtype;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,259 @@
+/*
+ * 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      8005091
+ * @summary  Make sure that type annotations are displayed correctly
+ * @author   Bhavesh Patel
+ * @library  ../lib/
+ * @build    JavadocTester TestTypeAnnotations
+ * @run main TestTypeAnnotations
+ */
+
+public class TestTypeAnnotations extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8005091";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-private", "typeannos"
+    };
+
+    //Input for string search tests.
+    private static final String[][] NEGATED_TEST = NO_TEST;
+    private static final String[][] TEST = {
+        // Test for type annotations on Class Extends (ClassExtends.java).
+        {BUG_ID + FS + "typeannos" + FS + "MyClass.html",
+            "implements <a href=\"../typeannos/ClassExtB.html\" title=\"" +
+            "annotation in typeannos\">@ClassExtB</a> java.lang.CharSequence, " +
+            "<a href=\"../typeannos/ParameterizedInterface.html\" title=\"" +
+            "interface in typeannos\">ParameterizedInterface</a>&lt;java.lang.String&gt;</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "MyInterface.html",
+            "extends <a href=\"../typeannos/ParameterizedInterface.html\" title" +
+            "=\"interface in typeannos\">ParameterizedInterface</a>&lt;java." +
+            "lang.String&gt;, <a href=\"../typeannos/ClassExtB.html\" title=\"" +
+            "annotation in typeannos\">@ClassExtB</a> java.lang.CharSequence</pre>"
+        },
+
+        // Test for type annotations on Class Parameters (ClassParameters.java).
+        {BUG_ID + FS + "typeannos" + FS + "ExtendsBound.html",
+            "class <span class=\"strong\">ExtendsBound&lt;K extends <a " +
+            "href=\"../typeannos/ClassParamA.html\" title=\"annotation in " +
+            "typeannos\">@ClassParamA</a> java.lang.String&gt;</span>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "TwoBounds.html",
+            "class <span class=\"strong\">TwoBounds&lt;K extends <a href=\"" +
+            "../typeannos/ClassParamA.html\" title=\"annotation in typeannos\">" +
+            "@ClassParamA</a> java.lang.String,V extends <a href=\"../typeannos" +
+            "/ClassParamB.html\" title=\"annotation in typeannos\">@ClassParamB" +
+            "</a> java.lang.String&gt;</span>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "Complex1.html",
+            "class <span class=\"strong\">Complex1&lt;K extends <a href=\"../" +
+            "typeannos/ClassParamA.html\" title=\"annotation in typeannos\">" +
+            "@ClassParamA</a> java.lang.String & java.lang.Runnable&gt;</span>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "Complex2.html",
+            "class <span class=\"strong\">Complex2&lt;K extends java.lang." +
+            "String & <a href=\"../typeannos/ClassParamB.html\" title=\"" +
+            "annotation in typeannos\">@ClassParamB</a> java.lang.Runnable&gt;</span>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ComplexBoth.html",
+            "class <span class=\"strong\">ComplexBoth&lt;K extends <a href=\"" +
+            "../typeannos/ClassParamA.html\" title=\"annotation in typeannos\"" +
+            ">@ClassParamA</a> java.lang.String & <a href=\"../typeannos/" +
+            "ClassParamA.html\" title=\"annotation in typeannos\">@ClassParamA" +
+            "</a> java.lang.Runnable&gt;</span>"
+        },
+
+        // Test for type annotations on method return types (MethodReturnType.java).
+        {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html",
+            "<pre>public&nbsp;&lt;T&gt;&nbsp;<a href=\"../typeannos/MRtnA.html\" " +
+            "title=\"annotation in typeannos\">@MRtnA</a> java.lang.String" +
+            "&nbsp;method()</pre>"
+        },
+
+        // Test for type annotations on method type parameters (MethodTypeParameters.java).
+        {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html",
+            "<pre>&lt;K extends <a href=\"../typeannos/MTyParamA.html\" title=\"" +
+            "annotation in typeannos\">@MTyParamA</a> java.lang.String&gt;" +
+            "&nbsp;void&nbsp;methodExtends()</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html",
+            "<pre>public final&nbsp;&lt;K extends <a href=\"../typeannos/" +
+            "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> " +
+            "java.lang.String&gt;&nbsp;void&nbsp;methodExtends()</pre>"
+        },
+
+        // Test for type annotations on throws (Throws.java).
+        {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html",
+            "<pre>void&nbsp;oneException()" + NL +
+            "            throws <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html",
+            "<pre>void&nbsp;twoExceptions()" + NL +
+            "             throws <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "annotation in typeannos\">@ThrA</a> java.lang.RuntimeException," + NL +
+            "                    <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html",
+            "<pre>public final&nbsp;void&nbsp;oneException(java.lang.String&nbsp;a)" + NL +
+            "                        throws <a href=\"../typeannos/ThrA.html\" " +
+            "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html",
+            "<pre>public final&nbsp;void&nbsp;twoExceptions(java.lang.String&nbsp;a)" + NL +
+            "                         throws <a href=\"../typeannos/ThrA.html\" " +
+            "title=\"annotation in typeannos\">@ThrA</a> java.lang.RuntimeException," + NL +
+            "                                <a href=\"../typeannos/ThrA.html\" " +
+            "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html",
+            "<pre>void&nbsp;oneException()" + NL +
+            "            throws <a href=\"../typeannos/ThrB.html\" title=\"" +
+            "annotation in typeannos\">@ThrB</a>(<a href=\"../typeannos/" +
+            "ThrB.html#value()\">value</a>=\"m\") java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html",
+            "<pre>void&nbsp;twoExceptions()" + NL +
+            "             throws <a href=\"../typeannos/ThrB.html\" title=\"" +
+            "annotation in typeannos\">@ThrB</a>(<a href=\"../typeannos/" +
+            "ThrB.html#value()\">value</a>=\"m\") java.lang.RuntimeException," + NL +
+            "                    <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
+        },
+
+        // Test for type annotations on wildcard type (Wildcards.java).
+        {BUG_ID + FS + "typeannos" + FS + "BoundTest.html",
+            "<pre>void&nbsp;wcExtends(<a href=\"../typeannos/MyList.html\" " +
+            "title=\"class in typeannos\">MyList</a>&lt;? extends <a href=\"" +
+            "../typeannos/WldA.html\" title=\"annotation in typeannos\">@WldA" +
+            "</a> java.lang.String&gt;&nbsp;l)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "BoundTest.html",
+            "<pre><a href=\"../typeannos/MyList.html\" title=\"class in " +
+            "typeannos\">MyList</a>&lt;? super <a href=\"../typeannos/WldA.html\" " +
+            "title=\"annotation in typeannos\">@WldA</a> java.lang.String&gt;" +
+            "&nbsp;returnWcSuper()</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html",
+            "<pre>void&nbsp;wcSuper(<a href=\"../typeannos/MyList.html\" title=\"" +
+            "class in typeannos\">MyList</a>&lt;? super <a href=\"../typeannos/" +
+            "WldB.html\" title=\"annotation in typeannos\">@WldB</a>(<a href=\"" +
+            "../typeannos/WldB.html#value()\">value</a>=\"m\") java.lang." +
+            "String&gt;&nbsp;l)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html",
+            "<pre><a href=\"../typeannos/MyList.html\" title=\"class in " +
+            "typeannos\">MyList</a>&lt;? extends <a href=\"../typeannos/WldB." +
+            "html\" title=\"annotation in typeannos\">@WldB</a>(<a href=\"../" +
+            "typeannos/WldB.html#value()\">value</a>=\"m\") java.lang.String" +
+            "&gt;&nbsp;returnWcExtends()</pre>"
+        },
+
+        // Test for receiver annotations (Receivers.java).
+        {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
+            "<pre>void&nbsp;withException(<a href=\"../typeannos/RcvrA.html\" " +
+            "title=\"annotation in typeannos\">@RcvrA</a>&nbsp;" +
+            "DefaultUnmodified&nbsp;this)" + NL + "             throws java." +
+            "lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
+            "<pre>java.lang.String&nbsp;nonVoid(<a href=\"../typeannos/RcvrA." +
+            "html\" title=\"annotation in typeannos\">@RcvrA</a> <a href=\"../" +
+            "typeannos/RcvrB.html\" title=\"annotation in typeannos\">@RcvrB" +
+            "</a>(<a href=\"../typeannos/RcvrB.html#value()\">value</a>=\"m\")" +
+            "&nbsp;DefaultUnmodified&nbsp;this)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
+            "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept(" +
+            "<a href=\"../typeannos/RcvrA.html\" title=\"annotation in " +
+            "typeannos\">@RcvrA</a>&nbsp;DefaultUnmodified&nbsp;this," + NL +
+            "                                         T&nbsp;r)" + NL +
+            "      throws java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "PublicModified.html",
+            "<pre>public final&nbsp;java.lang.String&nbsp;nonVoid(<a href=\"" +
+            "../typeannos/RcvrA.html\" title=\"annotation in typeannos\">" +
+            "@RcvrA</a>&nbsp;PublicModified&nbsp;this)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "PublicModified.html",
+            "<pre>public final&nbsp;&lt;T extends java.lang.Runnable&gt;&nbsp;" +
+            "void&nbsp;accept(<a href=\"../typeannos/RcvrA.html\" title=\"" +
+            "annotation in typeannos\">@RcvrA</a>&nbsp;PublicModified&nbsp;this," + NL +
+            "                                         T&nbsp;r)" + NL +
+            "                  throws java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "WithValue.html",
+            "<pre>&lt;T extends java.lang.Runnable&gt;&nbsp;void&nbsp;accept(" +
+            "<a href=\"../typeannos/RcvrB.html\" title=\"annotation in " +
+            "typeannos\">@RcvrB</a>(<a href=\"../typeannos/RcvrB.html#value()\">" +
+            "value</a>=\"m\")&nbsp;WithValue&nbsp;this," + NL +
+            "                                         T&nbsp;r)" + NL +
+            "      throws java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "WithFinal.html",
+            "<pre>java.lang.String&nbsp;nonVoid(<a href=\"../typeannos/RcvrB." +
+            "html\" title=\"annotation in typeannos\">@RcvrB</a>(<a href=\"../" +
+            "typeannos/RcvrB.html#value()\">value</a>=\"m\")&nbsp;WithFinal" +
+            "&nbsp;this)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "WithBody.html",
+            "<pre>void&nbsp;field(<a href=\"../typeannos/RcvrA.html\" title=\"" +
+            "annotation in typeannos\">@RcvrA</a>&nbsp;WithBody&nbsp;this)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "Generic2.html",
+            "<pre>void&nbsp;test2(<a href=\"../typeannos/RcvrA.html\" title=\"" +
+            "annotation in typeannos\">@RcvrA</a>&nbsp;Generic2&lt;X&gt;&nbsp;this)</pre>"
+        }
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestTypeAnnotations tester = new TestTypeAnnotations();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/ClassExtends.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,45 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+abstract class MyClass extends @ClassExtA ParameterizedClass<@ClassExtB String>
+  implements @ClassExtB CharSequence, @ClassExtA ParameterizedInterface<@ClassExtB String> { }
+
+interface MyInterface extends @ClassExtA ParameterizedInterface<@ClassExtA String>,
+                              @ClassExtB CharSequence { }
+
+class ParameterizedClass<K> {}
+interface ParameterizedInterface<K> {}
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface ClassExtA {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface ClassExtB {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/ClassParameters.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,60 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class Unannotated<K> { }
+
+class ExtendsBound<K extends @ClassParamA String> { }
+class ExtendsGeneric<K extends @ClassParamA Unannotated<@ClassParamB String>> { }
+class TwoBounds<K extends @ClassParamA String, V extends @ClassParamB String> { }
+
+class Complex1<K extends @ClassParamA String&Runnable> { }
+class Complex2<K extends String & @ClassParamB Runnable> { }
+class ComplexBoth<K extends @ClassParamA String & @ClassParamA Runnable> { }
+
+class ClassParamOuter {
+    void inner() {
+        class LUnannotated<K> { }
+
+        class LExtendsBound<K extends @ClassParamA String> { }
+        class LExtendsGeneric<K extends @ClassParamA LUnannotated<@ClassParamB String>> { }
+        class LTwoBounds<K extends @ClassParamA String, V extends @ClassParamB String> { }
+
+        class LComplex1<K extends @ClassParamA String&Runnable> { }
+        class LComplex2<K extends String & @ClassParamB Runnable> { }
+        class LComplexBoth<K extends @ClassParamA String & @ClassParamA Runnable> { }
+    }
+}
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface ClassParamA { }
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface ClassParamB { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Fields.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,76 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class DefaultScope {
+    Parameterized<String, String> unannotated;
+    Parameterized<@FldA String, String> firstTypeArg;
+    Parameterized<String, @FldA String> secondTypeArg;
+    Parameterized<@FldA String, @FldB String> bothTypeArgs;
+
+    Parameterized<@FldA Parameterized<@FldA String, @FldB String>, @FldB String>
+    nestedParameterized;
+
+    @FldA String [] array1;
+    @FldA String @FldB [] array1Deep;
+    @FldA String [] [] array2;
+    @FldA String @FldA [] @FldB [] array2Deep;
+    String @FldA [] [] array2First;
+    String [] @FldB [] array2Second;
+
+    // Old-style array syntax
+    String array2FirstOld @FldA [];
+    String array2SecondOld [] @FldB [];
+}
+
+class ModifiedScoped {
+    public final Parameterized<String, String> unannotated = null;
+    public final Parameterized<@FldA String, String> firstTypeArg = null;
+    public final Parameterized<String, @FldA String> secondTypeArg = null;
+    public final Parameterized<@FldA String, @FldB String> bothTypeArgs = null;
+
+    public final Parameterized<@FldA Parameterized<@FldA String, @FldB String>, @FldB String>
+    nestedParameterized = null;
+
+    public final @FldA String [] array1 = null;
+    public final @FldA String @FldB [] array1Deep = null;
+    public final @FldA String [] [] array2 = null;
+    public final @FldA String @FldA [] @FldB [] array2Deep = null;
+    public final String @FldA [] [] array2First = null;
+    public final String [] @FldB [] array2Second = null;
+}
+
+class Parameterized<K, V> { }
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface FldA { }
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface FldB { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/MethodReturnType.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,78 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class MtdDefaultScope {
+    MtdParameterized<String, String> unannotated() { return null; }
+    MtdParameterized<@MRtnA String, String> firstTypeArg() { return null; }
+    MtdParameterized<String, @MRtnA String> secondTypeArg() { return null; }
+    MtdParameterized<@MRtnA String, @MRtnB String> bothTypeArgs() { return null; }
+
+    MtdParameterized<@MRtnA MtdParameterized<@MRtnA String, @MRtnB String>, @MRtnB String>
+    nestedMtdParameterized() { return null; }
+
+    public <T> @MRtnA String method() { return null; }
+
+    @MRtnA String [] array1() { return null; }
+    @MRtnA String @MRtnB [] array1Deep() { return null; }
+    @MRtnA String [] [] array2() { return null; }
+    @MRtnA String @MRtnA [] @MRtnB [] array2Deep() { return null; }
+    String @MRtnA [] [] array2First() { return null; }
+    String [] @MRtnB [] array2Second() { return null; }
+
+    // Old-style array syntax
+    String array2FirstOld() @MRtnA [] { return null; }
+    String array2SecondOld() [] @MRtnB [] { return null; }
+}
+
+class MtdModifiedScoped {
+    public final MtdParameterized<String, String> unannotated() { return null; }
+    public final MtdParameterized<@MRtnA String, String> firstTypeArg() { return null; }
+    public final MtdParameterized<String, @MRtnA String> secondTypeArg() { return null; }
+    public final MtdParameterized<@MRtnA String, @MRtnB String> bothTypeArgs() { return null; }
+
+    public final MtdParameterized<@MRtnA MtdParameterized<@MRtnA String, @MRtnB String>, @MRtnB String>
+    nestedMtdParameterized() { return null; }
+
+    public final @MRtnA String [] array1() { return null; }
+    public final @MRtnA String @MRtnB [] array1Deep() { return null; }
+    public final @MRtnA String [] [] array2() { return null; }
+    public final @MRtnA String @MRtnA [] @MRtnB [] array2Deep() { return null; }
+    public final String @MRtnA [] [] array2First() { return null; }
+    public final String [] @MRtnB [] array2Second() { return null; }
+}
+
+class MtdParameterized<K, V> { }
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface MRtnA { }
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface MRtnB { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/MethodTypeParameters.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,52 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class UnscopedUnmodified {
+    <K extends @MTyParamA String> void methodExtends() {}
+    <K extends @MTyParamA MtdTyParameterized<@MTyParamB String>> void nestedExtends() {}
+    <K extends @MTyParamA String, V extends @MTyParamA MtdTyParameterized<@MTyParamB String>> void dual() {}
+    <K extends String, V extends MtdTyParameterized<@MTyParamB String>> void dualOneAnno() {}
+}
+
+class PublicModifiedMethods {
+    public final <K extends @MTyParamA String> void methodExtends() {}
+    public final <K extends @MTyParamA MtdTyParameterized<@MTyParamB String>> void nestedExtends() {}
+    public final <K extends @MTyParamA String, V extends @MTyParamA MtdTyParameterized<@MTyParamB String>> void dual() {}
+    public final <K extends String, V extends MtdTyParameterized<@MTyParamB String>> void dualOneAnno() {}
+}
+
+class MtdTyParameterized<K> { }
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface MTyParamA { }
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface MTyParamB { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Parameters.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class Parameters {
+    void unannotated(ParaParameterized<String, String> a) {}
+    void firstTypeArg(ParaParameterized<@ParamA String, String> a) {}
+    void secondTypeArg(ParaParameterized<String, @ParamA String> a) {}
+    void bothTypeArgs(ParaParameterized<@ParamA String, @ParamB String> both) {}
+
+    void nestedParaParameterized(ParaParameterized<@ParamA ParaParameterized<@ParamA String, @ParamB String>, @ParamB String> a) {}
+
+    void array1(@ParamA String [] a) {}
+    void array1Deep(@ParamA String @ParamB [] a) {}
+    void array2(@ParamA String [] [] a) {}
+    void array2Deep(@ParamA String @ParamA [] @ParamB [] a) {}
+    void array2First(String @ParamA [] [] a) {}
+    void array2Second(String [] @ParamB [] a) {}
+}
+
+class ParaParameterized<K, V> { }
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface ParamA { }
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface ParamB { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Receivers.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,131 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class DefaultUnmodified {
+    void plain(@RcvrA DefaultUnmodified this) { }
+    <T> void generic(@RcvrA DefaultUnmodified this) { }
+    void withException(@RcvrA DefaultUnmodified this) throws Exception { }
+    String nonVoid(@RcvrA @RcvrB("m") DefaultUnmodified this) { return null; }
+    <T extends Runnable> void accept(@RcvrA DefaultUnmodified this, T r) throws Exception { }
+}
+
+class PublicModified {
+    public final void plain(@RcvrA PublicModified this) { }
+    public final <T> void generic(@RcvrA PublicModified this) { }
+    public final void withException(@RcvrA PublicModified this) throws Exception { }
+    public final String nonVoid(@RcvrA PublicModified this) { return null; }
+    public final <T extends Runnable> void accept(@RcvrA PublicModified this, T r) throws Exception { }
+}
+
+class WithValue {
+    void plain(@RcvrB("m") WithValue this) { }
+    <T> void generic(@RcvrB("m") WithValue this) { }
+    void withException(@RcvrB("m") WithValue this) throws Exception { }
+    String nonVoid(@RcvrB("m") WithValue this) { return null; }
+    <T extends Runnable> void accept(@RcvrB("m") WithValue this, T r) throws Exception { }
+}
+
+class WithFinal {
+    void plain(final @RcvrB("m") WithFinal this) { }
+    <T> void generic(final @RcvrB("m") WithFinal this) { }
+    void withException(final @RcvrB("m") WithFinal this) throws Exception { }
+    String nonVoid(final @RcvrB("m") WithFinal this) { return null; }
+    <T extends Runnable> void accept(final @RcvrB("m") WithFinal this, T r) throws Exception { }
+}
+
+class WithBody {
+    Object f;
+
+    void field(@RcvrA WithBody this) {
+        this.f = null;
+    }
+    void meth(@RcvrA WithBody this) {
+        this.toString();
+    }
+}
+
+class Generic1<X> {
+    void test1(Generic1<X> this) {}
+    void test2(@RcvrA Generic1<X> this) {}
+    void test3(Generic1<@RcvrA X> this) {}
+    void test4(@RcvrA Generic1<@RcvrA X> this) {}
+}
+
+class Generic2<@RcvrA X> {
+    void test1(Generic2<X> this) {}
+    void test2(@RcvrA Generic2<X> this) {}
+    void test3(Generic2<@RcvrA X> this) {}
+    void test4(@RcvrA Generic2<@RcvrA X> this) {}
+}
+
+class Generic3<X extends @RcvrA Object> {
+    void test1(Generic3<X> this) {}
+    void test2(@RcvrA Generic3<X> this) {}
+    void test3(Generic3<@RcvrA X> this) {}
+    void test4(@RcvrA Generic3<@RcvrA X> this) {}
+}
+
+class Generic4<X extends @RcvrA Object> {
+    <Y> void test1(Generic4<X> this) {}
+    <Y> void test2(@RcvrA Generic4<X> this) {}
+    <Y> void test3(Generic4<@RcvrA X> this) {}
+    <Y> void test4(@RcvrA Generic4<@RcvrA X> this) {}
+}
+
+class Outer {
+    class Inner {
+        void none(Outer.Inner this) {}
+        void outer(@RcvrA Outer.Inner this) {}
+        void inner(Outer. @RcvrB("i") Inner this) {}
+        void both(@RcvrA Outer.@RcvrB("i") Inner this) {}
+
+        void innerOnlyNone(Inner this) {}
+        void innerOnly(@RcvrA Inner this) {}
+    }
+}
+
+class GenericOuter<S, T> {
+    class GenericInner<U, V> {
+        void none(GenericOuter<S, T>.GenericInner<U, V> this) {}
+        void outer(@RcvrA GenericOuter<S, T>.GenericInner<U, V> this) {}
+        void inner(GenericOuter<S, T>. @RcvrB("i") GenericInner<U, V> this) {}
+        void both(@RcvrA GenericOuter<S, T>.@RcvrB("i") GenericInner<U, V> this) {}
+
+        void innerOnlyNone(GenericInner<U, V> this) {}
+        void innerOnly(@RcvrA GenericInner<U, V> this) {}
+    }
+}
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface RcvrA {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface RcvrB { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Throws.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,51 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class ThrDefaultUnmodified {
+    void oneException() throws @ThrA Exception {}
+    void twoExceptions() throws @ThrA RuntimeException, @ThrA Exception {}
+}
+
+class ThrPublicModified {
+    public final void oneException(String a) throws @ThrA Exception {}
+    public final void twoExceptions(String a) throws @ThrA RuntimeException, @ThrA Exception {}
+}
+
+class ThrWithValue {
+    void oneException() throws @ThrB("m") Exception {}
+    void twoExceptions() throws @ThrB(value="m") RuntimeException, @ThrA Exception {}
+}
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface ThrA {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface ThrB { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/TypeParameters.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,60 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class TypUnannotated<K> { }
+class OneAnnotated<@TyParaA K> { }
+class TwoAnnotated<@TyParaA K, @TyParaA V> { }
+class SecondAnnotated<K, @TyParaA V extends String> { }
+
+class TestMethods {
+    <K> void unannotated() { }
+    <@TyParaA K> void oneAnnotated() { }
+    <@TyParaA K, @TyParaB("m") V> void twoAnnotated() { }
+    <K, @TyParaA V extends @TyParaA String> void secondAnnotated() { }
+}
+
+class UnannotatedB<K> { }
+class OneAnnotatedB<@TyParaB("m") K> { }
+class TwoAnnotatedB<@TyParaB("m") K, @TyParaB("m") V> { }
+class SecondAnnotatedB<K, @TyParaB("m") V extends @TyParaB("m") String> { }
+
+class OneAnnotatedC<@TyParaC K> { }
+class TwoAnnotatedC<@TyParaC K, @TyParaC V> { }
+class SecondAnnotatedC<K, @TyParaC V extends String> { }
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface TyParaA { }
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface TyParaB { String value(); }
+@Target(ElementType.TYPE_USE)
+@Documented
+@interface TyParaC { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Varargs.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,42 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface VarArgA {}
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class Varargs {
+
+    // Handle annotations on a varargs element type
+    void varargPlain(Object @VarArgA... objs) {
+    }
+
+    void varargGeneric(Class<?> @VarArgA ... clz) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Wildcards.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,74 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class BoundTest {
+    void wcExtends(MyList<? extends @WldA String> l) { }
+    void wcSuper(MyList<? super @WldA String> l) { }
+
+    MyList<? extends @WldA String> returnWcExtends() { return null; }
+    MyList<? super @WldA String> returnWcSuper() { return null; }
+    MyList<? extends @WldA MyList<? super @WldB("m") String>> complex() { return null; }
+}
+
+class BoundWithValue {
+    void wcExtends(MyList<? extends @WldB("m") String> l) { }
+    void wcSuper(MyList<? super @WldB(value="m") String> l) { }
+
+    MyList<? extends @WldB("m") String> returnWcExtends() { return null; }
+    MyList<? super @WldB(value="m") String> returnWcSuper() { return null; }
+    MyList<? extends @WldB("m") MyList<? super @WldB("m") String>> complex() { return null; }
+}
+
+class SelfTest {
+    void wcExtends(MyList<@WldA ?> l) { }
+    void wcSuper(MyList<@WldA ?> l) { }
+
+    MyList<@WldA ?> returnWcExtends() { return null; }
+    MyList<@WldA ?> returnWcSuper() { return null; }
+    MyList<@WldA ? extends @WldA MyList<@WldB("m") ?>> complex() { return null; }
+}
+
+class SelfWithValue {
+    void wcExtends(MyList<@WldB("m") ?> l) { }
+    void wcSuper(MyList<@WldB(value="m") ?> l) { }
+
+    MyList<@WldB("m") ?> returnWcExtends() { return null; }
+    MyList<@WldB(value="m") ?> returnWcSuper() { return null; }
+    MyList<@WldB("m") ? extends MyList<@WldB("m") ? super String>> complex() { return null; }
+}
+
+class MyList<K> { }
+
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface WldA { }
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@Documented
+@interface WldB { String value(); }
--- a/test/tools/javac/T5053846/MethodRefDupInConstantPoolTest.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/test/tools/javac/T5053846/MethodRefDupInConstantPoolTest.java	Wed Apr 10 12:50:05 2013 -0700
@@ -23,8 +23,9 @@
 
 /*
  * @test
- * @bug 5053846
+ * @bug 5053846 8011432
  * @summary javac: MethodRef entries are duplicated in the constant pool
+ * @summary javac, compiler regression iterable + captured type
  */
 
 import java.io.PrintWriter;
@@ -43,9 +44,13 @@
 
     void run() {
         check("-v", Paths.get(System.getProperty("test.classes"),
-                "TestHelper1.class").toString());
+                this.getClass().getSimpleName() + "$TestHelper1.class").toString());
         check("-v", Paths.get(System.getProperty("test.classes"),
-                "TestHelper2.class").toString());
+                this.getClass().getSimpleName() + "$TestHelper2.class").toString());
+        check("-v", Paths.get(System.getProperty("test.classes"),
+                this.getClass().getSimpleName() + "$TestHelper3.class").toString());
+        check("-v", Paths.get(System.getProperty("test.classes"),
+                this.getClass().getSimpleName() + "$TestHelper4.class").toString());
     }
 
     void check(String... params) {
@@ -68,24 +73,38 @@
         int end = out.indexOf("{");
         return out.substring(start, end);
     }
-}
 
-class TestHelper1 {
-    void m() {
-        Vector v = new Vector();
-        Iterator iter = v.iterator();
-        while (iter.hasNext()) {
-            Object o = iter.next();
-            Object o2 = o;
-        }
-        for (Object o: v) {
-            Object o2 = o;
+    class TestHelper1 {
+        void m() {
+            Vector v = new Vector();
+            Iterator iter = v.iterator();
+            while (iter.hasNext()) {
+                Object o = iter.next();
+                Object o2 = o;
+            }
+            for (Object o: v) {
+                Object o2 = o;
+            }
         }
     }
-}
 
-class TestHelper2<X extends Number & Iterable<String>> {
-    void test(X x) {
-        for (String s : x) { }
+    class TestHelper2<X extends Number & Iterable<String>> {
+        void test(X x) {
+            for (String s : x) { }
+        }
+    }
+
+    interface Data extends Iterable<String> {}
+
+    class TestHelper3<X extends Number & Iterable<? extends Data>> {
+        void test(X x) {
+            for (Data s : x) { }
+        }
+    }
+
+    class TestHelper4 {
+         void test(Iterable<? extends Data> t) {
+             for(Object a: t.iterator().next());
+         }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/BadArgTypesInLambda.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol
+// key: compiler.misc.no.conforming.assignment.exists
+// key: compiler.misc.bad.arg.types.in.lambda
+
+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/diags/examples/NotAnInterfaceComponent.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,30 @@
+/*
+ * 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.bad.intersection.target.for.functional.expr
+// key: compiler.misc.not.an.intf.component
+
+class NotAnInterfaceComponent {
+    Object o = (Object & Runnable) ()-> { };
+}
--- a/test/tools/javac/diags/examples/SecondaryBoundMustBeMarkerIntf.java	Thu Apr 04 17:44:59 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.prob.found.req
-// key: compiler.misc.secondary.bound.must.be.marker.intf
-
-class SecondaryBoundMustBeMarkerInterface {
-    Runnable r = (Runnable & Comparable<?>)()->{};
-}
--- a/test/tools/javac/lambda/BadRecovery.out	Thu Apr 04 17:44:59 2013 -0700
+++ b/test/tools/javac/lambda/BadRecovery.out	Wed Apr 10 12:50:05 2013 -0700
@@ -1,3 +1,2 @@
-BadRecovery.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, BadRecovery.SAM1, @369, kindname.class, BadRecovery, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))
 BadRecovery.java:17:77: compiler.err.cant.resolve.location: kindname.variable, f, , , (compiler.misc.location: kindname.class, BadRecovery, null)
-2 errors
+1 error
--- a/test/tools/javac/lambda/Intersection01.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/test/tools/javac/lambda/Intersection01.java	Wed Apr 10 12:50:05 2013 -0700
@@ -25,7 +25,7 @@
  * @test
  * @bug 8002099
  * @summary Add support for intersection types in cast expression
- * @compile/fail/ref=Intersection01.out -XDrawDiagnostics Intersection01.java
+ * @compile Intersection01.java
  */
 class Intersection01 {
 
--- a/test/tools/javac/lambda/Intersection01.out	Thu Apr 04 17:44:59 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-Intersection01.java:36:45: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: java.io.Serializable, (compiler.misc.no.abstracts: kindname.interface, java.io.Serializable))
-Intersection01.java:38:45: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: java.io.Serializable, (compiler.misc.no.abstracts: kindname.interface, java.io.Serializable))
-2 errors
--- a/test/tools/javac/lambda/TargetType01.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/test/tools/javac/lambda/TargetType01.java	Wed Apr 10 12:50:05 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -23,11 +23,10 @@
 
 /*
  * @test
- * @bug 8003280
+ * @bug 8003280 8009131
  * @summary Add lambda tests
  *  check nested case of overload resolution and lambda parameter inference
- * @author  Maurizio Cimadamore
- * @compile/fail/ref=TargetType01.out -XDrawDiagnostics TargetType01.java
+ * @compile TargetType01.java
  */
 
 class TargetType01 {
--- a/test/tools/javac/lambda/TargetType01.out	Thu Apr 04 17:44:59 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-TargetType01.java:46:9: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01
-TargetType01.java:46:26: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01
-2 errors
--- a/test/tools/javac/lambda/TargetType43.out	Thu Apr 04 17:44:59 2013 -0700
+++ b/test/tools/javac/lambda/TargetType43.out	Wed Apr 10 12:50:05 2013 -0700
@@ -1,5 +1,4 @@
 TargetType43.java:13:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
 TargetType43.java:13:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
-TargetType43.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Object, @359, kindname.class, TargetType43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: java.lang.Object))
 TargetType43.java:14:21: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
-4 errors
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/TargetType66.java	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8009131
+ * @summary Overload: javac should discard methods that lead to errors in lambdas with implicit parameter types
+ * @compile/fail/ref=TargetType66.out -XDrawDiagnostics TargetType66.java
+ */
+class TargetType66 {
+    interface SAM1 {
+        void m(String s);
+    }
+
+    interface SAM2 {
+        void m(Integer s);
+    }
+
+    void g(SAM1 s1) { }
+    void g(SAM2 s2) { }
+
+    void test() {
+        g(x->{ String s = x; }); //g(SAM1)
+        g(x->{ Integer i = x; }); //g(SAM2)
+        g(x->{ Object o = x; }); //ambiguous
+        g(x->{ Character c = x; }); //error: inapplicable methods
+        g(x->{ Character c = ""; }); //error: incompatible types
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/TargetType66.out	Wed Apr 10 12:50:05 2013 -0700
@@ -0,0 +1,4 @@
+TargetType66.java:22:9: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType66.SAM1), TargetType66, kindname.method, g(TargetType66.SAM2), TargetType66
+TargetType66.java:23:9: compiler.err.cant.apply.symbols: kindname.method, g, @578,{(compiler.misc.inapplicable.method: kindname.method, TargetType66, g(TargetType66.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.bad.arg.types.in.lambda: java.lang.String))),(compiler.misc.inapplicable.method: kindname.method, TargetType66, g(TargetType66.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.bad.arg.types.in.lambda: java.lang.Integer)))}
+TargetType66.java:24:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Character)
+3 errors
--- a/test/tools/javac/lambda/TestInvokeDynamic.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/test/tools/javac/lambda/TestInvokeDynamic.java	Wed Apr 10 12:50:05 2013 -0700
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug 7194586
- * @bug 8003280 8006694
+ * @bug 8003280 8006694 8010404
  * @summary Add lambda tests
  *  Add back-end support for invokedynamic
  *  temporarily workaround combo tests are causing time out in several platforms
@@ -48,6 +48,7 @@
 import com.sun.tools.classfile.Code_attribute;
 import com.sun.tools.classfile.ConstantPool.*;
 import com.sun.tools.classfile.Instruction;
+import com.sun.tools.classfile.LineNumberTable_attribute;
 import com.sun.tools.classfile.Method;
 
 import com.sun.tools.javac.api.JavacTaskImpl;
@@ -239,7 +240,7 @@
         int id = checkCount.incrementAndGet();
         JavaSource source = new JavaSource(id);
         JavacTaskImpl ct = (JavacTaskImpl)comp.getTask(null, fm.get(), dc,
-                null, null, Arrays.asList(source));
+                Arrays.asList("-g"), null, Arrays.asList(source));
         Context context = ct.getContext();
         Symtab syms = Symtab.instance(context);
         Names names = Names.instance(context);
@@ -349,6 +350,16 @@
                         bsm_ref.getNameAndTypeInfo().getType() + " " +
                         asBSMSignatureString());
             }
+
+            LineNumberTable_attribute lnt =
+                    (LineNumberTable_attribute)ea.attributes.get(Attribute.LineNumberTable);
+
+            if (lnt == null) {
+                throw new Error("No LineNumberTable attribute");
+            }
+            if (lnt.line_number_table_length != 2) {
+                throw new Error("Wrong number of entries in LineNumberTable");
+            }
         } catch (Exception e) {
             e.printStackTrace();
             throw new Error("error reading " + compiledTest +": " + e);
@@ -376,7 +387,10 @@
                 "}\n" +
                 "class Test#ID {\n" +
                 "   void m() { }\n" +
-                "   void test() { m(); }\n" +
+                "   void test() {\n" +
+                "      Object o = this; // marker statement \n" +
+                "      m();\n" +
+                "   }\n" +
                 "}";
 
         String source;
--- a/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java	Wed Apr 10 12:50:05 2013 -0700
@@ -28,10 +28,11 @@
  */
 
 import com.sun.source.util.JavacTask;
-import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import javax.tools.Diagnostic;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
@@ -45,37 +46,45 @@
 
     enum BoundKind {
         INTF,
-        CLASS,
-        SAM,
-        ZAM;
+        CLASS;
     }
 
     enum MethodKind {
-        NONE,
-        ABSTRACT,
-        DEFAULT;
+        NONE(false),
+        ABSTRACT_M(true),
+        DEFAULT_M(false),
+        ABSTRACT_G(true),
+        DEFAULT_G(false);
+
+        boolean isAbstract;
+
+        MethodKind(boolean isAbstract) {
+            this.isAbstract = isAbstract;
+        }
     }
 
     enum TypeKind {
-        A("interface A { }\n", "A", BoundKind.ZAM),
-        B("interface B { default void m() { } }\n", "B", BoundKind.ZAM),
-        C("interface C { void m(); }\n", "C", BoundKind.SAM),
-        D("interface D extends B { }\n", "D", BoundKind.ZAM),
-        E("interface E extends C { }\n", "E", BoundKind.SAM),
-        F("interface F extends C { void g(); }\n", "F", BoundKind.INTF),
-        G("interface G extends B { void g(); }\n", "G", BoundKind.SAM),
-        H("interface H extends A { void g(); }\n", "H", BoundKind.SAM),
+        A("interface A { }\n", "A", BoundKind.INTF, MethodKind.NONE),
+        B("interface B { default void m() { } }\n", "B", BoundKind.INTF, MethodKind.DEFAULT_M),
+        C("interface C { void m(); }\n", "C", BoundKind.INTF, MethodKind.ABSTRACT_M),
+        D("interface D extends B { }\n", "D", BoundKind.INTF, MethodKind.DEFAULT_M),
+        E("interface E extends C { }\n", "E", BoundKind.INTF, MethodKind.ABSTRACT_M),
+        F("interface F extends C { void g(); }\n", "F", BoundKind.INTF, MethodKind.ABSTRACT_G, MethodKind.ABSTRACT_M),
+        G("interface G extends B { void g(); }\n", "G", BoundKind.INTF, MethodKind.ABSTRACT_G, MethodKind.DEFAULT_M),
+        H("interface H extends A { void g(); }\n", "H", BoundKind.INTF, MethodKind.ABSTRACT_G),
         OBJECT("", "Object", BoundKind.CLASS),
         STRING("", "String", BoundKind.CLASS);
 
         String declStr;
         String typeStr;
         BoundKind boundKind;
+        MethodKind[] methodKinds;
 
-        private TypeKind(String declStr, String typeStr, BoundKind boundKind) {
+        private TypeKind(String declStr, String typeStr, BoundKind boundKind, MethodKind... methodKinds) {
             this.declStr = declStr;
             this.typeStr = typeStr;
             this.boundKind = boundKind;
+            this.methodKinds = methodKinds;
         }
 
         boolean compatibleSupertype(TypeKind tk) {
@@ -263,14 +272,22 @@
         boolean errorExpected = !cInfo.wellFormed();
 
         if (ek.isFunctional) {
-            //first bound must be a SAM
-            errorExpected |= cInfo.types[0].boundKind != BoundKind.SAM;
-            if (cInfo.types.length > 1) {
-                //additional bounds must be ZAMs
-                for (int i = 1; i < cInfo.types.length; i++) {
-                    errorExpected |= cInfo.types[i].boundKind != BoundKind.ZAM;
+            List<MethodKind> mks = new ArrayList<>();
+            for (TypeKind tk : cInfo.types) {
+                if (tk.boundKind == BoundKind.CLASS) {
+                    errorExpected = true;
+                    break;
+                } else {
+                    mks = mergeMethods(mks, Arrays.asList(tk.methodKinds));
                 }
             }
+            int abstractCount = 0;
+            for (MethodKind mk : mks) {
+                if (mk.isAbstract) {
+                    abstractCount++;
+                }
+            }
+            errorExpected |= abstractCount != 1;
         }
 
         if (errorExpected != diagChecker.errorFound) {
@@ -281,6 +298,32 @@
         }
     }
 
+    List<MethodKind> mergeMethods(List<MethodKind> l1, List<MethodKind> l2) {
+        List<MethodKind> mergedMethods = new ArrayList<>(l1);
+        for (MethodKind mk2 : l2) {
+            boolean add = !mergedMethods.contains(mk2);
+            switch (mk2) {
+                case ABSTRACT_G:
+                    add = add && !mergedMethods.contains(MethodKind.DEFAULT_G);
+                    break;
+                case ABSTRACT_M:
+                    add = add && !mergedMethods.contains(MethodKind.DEFAULT_M);
+                    break;
+                case DEFAULT_G:
+                    mergedMethods.remove(MethodKind.ABSTRACT_G);
+                case DEFAULT_M:
+                    mergedMethods.remove(MethodKind.ABSTRACT_M);
+                case NONE:
+                    add = false;
+                    break;
+            }
+            if (add) {
+                mergedMethods.add(mk2);
+            }
+        }
+        return mergedMethods;
+    }
+
     static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
 
         boolean errorFound;
--- a/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java	Thu Apr 04 17:44:59 2013 -0700
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java	Wed Apr 10 12:50:05 2013 -0700
@@ -427,6 +427,8 @@
      */
     public void testReflectCall() {
         Interface I = new Interface("I", DefaultMethod.std("99"));
+        //workaround accessibility issue when loading C with DirectedClassLoader
+        I.addAccessFlag(AccessFlag.PUBLIC);
         Class C = new Class("C", I);
 
         Compiler.Flags[] flags = this.verbose ?