changeset 2431:e92effa22ece jdk8u20-b20

Merge
author coffeys
date Mon, 23 Jun 2014 00:01:40 +0100
parents cff4be16ffdd (current diff) 37c7dbe8efee (diff)
children d231957fe310 3a31259481d8
files
diffstat 29 files changed, 581 insertions(+), 155 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Flags.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Mon Jun 23 00:01:40 2014 +0100
@@ -276,6 +276,11 @@
      */
     public static final long LAMBDA_METHOD = 1L<<49;
 
+    /**
+     * Flag to control recursion in TransTypes
+     */
+    public static final long TYPE_TRANSLATED = 1L<<50;
+
     /** Modifier masks.
      */
     public static final int
@@ -295,7 +300,8 @@
         ModifierFlags               = ((long)StandardFlags & ~INTERFACE) | DEFAULT,
         InterfaceMethodMask         = ABSTRACT | STATIC | PUBLIC | STRICTFP | DEFAULT,
         AnnotationTypeElementMask   = ABSTRACT | PUBLIC,
-        LocalVarFlags               = FINAL | PARAMETER;
+        LocalVarFlags               = FINAL | PARAMETER,
+        ReceiverParamFlags          = PARAMETER;
 
 
     public static Set<Modifier> asModifierSet(long flags) {
@@ -385,7 +391,8 @@
         BAD_OVERRIDE(Flags.BAD_OVERRIDE),
         SIGNATURE_POLYMORPHIC(Flags.SIGNATURE_POLYMORPHIC),
         THROWS(Flags.THROWS),
-        LAMBDA_METHOD(Flags.LAMBDA_METHOD);
+        LAMBDA_METHOD(Flags.LAMBDA_METHOD),
+        TYPE_TRANSLATED(Flags.TYPE_TRANSLATED);
 
         Flag(long flag) {
             this.value = flag;
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Jun 23 00:01:40 2014 +0100
@@ -779,42 +779,41 @@
 
         @Override
         public List<Attribute.Compound> getAnnotationMirrors() {
-            return onlyTypeVariableAnnotations(owner.getRawTypeAttributes());
-        }
-
-        private List<Attribute.Compound> onlyTypeVariableAnnotations(
-                List<Attribute.TypeCompound> candidates) {
-            // Declaration annotations on TypeParameters are stored in type attributes
+            // Declaration annotations on type variables are stored in type attributes
+            // on the owner of the TypeVariableSymbol
+            List<Attribute.TypeCompound> candidates = owner.getRawTypeAttributes();
+            int index = owner.getTypeParameters().indexOf(this);
             List<Attribute.Compound> res = List.nil();
             for (Attribute.TypeCompound a : candidates) {
-                if (a.position.type == TargetType.CLASS_TYPE_PARAMETER ||
-                    a.position.type == TargetType.METHOD_TYPE_PARAMETER)
+                if (isCurrentSymbolsAnnotation(a, index))
                     res = res.prepend(a);
             }
 
-            return res = res.reverse();
+            return res.reverse();
         }
 
-
-
         // Helper to getAnnotation[s]
         @Override
         public <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) {
-
             String name = annoType.getName();
 
             // Declaration annotations on type variables are stored in type attributes
             // on the owner of the TypeVariableSymbol
             List<Attribute.TypeCompound> candidates = owner.getRawTypeAttributes();
+            int index = owner.getTypeParameters().indexOf(this);
             for (Attribute.TypeCompound anno : candidates)
-                if (anno.position.type == TargetType.CLASS_TYPE_PARAMETER ||
-                        anno.position.type == TargetType.METHOD_TYPE_PARAMETER)
-                    if (name.contentEquals(anno.type.tsym.flatName()))
-                        return anno;
+                if (isCurrentSymbolsAnnotation(anno, index) &&
+                    name.contentEquals(anno.type.tsym.flatName()))
+                    return anno;
 
             return null;
         }
-
+            //where:
+            boolean isCurrentSymbolsAnnotation(Attribute.TypeCompound anno, int index) {
+                return (anno.position.type == TargetType.CLASS_TYPE_PARAMETER ||
+                        anno.position.type == TargetType.METHOD_TYPE_PARAMETER) &&
+                       anno.position.parameter_index == index;
+            }
 
 
         @Override
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Jun 23 00:01:40 2014 +0100
@@ -629,7 +629,7 @@
      * (ii) perform functional interface bridge calculation.
      */
     public ClassSymbol makeFunctionalInterfaceClass(Env<AttrContext> env, Name name, List<Type> targets, long cflags) {
-        if (targets.isEmpty() || !isFunctionalInterface(targets.head)) {
+        if (targets.isEmpty()) {
             return null;
         }
         Symbol descSym = findDescriptorSymbol(targets.head.tsym);
@@ -2300,7 +2300,7 @@
             public Type visitType(Type t, Void ignored) {
                 // A note on wildcards: there is no good way to
                 // determine a supertype for a super bounded wildcard.
-                return null;
+                return Type.noType;
             }
 
             @Override
@@ -2467,7 +2467,7 @@
             return false;
         return
             t.isRaw() ||
-            supertype(t) != null && isDerivedRaw(supertype(t)) ||
+            supertype(t) != Type.noType && isDerivedRaw(supertype(t)) ||
             isDerivedRaw(interfaces(t));
     }
 
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jun 23 00:01:40 2014 +0100
@@ -94,6 +94,7 @@
     final Annotate annotate;
     final TypeAnnotations typeAnnotations;
     final DeferredLintHandler deferredLintHandler;
+    final TypeEnvs typeEnvs;
 
     public static Attr instance(Context context) {
         Attr instance = context.get(attrKey);
@@ -123,6 +124,7 @@
         annotate = Annotate.instance(context);
         typeAnnotations = TypeAnnotations.instance(context);
         deferredLintHandler = DeferredLintHandler.instance(context);
+        typeEnvs = TypeEnvs.instance(context);
 
         Options options = Options.instance(context);
 
@@ -432,7 +434,7 @@
     }
 
     public Type attribType(JCTree node, TypeSymbol sym) {
-        Env<AttrContext> env = enter.typeEnvs.get(sym);
+        Env<AttrContext> env = typeEnvs.get(sym);
         Env<AttrContext> localEnv = env.dup(node, env.info.dup());
         return attribTree(node, localEnv, unknownTypeInfo);
     }
@@ -2966,10 +2968,19 @@
             if (checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK &&
                     pt != Type.recoveryType) {
                 //check that functional interface class is well-formed
-                ClassSymbol csym = types.makeFunctionalInterfaceClass(env,
-                        names.empty, List.of(fExpr.targets.head), ABSTRACT);
-                if (csym != null) {
-                    chk.checkImplementations(env.tree, csym, csym);
+                try {
+                    /* Types.makeFunctionalInterfaceClass() may throw an exception
+                     * when it's executed post-inference. See the listener code
+                     * above.
+                     */
+                    ClassSymbol csym = types.makeFunctionalInterfaceClass(env,
+                            names.empty, List.of(fExpr.targets.head), ABSTRACT);
+                    if (csym != null) {
+                        chk.checkImplementations(env.tree, csym, csym);
+                    }
+                } catch (Types.FunctionDescriptorLookupError ex) {
+                    JCDiagnostic cause = ex.getDiagnostic();
+                    resultInfo.checkContext.report(env.tree, cause);
                 }
             }
         }
@@ -4051,7 +4062,7 @@
             // ... and attribute the bound class
             c.flags_field |= UNATTRIBUTED;
             Env<AttrContext> cenv = enter.classEnv(cd, env);
-            enter.typeEnvs.put(c, cenv);
+            typeEnvs.put(c, cenv);
             attribClass(c);
             return owntype;
         }
@@ -4201,9 +4212,9 @@
             c.flags_field &= ~UNATTRIBUTED;
 
             // Get environment current at the point of class definition.
-            Env<AttrContext> env = enter.typeEnvs.get(c);
-
-            // The info.lint field in the envs stored in enter.typeEnvs is deliberately uninitialized,
+            Env<AttrContext> env = typeEnvs.get(c);
+
+            // The info.lint field in the envs stored in typeEnvs is deliberately uninitialized,
             // because the annotations were not available at the time the env was created. Therefore,
             // we look up the environment chain for the first enclosing environment for which the
             // lint value is set. Typically, this is the parent env, but might be further if there
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Jun 23 00:01:40 2014 +0100
@@ -1038,7 +1038,9 @@
 
         switch (sym.kind) {
         case VAR:
-            if (sym.owner.kind != TYP)
+            if (TreeInfo.isReceiverParam(tree))
+                mask = ReceiverParamFlags;
+            else if (sym.owner.kind != TYP)
                 mask = LocalVarFlags;
             else if ((sym.owner.flags_field & INTERFACE) != 0)
                 mask = implicit = InterfaceVarFlags;
@@ -2677,7 +2679,7 @@
                 checkClassBounds(pos, seensofar, it);
             }
             Type st = types.supertype(type);
-            if (st != null) checkClassBounds(pos, seensofar, st);
+            if (st != Type.noType) checkClassBounds(pos, seensofar, st);
         }
 
     /** Enter interface into into set.
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Mon Jun 23 00:01:40 2014 +0100
@@ -77,6 +77,7 @@
     final Types types;
     final Flow flow;
     final Names names;
+    final TypeEnvs typeEnvs;
 
     public static DeferredAttr instance(Context context) {
         DeferredAttr instance = context.get(deferredAttrKey);
@@ -100,6 +101,7 @@
         flow = Flow.instance(context);
         names = Names.instance(context);
         stuckTree = make.Ident(names.empty).setType(Type.stuckType);
+        typeEnvs = TypeEnvs.instance(context);
         emptyDeferredAttrContext =
             new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) {
                 @Override
@@ -400,7 +402,7 @@
                 //it is possible that nested expressions inside argument expression
                 //are left unchecked - in such cases there's nothing to clean up.
                 if (csym == null) return;
-                enter.typeEnvs.remove(csym);
+                typeEnvs.remove(csym);
                 chk.compiled.remove(csym.flatname);
                 syms.classes.remove(csym.flatname);
                 super.visitClassDef(tree);
@@ -928,7 +930,7 @@
 
         LambdaReturnScanner() {
             super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP,
-                    FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
+                    FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
         }
     }
 
--- a/src/share/classes/com/sun/tools/javac/comp/Enter.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java	Mon Jun 23 00:01:40 2014 +0100
@@ -105,6 +105,7 @@
     Names names;
     JavaFileManager fileManager;
     PkgInfo pkginfoOpt;
+    TypeEnvs typeEnvs;
 
     private final Todo todo;
 
@@ -142,14 +143,9 @@
 
         Options options = Options.instance(context);
         pkginfoOpt = PkgInfo.get(options);
+        typeEnvs = TypeEnvs.instance(context);
     }
 
-    /** A hashtable mapping classes and packages to the environments current
-     *  at the points of their definitions.
-     */
-    Map<TypeSymbol,Env<AttrContext>> typeEnvs =
-            new HashMap<TypeSymbol,Env<AttrContext>>();
-
     /** Accessor for typeEnvs
      */
     public Env<AttrContext> getEnv(TypeSymbol sym) {
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Jun 23 00:01:40 2014 +0100
@@ -82,6 +82,7 @@
     private ConstFold cfolder;
     private Target target;
     private Source source;
+    private final TypeEnvs typeEnvs;
     private boolean allowEnums;
     private final Name dollarAssertionsDisabled;
     private final Name classDollar;
@@ -103,6 +104,7 @@
         cfolder = ConstFold.instance(context);
         target = Target.instance(context);
         source = Source.instance(context);
+        typeEnvs = TypeEnvs.instance(context);
         allowEnums = source.allowEnums();
         dollarAssertionsDisabled = names.
             fromString(target.syntheticNameChar() + "assertionsDisabled");
@@ -2452,10 +2454,16 @@
     }
 
     public void visitClassDef(JCClassDecl tree) {
+        Env<AttrContext> prevEnv = attrEnv;
         ClassSymbol currentClassPrev = currentClass;
         MethodSymbol currentMethodSymPrev = currentMethodSym;
+
         currentClass = tree.sym;
         currentMethodSym = null;
+        attrEnv = typeEnvs.remove(currentClass);
+        if (attrEnv == null)
+            attrEnv = prevEnv;
+
         classdefs.put(currentClass, tree);
 
         proxies = proxies.dup(currentClass);
@@ -2527,6 +2535,7 @@
         // Append translated tree to `translated' queue.
         translated.append(tree);
 
+        attrEnv = prevEnv;
         currentClass = currentClassPrev;
         currentMethodSym = currentMethodSymPrev;
 
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Jun 23 00:01:40 2014 +0100
@@ -86,6 +86,7 @@
     private final Target target;
     private final DeferredLintHandler deferredLintHandler;
     private final Lint lint;
+    private final TypeEnvs typeEnvs;
 
     public static MemberEnter instance(Context context) {
         MemberEnter instance = context.get(memberEnterKey);
@@ -113,6 +114,7 @@
         target = Target.instance(context);
         deferredLintHandler = DeferredLintHandler.instance(context);
         lint = Lint.instance(context);
+        typeEnvs = TypeEnvs.instance(context);
         allowTypeAnnos = source.allowTypeAnnotations();
         allowRepeatedAnnos = source.allowRepeatedAnnotations();
     }
@@ -652,22 +654,8 @@
                     attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype);
                 } else {
                     attr.attribType(tree.vartype, localEnv);
-                    if (tree.nameexpr != null) {
-                        attr.attribExpr(tree.nameexpr, localEnv);
-                        MethodSymbol m = localEnv.enclMethod.sym;
-                        if (m.isConstructor()) {
-                            Type outertype = m.owner.owner.type;
-                            if (outertype.hasTag(TypeTag.CLASS)) {
-                                checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type");
-                                checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name");
-                            } else {
-                                log.error(tree, "receiver.parameter.not.applicable.constructor.toplevel.class");
-                            }
-                        } else {
-                            checkType(tree.vartype, m.owner.type, "incorrect.receiver.type");
-                            checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name");
-                        }
-                    }
+                    if (TreeInfo.isReceiverParam(tree))
+                        checkReceiver(tree, localEnv);
                 }
             } finally {
                 deferredLintHandler.setPos(prevLintPos);
@@ -714,6 +702,26 @@
             log.error(tree, diag, type, tree.type);
         }
     }
+    void checkReceiver(JCVariableDecl tree, Env<AttrContext> localEnv) {
+        attr.attribExpr(tree.nameexpr, localEnv);
+        MethodSymbol m = localEnv.enclMethod.sym;
+        if (m.isConstructor()) {
+            Type outertype = m.owner.owner.type;
+            if (outertype.hasTag(TypeTag.METHOD)) {
+                // we have a local inner class
+                outertype = m.owner.owner.owner.type;
+            }
+            if (outertype.hasTag(TypeTag.CLASS)) {
+                checkType(tree.vartype, outertype, "incorrect.constructor.receiver.type");
+                checkType(tree.nameexpr, outertype, "incorrect.constructor.receiver.name");
+            } else {
+                log.error(tree, "receiver.parameter.not.applicable.constructor.toplevel.class");
+            }
+        } else {
+            checkType(tree.vartype, m.owner.type, "incorrect.receiver.type");
+            checkType(tree.nameexpr, m.owner.type, "incorrect.receiver.name");
+        }
+    }
 
     public boolean needsLazyConstValue(JCTree tree) {
         InitTreeVisitor initTreeVisitor = new InitTreeVisitor();
@@ -1018,7 +1026,7 @@
 
         ClassSymbol c = (ClassSymbol)sym;
         ClassType ct = (ClassType)c.type;
-        Env<AttrContext> env = enter.typeEnvs.get(c);
+        Env<AttrContext> env = typeEnvs.get(c);
         JCClassDecl tree = (JCClassDecl)env.tree;
         boolean wasFirst = isFirst;
         isFirst = false;
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Mon Jun 23 00:01:40 2014 +0100
@@ -967,10 +967,11 @@
             translateClass((ClassSymbol)st.tsym);
         }
 
-        Env<AttrContext> myEnv = enter.typeEnvs.remove(c);
-        if (myEnv == null) {
+        Env<AttrContext> myEnv = enter.getEnv(c);
+        if (myEnv == null || (c.flags_field & TYPE_TRANSLATED) != 0) {
             return;
         }
+        c.flags_field |= TYPE_TRANSLATED;
 
         /*  The two assertions below are set for early detection of any attempt
          *  to translate a class that:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/TypeEnvs.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.comp;
+
+import java.util.Collection;
+import java.util.HashMap;
+import com.sun.tools.javac.code.Symbol.TypeSymbol;
+import com.sun.tools.javac.util.Context;
+
+/** This class contains the type environments used by Enter, MemberEnter,
+ *  Attr, DeferredAttr, and Lower.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+class TypeEnvs {
+    private static final long serialVersionUID = 571524752489954631L;
+
+    protected static final Context.Key<TypeEnvs> typeEnvsKey = new Context.Key<>();
+    public static TypeEnvs instance(Context context) {
+        TypeEnvs instance = context.get(typeEnvsKey);
+        if (instance == null)
+            instance = new TypeEnvs(context);
+        return instance;
+    }
+
+    private HashMap<TypeSymbol,Env<AttrContext>> map;
+    protected TypeEnvs(Context context) {
+        map = new HashMap<>();
+        context.put(typeEnvsKey, this);
+    }
+
+    Env<AttrContext> get(TypeSymbol sym) { return map.get(sym); }
+    Env<AttrContext> put(TypeSymbol sym, Env<AttrContext> env) { return map.put(sym, env); }
+    Env<AttrContext> remove(TypeSymbol sym) { return map.remove(sym); }
+    Collection<Env<AttrContext>> values() { return map.values(); }
+    void clear() { map.clear(); }
+}
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Mon Jun 23 00:01:40 2014 +0100
@@ -135,6 +135,14 @@
         }
     }
 
+    public static boolean isReceiverParam(JCTree tree) {
+        if (tree.hasTag(VARDEF)) {
+            return ((JCVariableDecl)tree).nameexpr != null;
+        } else {
+            return false;
+        }
+    }
+
     /** Is there a constructor declaration in the given list of trees?
      */
     public static boolean hasConstructors(List<JCTree> trees) {
--- a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Mon Jun 23 00:01:40 2014 +0100
@@ -355,13 +355,41 @@
     private final DiagnosticType type;
     private final DiagnosticSource source;
     private final DiagnosticPosition position;
-    private final int line;
-    private final int column;
     private final String key;
     protected final Object[] args;
     private final Set<DiagnosticFlag> flags;
     private final LintCategory lintCategory;
 
+    /** source line position (set lazily) */
+    private SourcePosition sourcePosition;
+
+    /**
+     * This class is used to defer the line/column position fetch logic after diagnostic construction.
+     */
+    class SourcePosition {
+
+        private final int line;
+        private final int column;
+
+        SourcePosition() {
+            int n = (position == null ? Position.NOPOS : position.getPreferredPosition());
+            if (n == Position.NOPOS || source == null)
+                line = column = -1;
+            else {
+                line = source.getLineNumber(n);
+                column = source.getColumnNumber(n, true);
+            }
+        }
+
+        public int getLineNumber() {
+            return line;
+        }
+
+        public int getColumnNumber() {
+            return column;
+        }
+    }
+
     /**
      * Create a diagnostic object.
      * @param formatter the formatter to use for the diagnostic
@@ -391,14 +419,6 @@
         this.position = pos;
         this.key = key;
         this.args = args;
-
-        int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition());
-        if (n == Position.NOPOS || source == null)
-            line = column = -1;
-        else {
-            line = source.getLineNumber(n);
-            column = source.getColumnNumber(n, true);
-        }
     }
 
     /**
@@ -495,7 +515,10 @@
      * @return  the line number within the source referred to by this diagnostic
      */
     public long getLineNumber() {
-        return line;
+        if (sourcePosition == null) {
+            sourcePosition = new SourcePosition();
+        }
+        return sourcePosition.getLineNumber();
     }
 
     /**
@@ -503,7 +526,10 @@
      * @return  the column number within the line of source referred to by this diagnostic
      */
     public long getColumnNumber() {
-        return column;
+        if (sourcePosition == null) {
+            sourcePosition = new SourcePosition();
+        }
+        return sourcePosition.getColumnNumber();
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T8038975/AccessTest.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, 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 8038975
+ * @summary Access control in enhanced for
+ * @compile AccessTest.java
+ */
+
+import a.*;
+public class AccessTest {
+    private static class Impl extends B {
+        public void method(Inner inner) {
+            for (A a : inner)
+                System.out.println(a);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T8038975/a/A.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014, 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 a;
+public class A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T8038975/a/B.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014, 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 a;
+public class B {
+    protected abstract class Inner implements Iterable<A> { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/FinalReceiverTest.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8027886
+ * @summary Receiver parameters must not be final
+ * @compile/fail/ref=FinalReceiverTest.out  -XDrawDiagnostics FinalReceiverTest.java
+ */
+
+class FinalReceiverTest {
+    void m() {
+        class Inner {
+            Inner(final FinalReceiverTest FinalReceiverTest.this) {}
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/FinalReceiverTest.out	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,2 @@
+FinalReceiverTest.java:11:43: compiler.err.mod.not.allowed.here: final
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/LocalInnerReceiverTest.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014, 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 8029042
+ * @summary Receiver parameter not supported on local class constructor
+ * @compile LocalInnerReceiverTest.java
+ */
+
+class LocalInnerReceiverTest {
+    void m() {
+        class Inner {
+            Inner(LocalInnerReceiverTest LocalInnerReceiverTest.this) {}
+        }
+    }
+}
--- a/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java	Mon Jun 23 00:01:40 2014 +0100
@@ -54,14 +54,6 @@
   <T extends Runnable> void accept(@B("m") WithValue this, T r) throws Exception { }
 }
 
-class WithFinal {
-  void plain(final @B("m") WithFinal this) { }
-  <T> void generic(final @B("m") WithFinal this) { }
-  void withException(final @B("m") WithFinal this) throws Exception { }
-  String nonVoid(final @B("m") WithFinal this) { return null; }
-  <T extends Runnable> void accept(final @B("m") WithFinal this, T r) throws Exception { }
-}
-
 class WithBody {
   Object f;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/static/StaticInvoke.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,15 @@
+/* @test /nodynamiccopyright/
+ * @bug 8037385
+ * @summary Must not allow static interface method invocation in legacy code
+ * @compile -source 8 -Xlint:-options StaticInvoke.java
+ * @compile/fail/ref=StaticInvoke7.out -source 7 -Xlint:-options -XDrawDiagnostics StaticInvoke.java
+ * @compile/fail/ref=StaticInvoke6.out -source 6 -Xlint:-options -XDrawDiagnostics StaticInvoke.java
+ */
+import java.util.stream.Stream;
+
+class StaticInvoke {
+    void test() {
+        Stream.empty();
+        java.util.stream.Stream.empty();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/static/StaticInvoke6.out	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,3 @@
+StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6
+StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/static/StaticInvoke7.out	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,3 @@
+StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7
+StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/wildcards/T8034147.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014, 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 8034147
+ * @summary javac crashes with a NullPointerException during bounds checking
+ * @compile T8034147.java
+ */
+
+class T8034147 {
+    static class One<X extends Two<? super X>> {}
+    static class Two<Y extends Three<? extends Y>> implements Three<Y> {}
+    interface Three<Z> {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8038182
+ * @summary javac crash with FunctionDescriptorLookupError for invalid functional interface
+ * @compile/fail/ref=CrashFunctionDescriptorExceptionTest.out -XDrawDiagnostics CrashFunctionDescriptorExceptionTest.java
+ */
+
+class CrashFunctionDescriptorExceptionTest {
+
+    @SuppressWarnings("unchecked")
+    void m () {
+        bar((B b) -> {});
+    }
+
+    <E extends A<E>> void bar(I<E> i) {}
+
+    class A<E> {}
+
+    class B<E> extends A<E> {}
+
+    interface I<E extends A<E>> {
+        void foo(E e);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,2 @@
+CrashFunctionDescriptorExceptionTest.java:12:13: compiler.err.prob.found.req: (compiler.misc.no.suitable.functional.intf.inst: CrashFunctionDescriptorExceptionTest.I<CrashFunctionDescriptorExceptionTest.B>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8042759
+ * @summary Lambda returning implicitly-typed lambdas considered pertinent to applicability
+ * @compile/fail/ref=ImplicitLambdaConsideredForApplicabilityTest.out -XDrawDiagnostics ImplicitLambdaConsideredForApplicabilityTest.java
+ */
+
+abstract class ImplicitLambdaConsideredForApplicabilityTest {
+    interface A {
+        B m(int a, int b);
+    }
+
+    interface C {
+        String m(int a, int b);
+    }
+
+    interface B {
+        int m(int c);
+    }
+
+    abstract void foo(A a);
+
+    abstract void foo(C c);
+
+    void bar() {
+        foo((int a, int b) -> {
+            if(a < b)
+                return c -> 0;
+            else
+                return c -> 0;
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out	Mon Jun 23 00:01:40 2014 +0100
@@ -0,0 +1,2 @@
+ImplicitLambdaConsideredForApplicabilityTest.java:26:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.A), ImplicitLambdaConsideredForApplicabilityTest, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.C), ImplicitLambdaConsideredForApplicabilityTest
+1 error
--- a/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java	Thu Jun 19 17:59:42 2014 -0700
+++ b/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java	Mon Jun 23 00:01:40 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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,7 +23,7 @@
 
 /*
  * @test
- * @bug 8011027
+ * @bug 8011027 8046916
  * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestTypeParameterAnnotations
  * @compile -processor TestTypeParameterAnnotations -proc:only TestTypeParameterAnnotations.java
@@ -33,10 +33,16 @@
 import java.lang.annotation.*;
 import javax.annotation.processing.*;
 import javax.lang.model.element.*;
-import javax.lang.model.util.*;
 import javax.tools.*;
 
-public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTestingAbstractProcessor {
+@ExpectedTypeParameterAnnotations(typeParameterName="T1",
+                                  annotations={"Foo1", "Bar1", "Baz1"})
+@ExpectedTypeParameterAnnotations(typeParameterName="T2", annotations={})
+@ExpectedTypeParameterAnnotations(typeParameterName="T3",
+                                  annotations={"Foo2", "Bar2", "Baz2"})
+@ExpectedTypeParameterAnnotations(typeParameterName="T4", annotations={})
+public class TestTypeParameterAnnotations<@Foo1 @Bar1 @Baz1 T1, T2, @Foo2 @Bar2 @Baz2 T3, T4> extends
+        JavacTestingAbstractProcessor {
     int round = 0;
 
     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
@@ -74,82 +80,69 @@
     int check(Element e, List<? extends TypeParameterElement> typarams) {
         if (typarams.isEmpty())
             return 0;
-        if (typarams.size() != 1)
-            return 0;
 
-        for (TypeParameterElement tpe: typarams) {
-            boolean b1 = checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors());
-            boolean b2 = checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe));
-            boolean b3 = checkGetAnnotation(tpe);
-            boolean b4 = checkGetAnnotations(tpe);
-            return b1 && b2 && b3 && b4 ? 1 : 0;
-        }
-        return 0;
-    }
-
-    boolean checkAnnotationMirrors(TypeParameterElement tpe, List<? extends AnnotationMirror> l) {
-        if (l.size() != 3) {
-            error("To few annotations, got " + l.size() +
-                    ", should be 3", tpe);
-            return false;
+        for (TypeParameterElement tpe : typarams) {
+            ExpectedTypeParameterAnnotations expected = null;
+            for (ExpectedTypeParameterAnnotations a : e.getAnnotationsByType(ExpectedTypeParameterAnnotations.class)) {
+                if (tpe.getSimpleName().contentEquals(a.typeParameterName())) {
+                    expected = a;
+                    break;
+                }
+            }
+            if (expected == null) {
+                throw new IllegalStateException("Does not have expected values annotation.");
+            }
+            checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors(), expected);
+            checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe), expected);
+            checkGetAnnotation(tpe, expected);
+            checkGetAnnotations(tpe, expected);
         }
 
-        AnnotationMirror m = l.get(0);
-        if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Foo"))) {
-            error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement());
-            return false;
-        }
-        m = l.get(1);
-        if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Bar"))) {
-            error("Wrong type of annotation, was expecting @Bar", m.getAnnotationType().asElement());
-            return false;
-        }
-        m = l.get(2);
-        if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Baz"))) {
-            error("Wrong type of annotation, was expecting @Baz", m.getAnnotationType().asElement());
-            return false;
-        }
-        return true;
+        return typarams.size();
     }
 
-    boolean checkGetAnnotation(TypeParameterElement tpe) {
-        Foo f = tpe.getAnnotation(Foo.class);
-        if (f == null)
-            error("Expecting @Foo to be present in getAnnotation()", tpe);
+    void checkAnnotationMirrors(TypeParameterElement tpe, List<? extends AnnotationMirror> l, ExpectedTypeParameterAnnotations expected) {
+        String[] expectedAnnotations = expected.annotations();
 
-        Bar b = tpe.getAnnotation(Bar.class);
-        if (b == null)
-            error("Expecting @Bar to be present in getAnnotation()", tpe);
+        if (l.size() != expectedAnnotations.length) {
+            error("Incorrect number of annotations, got " + l.size() +
+                    ", should be " + expectedAnnotations.length, tpe);
+            return ;
+        }
 
-        Baz z = tpe.getAnnotation(Baz.class);
-        if (z == null)
-            error("Expecting @Baz to be present in getAnnotation()", tpe);
-
-        return f != null &&
-            b != null &&
-            z != null;
+        for (int i = 0; i < expectedAnnotations.length; i++) {
+            AnnotationMirror m = l.get(i);
+            if (!m.getAnnotationType().asElement().equals(elements.getTypeElement(expectedAnnotations[i]))) {
+                error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement());
+                return ;
+            }
+        }
     }
 
-    boolean checkGetAnnotations(TypeParameterElement tpe) {
-        Foo[] f = tpe.getAnnotationsByType(Foo.class);
-        if (f.length != 1) {
-            error("Expecting 1 @Foo to be present in getAnnotationsByType()", tpe);
-            return false;
-        }
+    void checkGetAnnotation(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) {
+        List<String> expectedAnnotations = Arrays.asList(expected.annotations());
+
+        for (Class<? extends Annotation> c : ALL_ANNOTATIONS) {
+            Object a = tpe.getAnnotation(c);
 
-        Bar[] b = tpe.getAnnotationsByType(Bar.class);
-        if (b.length != 1) {
-            error("Expecting 1 @Bar to be present in getAnnotationsByType()", tpe);
-            return false;
+            if (a != null ^ expectedAnnotations.indexOf(c.getName()) != (-1)) {
+                error("Unexpected behavior for " + c.getName(), tpe);
+                return ;
+            }
         }
+    }
 
-        Baz[] z = tpe.getAnnotationsByType(Baz.class);
-        if (z.length != 1) {
-            error("Expecting 1 @Baz to be present in getAnnotationsByType()", tpe);
-            return false;
+    void checkGetAnnotations(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) {
+        List<String> expectedAnnotations = Arrays.asList(expected.annotations());
+
+        for (Class<? extends Annotation> c : ALL_ANNOTATIONS) {
+            Object[] a = tpe.getAnnotationsByType(c);
+
+            if (a.length > 0 ^ expectedAnnotations.indexOf(c.getName()) != (-1)) {
+                error("Unexpected behavior for " + c.getName(), tpe);
+                return ;
+            }
         }
-
-        return true;
     }
 
     void note(String msg) {
@@ -168,23 +161,71 @@
         messager.printMessage(Diagnostic.Kind.ERROR, msg);
     }
 
+    Class<? extends Annotation>[] ALL_ANNOTATIONS = new Class[] {
+        Foo1.class, Bar1.class, Baz1.class,
+        Foo2.class, Bar2.class, Baz2.class,
+    };
+
     // additional generic elements to test
-    <@Foo @Bar @Baz X> X m(X x) { return x; }
+    @ExpectedTypeParameterAnnotations(typeParameterName="W",
+                                      annotations={"Foo1", "Bar1", "Baz1"})
+    @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
+    @ExpectedTypeParameterAnnotations(typeParameterName="Y",
+                                      annotations={"Foo2", "Bar2", "Baz2"})
+    @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
+    <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> X m(X x) { return x; }
 
-    interface Intf<@Foo @Bar @Baz X> { X m() ; }
+    @ExpectedTypeParameterAnnotations(typeParameterName="W",
+                                      annotations={"Foo1", "Bar1", "Baz1"})
+    @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
+    @ExpectedTypeParameterAnnotations(typeParameterName="Y",
+                                      annotations={"Foo2", "Bar2", "Baz2"})
+    @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
+    interface Intf<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> { X m() ; }
 
-    class Class<@Foo @Bar @Baz X> {
-        <@Foo @Bar @Baz Y> Class() { }
+    @ExpectedTypeParameterAnnotations(typeParameterName="W",
+                                      annotations={"Foo1", "Bar1", "Baz1"})
+    @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
+    @ExpectedTypeParameterAnnotations(typeParameterName="Y",
+                                      annotations={"Foo2", "Bar2", "Baz2"})
+    @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
+    class Clazz<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> {
+        @ExpectedTypeParameterAnnotations(typeParameterName="W",
+                                          annotations={"Foo1", "Bar1", "Baz1"})
+        @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
+        @ExpectedTypeParameterAnnotations(typeParameterName="Y",
+                                          annotations={"Foo2", "Bar2", "Baz2"})
+        @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
+        <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> Clazz() { }
     }
 
-    final int expect = 5;  // top level class, plus preceding examples
+    final int expect = 5 * 4;  // top level class, plus preceding examples, 4 type variables each
 }
 
 @Target(ElementType.TYPE_PARAMETER)
-@interface Foo {}
+@interface Foo1 {}
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface Bar1 {}
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface Baz1 {}
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface Foo2 {}
 
 @Target(ElementType.TYPE_PARAMETER)
-@interface Bar {}
+@interface Bar2 {}
 
 @Target(ElementType.TYPE_PARAMETER)
-@interface Baz {}
+@interface Baz2 {}
+
+@Repeatable(ExpectedTypeParameterAnnotationsCollection.class)
+@interface ExpectedTypeParameterAnnotations {
+    public String typeParameterName();
+    public String[] annotations();
+}
+
+@interface ExpectedTypeParameterAnnotationsCollection {
+    public ExpectedTypeParameterAnnotations[] value();
+}