8062373: Project Coin: diamond and anonymous classes
authorsadayapalam
Mon, 30 Mar 2015 17:09:14 +0530
changeset 29776 984a79b71cfe
parent 29775 dc7df633fea1
child 29777 95a89a2efd89
8062373: Project Coin: diamond and anonymous classes Summary: Allow diamond inference in combination with anonymous class instance creation Reviewed-by: mcimadamore, vromero Contributed-by: srikanth.adayapalam@oracle.com, maurizio.cimadamore@oracle.com
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java
langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java
langtools/test/tools/javac/diags/examples/DiamondAndNonDenotableTypes.java
langtools/test/tools/javac/failover/CheckAttributedTree.java
langtools/test/tools/javac/generics/diamond/6939780/T6939780.java
langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out
langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out
langtools/test/tools/javac/generics/diamond/6939780/T6939780_9.out
langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java
langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java
langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java
langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out
langtools/test/tools/javac/generics/diamond/MultipleInferenceHooksTest.java
langtools/test/tools/javac/generics/diamond/neg/Neg01.java
langtools/test/tools/javac/generics/diamond/neg/Neg01.out
langtools/test/tools/javac/generics/diamond/neg/Neg02.java
langtools/test/tools/javac/generics/diamond/neg/Neg02.out
langtools/test/tools/javac/generics/diamond/neg/Neg03.java
langtools/test/tools/javac/generics/diamond/neg/Neg03.out
langtools/test/tools/javac/generics/diamond/neg/Neg04.java
langtools/test/tools/javac/generics/diamond/neg/Neg04.out
langtools/test/tools/javac/generics/diamond/neg/Neg05.java
langtools/test/tools/javac/generics/diamond/neg/Neg05.out
langtools/test/tools/javac/generics/diamond/neg/Neg06.java
langtools/test/tools/javac/generics/diamond/neg/Neg06.out
langtools/test/tools/javac/generics/diamond/neg/Neg07.java
langtools/test/tools/javac/generics/diamond/neg/Neg07.out
langtools/test/tools/javac/generics/diamond/neg/Neg09.java
langtools/test/tools/javac/generics/diamond/neg/Neg09.out
langtools/test/tools/javac/generics/diamond/neg/Neg12.java
langtools/test/tools/javac/generics/diamond/neg/Neg12.out
langtools/test/tools/javac/generics/diamond/neg/Neg13.java
langtools/test/tools/javac/generics/diamond/neg/Neg13.out
langtools/test/tools/javac/generics/diamond/neg/Neg14.java
langtools/test/tools/javac/generics/diamond/neg/Neg14.out
langtools/test/tools/javac/generics/diamond/neg/Neg15.java
langtools/test/tools/javac/generics/diamond/neg/Neg15.out
langtools/test/tools/javac/generics/diamond/neg/Neg16.java
langtools/test/tools/javac/generics/diamond/neg/Neg16.out
langtools/test/tools/javac/generics/diamond/neg/Neg17.java
langtools/test/tools/javac/generics/diamond/neg/Neg17.out
langtools/test/tools/javac/generics/diamond/neg/Neg18.java
langtools/test/tools/javac/generics/diamond/neg/Neg18.out
langtools/test/tools/javac/generics/diamond/neg/Neg19.java
langtools/test/tools/javac/generics/diamond/neg/Neg19.out
langtools/test/tools/javac/generics/diamond/neg/pkg/Neg18_01.java
langtools/test/tools/javac/generics/diamond/pos/Pos01.java
langtools/test/tools/javac/generics/diamond/pos/Pos02.java
langtools/test/tools/javac/generics/diamond/pos/Pos03.java
langtools/test/tools/javac/generics/diamond/pos/Pos04.java
langtools/test/tools/javac/generics/diamond/pos/Pos05.java
langtools/test/tools/javac/generics/inference/8055963/T8055963.java
langtools/test/tools/javac/lambda/8066974/T8066974.java
langtools/test/tools/javac/lambda/8066974/T8066974.out
langtools/test/tools/javac/lambda/TargetType46.java
langtools/test/tools/javac/lambda/TargetType46.out
langtools/test/tools/javac/lambda/TargetType68.java
langtools/test/tools/javac/lambda/TargetType68.out
langtools/test/tools/javac/lambda/TargetType69.java
langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java
langtools/test/tools/javac/scope/DupUnsharedTest.java
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Mon Mar 30 17:09:14 2015 +0530
@@ -209,6 +209,9 @@
     public boolean allowPrivateSafeVarargs() {
         return compareTo(JDK1_9) >= 0;
     }
+    public boolean allowDiamondWithAnonymousClassCreation() {
+        return compareTo(JDK1_9) >= 0;
+    }
     public boolean allowUnderscoreIdentifier() {
         return compareTo(JDK1_8) <= 0;
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -90,6 +90,7 @@
     final DeferredAttr deferredAttr;
     final TreeMaker make;
     final Names names;
+    private final boolean allowDiamondWithAnonymousClassCreation;
 
     final EnumSet<AnalyzerMode> analyzerModes;
 
@@ -112,6 +113,7 @@
         String findOpt = options.get("find");
         //parse modes
         Source source = Source.instance(context);
+        allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
         analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source);
     }
 
@@ -210,7 +212,7 @@
         boolean match(JCNewClass tree) {
             return tree.clazz.hasTag(TYPEAPPLY) &&
                     !TreeInfo.isDiamond(tree) &&
-                    tree.def == null;
+                    (tree.def == null || allowDiamondWithAnonymousClassCreation);
         }
 
         @Override
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Mar 30 17:09:14 2015 +0530
@@ -46,6 +46,10 @@
 import com.sun.tools.javac.comp.Infer.InferenceContext;
 import com.sun.tools.javac.comp.Infer.FreeTypeListener;
 import com.sun.tools.javac.jvm.*;
+import static com.sun.tools.javac.resources.CompilerProperties.Fragments.Diamond;
+import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArg;
+import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArgs;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
@@ -54,6 +58,7 @@
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.Dependencies.AttributionKind;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Fragment;
 import com.sun.tools.javac.util.List;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Flags.ANNOTATION;
@@ -219,6 +224,26 @@
                final Type found,
                final KindSelector ownkind,
                final ResultInfo resultInfo) {
+        return check(tree, found, ownkind, resultInfo, true);
+    }
+    /** Check kind and type of given tree against protokind and prototype.
+     *  If check succeeds, store type in tree and return it.
+     *  If check fails, store errType in tree and return it.
+     *  No checks are performed if the prototype is a method type.
+     *  It is not necessary in this case since we know that kind and type
+     *  are correct.
+     *
+     *  @param tree     The tree whose kind and type is checked
+     *  @param found    The computed type of the tree
+     *  @param ownkind  The computed kind of the tree
+     *  @param resultInfo  The expected result of the tree
+     *  @param recheckPostInference If true and inference is underway, arrange to recheck the tree after inference finishes.
+     */
+    Type check(final JCTree tree,
+               final Type found,
+               final KindSelector ownkind,
+               final ResultInfo resultInfo,
+               boolean recheckPostInference) {
         InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
         Type owntype;
         boolean shouldCheck = !found.hasTag(ERROR) &&
@@ -233,12 +258,14 @@
             //delay the check if there are inference variables in the found type
             //this means we are dealing with a partially inferred poly expression
             owntype = shouldCheck ? resultInfo.pt : found;
-            inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt),
-                    instantiatedContext -> {
-                        ResultInfo pendingResult =
-                                resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
-                        check(tree, inferenceContext.asInstType(found), ownkind, pendingResult);
-                    });
+            if (recheckPostInference) {
+                inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt),
+                        instantiatedContext -> {
+                            ResultInfo pendingResult =
+                                    resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
+                            check(tree, inferenceContext.asInstType(found), ownkind, pendingResult, false);
+                        });
+            }
         } else {
             owntype = shouldCheck ?
             resultInfo.check(tree, found) :
@@ -862,7 +889,7 @@
             } else {
                 chk.checkOverrideClashes(tree.pos(), env.enclClass.type, m);
             }
-            chk.checkOverride(tree, m);
+            chk.checkOverride(env, tree, m);
 
             if (isDefaultMethod && types.overridesObjectMethod(m.enclClass(), m)) {
                 log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location());
@@ -1969,11 +1996,16 @@
                  (((JCVariableDecl) env.tree).mods.flags & Flags.ENUM) == 0 ||
                  ((JCVariableDecl) env.tree).init != tree))
                 log.error(tree.pos(), "enum.cant.be.instantiated");
+
+            boolean isSpeculativeDiamondInferenceRound = TreeInfo.isDiamond(tree) &&
+                    resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
+            boolean skipNonDiamondPath = false;
             // Check that class is not abstract
-            if (cdef == null &&
+            if (cdef == null && !isSpeculativeDiamondInferenceRound && // class body may be nulled out in speculative tree copy
                 (clazztype.tsym.flags() & (ABSTRACT | INTERFACE)) != 0) {
                 log.error(tree.pos(), "abstract.cant.be.instantiated",
                           clazztype.tsym);
+                skipNonDiamondPath = true;
             } else if (cdef != null && clazztype.tsym.isInterface()) {
                 // Check that no constructor arguments are given to
                 // anonymous classes implementing an interface
@@ -1986,7 +2018,9 @@
                 // Error recovery: pretend no arguments were supplied.
                 argtypes = List.nil();
                 typeargtypes = List.nil();
-            } else if (TreeInfo.isDiamond(tree)) {
+                skipNonDiamondPath = true;
+            }
+            if (TreeInfo.isDiamond(tree)) {
                 ClassType site = new ClassType(clazztype.getEnclosingType(),
                             clazztype.tsym.type.getTypeArguments(),
                                                clazztype.tsym,
@@ -2022,7 +2056,7 @@
 
                 tree.clazz.type = types.createErrorType(clazztype);
                 if (!constructorType.isErroneous()) {
-                    tree.clazz.type = clazztype = constructorType.getReturnType();
+                    tree.clazz.type = clazz.type = constructorType.getReturnType();
                     tree.constructorType = types.createMethodTypeWithReturn(constructorType, syms.voidType);
                 }
                 clazztype = chk.checkClassType(tree.clazz, tree.clazz.type, true);
@@ -2031,7 +2065,7 @@
             // Resolve the called constructor under the assumption
             // that we are referring to a superclass instance of the
             // current instance (JLS ???).
-            else {
+            else if (!skipNonDiamondPath) {
                 //the following code alters some of the fields in the current
                 //AttrContext - hence, the current context must be dup'ed in
                 //order to avoid downstream failures
@@ -2052,70 +2086,8 @@
             }
 
             if (cdef != null) {
-                // We are seeing an anonymous class instance creation.
-                // In this case, the class instance creation
-                // expression
-                //
-                //    E.new <typeargs1>C<typargs2>(args) { ... }
-                //
-                // is represented internally as
-                //
-                //    E . new <typeargs1>C<typargs2>(args) ( class <empty-name> { ... } )  .
-                //
-                // This expression is then *transformed* as follows:
-                //
-                // (1) add an extends or implements clause
-                // (2) add a constructor.
-                //
-                // For instance, if C is a class, and ET is the type of E,
-                // the expression
-                //
-                //    E.new <typeargs1>C<typargs2>(args) { ... }
-                //
-                // is translated to (where X is a fresh name and typarams is the
-                // parameter list of the super constructor):
-                //
-                //   new <typeargs1>X(<*nullchk*>E, args) where
-                //     X extends C<typargs2> {
-                //       <typarams> X(ET e, args) {
-                //         e.<typeargs1>super(args)
-                //       }
-                //       ...
-                //     }
-
-                if (clazztype.tsym.isInterface()) {
-                    cdef.implementing = List.of(clazz);
-                } else {
-                    cdef.extending = clazz;
-                }
-
-                if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK &&
-                    isSerializable(clazztype)) {
-                    localEnv.info.isSerializable = true;
-                }
-
-                attribStat(cdef, localEnv);
-
-                // If an outer instance is given,
-                // prefix it to the constructor arguments
-                // and delete it from the new expression
-                if (tree.encl != null && !clazztype.tsym.isInterface()) {
-                    tree.args = tree.args.prepend(makeNullCheck(tree.encl));
-                    argtypes = argtypes.prepend(tree.encl.type);
-                    tree.encl = null;
-                }
-
-                // Reassign clazztype and recompute constructor.
-                clazztype = cdef.sym.type;
-                Symbol sym = tree.constructor = rs.resolveConstructor(
-                    tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
-                Assert.check(!sym.kind.isResolutionError());
-                tree.constructor = sym;
-                tree.constructorType = checkId(noCheckTree,
-                    clazztype,
-                    tree.constructor,
-                    localEnv,
-                    new ResultInfo(pkind, newMethodTemplate(syms.voidType, argtypes, typeargtypes)));
+                visitAnonymousClassDefinition(tree, clazz, clazztype, cdef, localEnv, argtypes, typeargtypes, pkind);
+                return;
             }
 
             if (tree.constructor != null && tree.constructor.kind == MTH)
@@ -2133,6 +2105,125 @@
         chk.validate(tree.typeargs, localEnv);
     }
 
+        // where
+        private void visitAnonymousClassDefinition(JCNewClass tree, JCExpression clazz, Type clazztype,
+                                                   JCClassDecl cdef, Env<AttrContext> localEnv,
+                                                   List<Type> argtypes, List<Type> typeargtypes,
+                                                   KindSelector pkind) {
+            // We are seeing an anonymous class instance creation.
+            // In this case, the class instance creation
+            // expression
+            //
+            //    E.new <typeargs1>C<typargs2>(args) { ... }
+            //
+            // is represented internally as
+            //
+            //    E . new <typeargs1>C<typargs2>(args) ( class <empty-name> { ... } )  .
+            //
+            // This expression is then *transformed* as follows:
+            //
+            // (1) add an extends or implements clause
+            // (2) add a constructor.
+            //
+            // For instance, if C is a class, and ET is the type of E,
+            // the expression
+            //
+            //    E.new <typeargs1>C<typargs2>(args) { ... }
+            //
+            // is translated to (where X is a fresh name and typarams is the
+            // parameter list of the super constructor):
+            //
+            //   new <typeargs1>X(<*nullchk*>E, args) where
+            //     X extends C<typargs2> {
+            //       <typarams> X(ET e, args) {
+            //         e.<typeargs1>super(args)
+            //       }
+            //       ...
+            //     }
+            InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
+            final boolean isDiamond = TreeInfo.isDiamond(tree);
+            if (isDiamond
+                    && ((tree.constructorType != null && inferenceContext.free(tree.constructorType))
+                    || (tree.clazz.type != null && inferenceContext.free(tree.clazz.type)))) {
+                inferenceContext.addFreeTypeListener(List.of(tree.constructorType, tree.clazz.type),
+                        instantiatedContext -> {
+                            tree.constructorType = instantiatedContext.asInstType(tree.constructorType);
+                            clazz.type = instantiatedContext.asInstType(clazz.type);
+                            visitAnonymousClassDefinition(tree, clazz, clazz.type, cdef, localEnv, argtypes, typeargtypes, pkind);
+                        });
+            } else {
+                if (isDiamond && clazztype.hasTag(CLASS)) {
+                    List<Type> invalidDiamondArgs = chk.checkDiamondDenotable((ClassType)clazztype);
+                    if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
+                        // One or more types inferred in the previous steps is non-denotable.
+                        Fragment fragment = Diamond(clazztype.tsym);
+                        log.error(tree.clazz.pos(),
+                                Errors.CantApplyDiamond1(
+                                        fragment,
+                                        invalidDiamondArgs.size() > 1 ?
+                                                DiamondInvalidArgs(invalidDiamondArgs, fragment) :
+                                                DiamondInvalidArg(invalidDiamondArgs, fragment)));
+                    }
+                    // For <>(){}, inferred types must also be accessible.
+                    for (Type t : clazztype.getTypeArguments()) {
+                        rs.checkAccessibleType(env, t);
+                    }
+                }
+
+                // If we already errored, be careful to avoid a further avalanche. ErrorType answers
+                // false for isInterface call even when the original type is an interface.
+                boolean implementing = clazztype.tsym.isInterface() ||
+                        clazztype.isErroneous() && clazztype.getOriginalType().tsym.isInterface();
+
+                if (implementing) {
+                    cdef.implementing = List.of(clazz);
+                } else {
+                    cdef.extending = clazz;
+                }
+
+                if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK &&
+                    isSerializable(clazztype)) {
+                    localEnv.info.isSerializable = true;
+                }
+
+                attribStat(cdef, localEnv);
+
+                List<Type> finalargtypes;
+                // If an outer instance is given,
+                // prefix it to the constructor arguments
+                // and delete it from the new expression
+                if (tree.encl != null && !clazztype.tsym.isInterface()) {
+                    tree.args = tree.args.prepend(makeNullCheck(tree.encl));
+                    finalargtypes = argtypes.prepend(tree.encl.type);
+                    tree.encl = null;
+                } else {
+                    finalargtypes = argtypes;
+                }
+
+                // Reassign clazztype and recompute constructor. As this necessarily involves
+                // another attribution pass for deferred types in the case of <>, replicate
+                // them. Original arguments have right decorations already.
+                if (isDiamond && pkind.contains(KindSelector.POLY)) {
+                    finalargtypes = finalargtypes.map(deferredAttr.deferredCopier);
+                }
+
+                clazztype = cdef.sym.type;
+                Symbol sym = tree.constructor = rs.resolveConstructor(
+                        tree.pos(), localEnv, clazztype, finalargtypes, typeargtypes);
+                Assert.check(!sym.kind.isResolutionError());
+                tree.constructor = sym;
+                tree.constructorType = checkId(noCheckTree,
+                        clazztype,
+                        tree.constructor,
+                        localEnv,
+                        new ResultInfo(pkind, newMethodTemplate(syms.voidType, finalargtypes, typeargtypes)));
+            }
+            Type owntype = (tree.constructor != null && tree.constructor.kind == MTH) ?
+                                clazztype : types.createErrorType(tree.type);
+            result = check(tree, owntype, KindSelector.VAL, resultInfo, false);
+            chk.validate(tree.typeargs, localEnv);
+        }
+
     /** Make an attributed null check tree.
      */
     public JCExpression makeNullCheck(JCExpression arg) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,6 +63,11 @@
      */
     boolean isSpeculative = false;
 
+    /**
+     *  Is this an attribution environment for an anonymous class instantiated using <> ?
+     */
+    boolean isAnonymousDiamond = false;
+
     /** Are arguments to current function applications boxed into an array for varargs?
      */
     Resolve.MethodResolutionPhase pendingResolutionPhase = null;
@@ -100,6 +105,7 @@
         info.defaultSuperCallSite = defaultSuperCallSite;
         info.isSerializable = isSerializable;
         info.isSpeculative = isSpeculative;
+        info.isAnonymousDiamond = isAnonymousDiamond;
         return info;
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Mon Mar 30 17:09:14 2015 +0530
@@ -32,6 +32,8 @@
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Attribute.Compound;
 import com.sun.tools.javac.jvm.*;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -84,6 +86,7 @@
     private boolean suppressAbortOnBadClassFile;
     private boolean enableSunApiLintControl;
     private final JavaFileManager fileManager;
+    private final Source source;
     private final Profile profile;
     private final boolean warnOnAccessToSensitiveMembers;
 
@@ -122,11 +125,12 @@
         lint = Lint.instance(context);
         fileManager = context.get(JavaFileManager.class);
 
-        Source source = Source.instance(context);
+        source = Source.instance(context);
         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
         allowDefaultMethods = source.allowDefaultMethods();
         allowStrictMethodClashCheck = source.allowStrictMethodClashCheck();
         allowPrivateSafeVarargs = source.allowPrivateSafeVarargs();
+        allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
         complexInference = options.isSet("complexinference");
         warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
         suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
@@ -169,6 +173,10 @@
      */
     boolean allowPrivateSafeVarargs;
 
+    /** Switch: can diamond inference be used in anonymous instance creation ?
+     */
+    boolean allowDiamondWithAnonymousClassCreation;
+
     /** Switch: -complexinference option set?
      */
     boolean complexInference;
@@ -773,10 +781,9 @@
         if (!TreeInfo.isDiamond(tree) ||
                 t.isErroneous()) {
             return checkClassType(tree.clazz.pos(), t, true);
-        } else if (tree.def != null) {
+        } else if (tree.def != null && !allowDiamondWithAnonymousClassCreation) {
             log.error(tree.clazz.pos(),
-                    "cant.apply.diamond.1",
-                    t, diags.fragment("diamond.and.anon.class", t));
+                    Errors.CantApplyDiamond1(t, Fragments.DiamondAndAnonClassNotSupportedInSource(source.name)));
             return types.createErrorType(t);
         } else if (t.tsym.type.getTypeArguments().isEmpty()) {
             log.error(tree.clazz.pos(),
@@ -794,6 +801,59 @@
         }
     }
 
+    /** Check that the type inferred using the diamond operator does not contain
+     *  non-denotable types such as captured types or intersection types.
+     *  @param t the type inferred using the diamond operator
+     *  @return  the (possibly empty) list of non-denotable types.
+     */
+    List<Type> checkDiamondDenotable(ClassType t) {
+        ListBuffer<Type> buf = new ListBuffer<>();
+        for (Type arg : t.getTypeArguments()) {
+            if (!diamondTypeChecker.visit(arg, null)) {
+                buf.append(arg);
+            }
+        }
+        return buf.toList();
+    }
+        // where
+
+        /** diamondTypeChecker: A type visitor that descends down the given type looking for non-denotable
+         *  types. The visit methods return false as soon as a non-denotable type is encountered and true
+         *  otherwise.
+         */
+        private static final Types.SimpleVisitor<Boolean, Void> diamondTypeChecker = new Types.SimpleVisitor<Boolean, Void>() {
+            @Override
+            public Boolean visitType(Type t, Void s) {
+                return true;
+            }
+            @Override
+            public Boolean visitClassType(ClassType t, Void s) {
+                if (t.isCompound()) {
+                    return false;
+                }
+                for (Type targ : t.getTypeArguments()) {
+                    if (!visit(targ, s)) {
+                        return false;
+                    }
+                }
+                return true;
+            }
+            @Override
+            public Boolean visitCapturedType(CapturedType t, Void s) {
+                return false;
+            }
+
+            @Override
+            public Boolean visitArrayType(ArrayType t, Void s) {
+                return visit(t.elemtype, s);
+            }
+
+            @Override
+            public Boolean visitWildcardType(WildcardType t, Void s) {
+                return visit(t.type, s);
+            }
+        };
+
     void checkVarargsMethodDecl(Env<AttrContext> env, JCMethodDecl tree) {
         MethodSymbol m = tree.sym;
         if (!allowSimplifiedVarargs) return;
@@ -1917,7 +1977,7 @@
      *                      for errors.
      *  @param m            The overriding method.
      */
-    void checkOverride(JCMethodDecl tree, MethodSymbol m) {
+    void checkOverride(Env<AttrContext> env, JCMethodDecl tree, MethodSymbol m) {
         ClassSymbol origin = (ClassSymbol)m.owner;
         if ((origin.flags() & ENUM) != 0 && names.finalize.equals(m.name))
             if (m.overrides(syms.enumFinalFinalize, origin, types, false)) {
@@ -1934,7 +1994,12 @@
             }
         }
 
-        if (m.attribute(syms.overrideType.tsym) != null && !isOverrider(m)) {
+        // Check if this method must override a super method due to being annotated with @Override
+        // or by virtue of being a member of a diamond inferred anonymous class. Latter case is to
+        // be treated "as if as they were annotated" with @Override.
+        boolean mustOverride = m.attribute(syms.overrideType.tsym) != null ||
+                (env.info.isAnonymousDiamond && !m.isConstructor() && !m.isPrivate());
+        if (mustOverride && !isOverrider(m)) {
             DiagnosticPosition pos = tree.pos();
             for (JCAnnotation a : tree.getModifiers().annotations) {
                 if (a.annotationType.type.tsym == syms.overrideType.tsym) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Mon Mar 30 17:09:14 2015 +0530
@@ -26,6 +26,7 @@
 package com.sun.tools.javac.comp;
 
 import com.sun.source.tree.LambdaExpressionTree.BodyKind;
+import com.sun.source.tree.NewClassTree;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Type.TypeMapping;
 import com.sun.tools.javac.comp.Resolve.ResolveError;
@@ -81,6 +82,8 @@
     final Log log;
     final Symtab syms;
     final TreeMaker make;
+    final TreeCopier<Void> treeCopier;
+    final TypeMapping<Void> deferredCopier;
     final Types types;
     final Flow flow;
     final Names names;
@@ -125,6 +128,35 @@
                     return "Empty deferred context!";
                 }
             };
+
+        // For speculative attribution, skip the class definition in <>.
+        treeCopier =
+            new TreeCopier<Void>(make) {
+                @Override @DefinedBy(Api.COMPILER_TREE)
+                public JCTree visitNewClass(NewClassTree node, Void p) {
+                    JCNewClass t = (JCNewClass) node;
+                    if (TreeInfo.isDiamond(t)) {
+                        JCExpression encl = copy(t.encl, p);
+                        List<JCExpression> typeargs = copy(t.typeargs, p);
+                        JCExpression clazz = copy(t.clazz, p);
+                        List<JCExpression> args = copy(t.args, p);
+                        JCClassDecl def = null;
+                        return make.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
+                    } else {
+                        return super.visitNewClass(node, p);
+                    }
+                }
+            };
+        deferredCopier = new TypeMapping<Void> () {
+                @Override
+                public Type visitType(Type t, Void v) {
+                    if (t.hasTag(DEFERRED)) {
+                        DeferredType dt = (DeferredType) t;
+                        return new DeferredType(treeCopier.copy(dt.tree), dt.env);
+                    }
+                    return t;
+                }
+            };
     }
 
     /** shared tree for stuck expressions */
@@ -364,7 +396,7 @@
      * disabled during speculative type-checking.
      */
     JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
-        return attribSpeculative(tree, env, resultInfo, new TreeCopier<>(make),
+        return attribSpeculative(tree, env, resultInfo, treeCopier,
                 (newTree)->new DeferredAttrDiagHandler(log, newTree));
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -192,6 +192,7 @@
         localEnv.info.isSelfCall = false;
         localEnv.info.lint = null; // leave this to be filled in by Attr,
                                    // when annotations have been processed
+        localEnv.info.isAnonymousDiamond = TreeInfo.isDiamond(env.tree);
         return localEnv;
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Mar 30 17:09:14 2015 +0530
@@ -2555,7 +2555,8 @@
                               boolean allowBoxing,
                               boolean useVarargs) {
         Symbol bestSoFar = methodNotFound;
-        for (final Symbol sym : site.tsym.members().getSymbolsByName(names.init)) {
+        TypeSymbol tsym = site.tsym.isInterface() ? syms.objectType.tsym : site.tsym;
+        for (final Symbol sym : tsym.members().getSymbolsByName(names.init)) {
             //- System.out.println(" e " + e.sym);
             if (sym.kind == MTH &&
                 (sym.flags_field & SYNTHETIC) == 0) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Mar 30 17:09:14 2015 +0530
@@ -2010,6 +2010,16 @@
 compiler.misc.diamond.non.generic=\
     cannot use ''<>'' with non-generic class {0}
 
+# 0: list of type, 1: message segment
+compiler.misc.diamond.invalid.arg=\
+    type argument {0} inferred for {1} is not allowed in this context\n\
+    inferred argument is not expressible in the Signature attribute
+
+# 0: list of type, 1: message segment
+compiler.misc.diamond.invalid.args=\
+    type arguments {0} inferred for {1} are not allowed in this context\n\
+    inferred arguments are not expressible in the Signature attribute
+
 # 0: unused
 compiler.misc.diamond.and.explicit.params=\
     cannot use ''<>'' with explicit type parameters for constructor
@@ -2271,10 +2281,6 @@
 compiler.misc.varargs.clash.with=\
     {0} in {1} overrides {2} in {3}
 
-# 0: unused
-compiler.misc.diamond.and.anon.class=\
-    cannot use ''<>'' with anonymous inner classes
-
 # 0: symbol kind, 1: symbol, 2: symbol, 3: message segment
 compiler.misc.inapplicable.method=\
     {0} {1}.{2} is not applicable\n\
@@ -2284,6 +2290,11 @@
 # Diagnostics for language feature changes
 ########################################
 # 0: string
+compiler.misc.diamond.and.anon.class.not.supported.in.source=\
+    cannot use ''<>'' with anonymous inner classes in -source {0}\n\
+    (use -source 9 or higher to enable ''<>'' with anonymous inner classes)
+
+# 0: string
 compiler.err.unsupported.binary.lit=\
     binary literals are not supported in -source {0}\n\
     (use -source 7 or higher to enable binary literals)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -190,6 +190,18 @@
         }
     }
 
+    /** Return true if the given tree represents a type elided anonymous class instance creation. */
+    public static boolean isAnonymousDiamond(JCTree tree) {
+        switch(tree.getTag()) {
+            case NEWCLASS:  {
+                JCNewClass nc = (JCNewClass)tree;
+                return nc.def != null && isDiamond(nc.clazz);
+            }
+            case ANNOTATED_TYPE: return isAnonymousDiamond(((JCAnnotatedType)tree).underlyingType);
+            default: return false;
+        }
+    }
+
     public static boolean isEnumInit(JCTree tree) {
         switch (tree.getTag()) {
             case VARDEF:
--- a/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8042251
+ * @bug 8042251 8062373
  * @summary Testing InnerClasses_attribute of inner classes in anonymous class.
  * @library /tools/lib /tools/javac/lib ../lib
  * @build InnerClassesTestBase TestResult TestBase InMemoryFileManager ToolBox
@@ -73,6 +73,6 @@
     public void getAdditionalFlags(Map<String, Set<String>> class2Flags, ClassType type, Modifier... flags) {
         super.getAdditionalFlags(class2Flags, type, flags);
         class2Flags.put("Anonymous", getFlags(currentClassType, Arrays.asList(flags)));
-        class2Flags.put("1", new HashSet<>());
+        class2Flags.put("1", new HashSet<>() {});
     }
 }
--- a/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,8 +21,10 @@
  * questions.
  */
 
-// key: compiler.misc.diamond.and.anon.class
+// key: compiler.misc.diamond.and.anon.class.not.supported.in.source
 // key: compiler.err.cant.apply.diamond.1
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 8
 
 import java.util.*;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/DiamondAndNonDenotableTypes.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.misc.diamond
+// key: compiler.err.cant.apply.diamond.1
+// key: compiler.misc.diamond.invalid.arg
+// key: compiler.misc.diamond.invalid.args
+
+import java.util.*;
+
+class DiamondAndNonDenotableType<T> {
+    DiamondAndNonDenotableType(T t) {}
+}
+
+class DiamondAndNonDenotableTypes<T, S> {
+    DiamondAndNonDenotableTypes(T t, S s) {}
+    void m() {
+        List<?> wl = null;
+        new DiamondAndNonDenotableTypes<>(wl, wl) {};
+        new DiamondAndNonDenotableType<>(wl) {};
+    };
+}
--- a/langtools/test/tools/javac/failover/CheckAttributedTree.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6970584 8006694
+ * @bug 6970584 8006694 8062373
  * @summary assorted position errors in compiler syntax trees
  *  temporarily workaround combo tests are causing time out in several platforms
  * @library ../lib
@@ -290,7 +290,7 @@
             }
             public void finished(TaskEvent e) { }
         });
-
+        int i = 0;
         try {
             Iterable<? extends CompilationUnitTree> trees = task.parse();
 //            JavaCompiler c = JavaCompiler.instance(((JavacTaskImpl) task).getContext());
@@ -308,7 +308,7 @@
                    if (def.hasTag(CLASSDEF) &&
                            analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) {
                        //System.err.println("Adding pair..." + cu.sourcefile + " " + ((JCTree.JCClassDecl) def).name);
-                       res.add(new Pair<>(cu, def));
+                       res.add((i++ % 2) == 0 ? new Pair<>(cu, def) {} : new Pair<>(cu, def));
                    }
                }
             }
--- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,11 +1,12 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939780 7020044 8009459 8021338 8064365
+ * @bug 6939780 7020044 8009459 8021338 8064365 8062373
  *
- * @summary  add a warning to detect diamond sites
+ * @summary  add a warning to detect diamond sites (including anonymous class instance creation at source >= 9)
  * @author mcimadamore
  * @compile/ref=T6939780_7.out -Xlint:-options -source 7 T6939780.java -XDrawDiagnostics -XDfind=diamond
- * @compile/ref=T6939780_8.out T6939780.java -XDrawDiagnostics -XDfind=diamond
+ * @compile/ref=T6939780_8.out -Xlint:-options -source 8 T6939780.java -XDrawDiagnostics -XDfind=diamond
+ * @compile/ref=T6939780_9.out -Xlint:-options -source 9 T6939780.java -XDrawDiagnostics -XDfind=diamond
  *
  */
 
--- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
-T6939780.java:21:28: compiler.warn.diamond.redundant.args
-T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
-T6939780.java:30:19: compiler.warn.diamond.redundant.args
-T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:22:28: compiler.warn.diamond.redundant.args
+T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:31:19: compiler.warn.diamond.redundant.args
+T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
 4 warnings
--- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out	Mon Mar 30 17:09:14 2015 +0530
@@ -1,7 +1,7 @@
-T6939780.java:20:33: compiler.warn.diamond.redundant.args
-T6939780.java:21:28: compiler.warn.diamond.redundant.args
-T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
-T6939780.java:29:19: compiler.warn.diamond.redundant.args
+T6939780.java:21:33: compiler.warn.diamond.redundant.args
+T6939780.java:22:28: compiler.warn.diamond.redundant.args
+T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
 T6939780.java:30:19: compiler.warn.diamond.redundant.args
-T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:31:19: compiler.warn.diamond.redundant.args
+T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
 6 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_9.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,13 @@
+T6939780.java:21:33: compiler.warn.diamond.redundant.args
+T6939780.java:22:28: compiler.warn.diamond.redundant.args
+T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:24:33: compiler.warn.diamond.redundant.args
+T6939780.java:25:28: compiler.warn.diamond.redundant.args
+T6939780.java:26:28: compiler.warn.diamond.redundant.args
+T6939780.java:30:19: compiler.warn.diamond.redundant.args
+T6939780.java:31:19: compiler.warn.diamond.redundant.args
+T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:33:19: compiler.warn.diamond.redundant.args
+T6939780.java:34:19: compiler.warn.diamond.redundant.args
+T6939780.java:35:19: compiler.warn.diamond.redundant.args
+12 warnings
--- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6996914 7020044
+ * @bug 6996914 7020044 8062373
  * @summary  Diamond inference: problem when accessing protected constructor
  * @run main T6996914a
  */
@@ -53,6 +53,17 @@
         }
     }
 
+    enum DiamondKind {
+        STANDARD("new Foo<>();"),
+        ANON("new Foo<>() {};");
+
+        String expr;
+
+        DiamondKind(String expr) {
+            this.expr = expr;
+        }
+    }
+
     enum ConstructorKind {
         PACKAGE(""),
         PROTECTED("protected"),
@@ -93,14 +104,14 @@
         final static String sourceStub =
                         "#I\n" +
                         "class Test {\n" +
-                        "  Foo<String> fs = new Foo<>();\n" +
+                        "  Foo<String> fs = #D\n" +
                         "}\n";
 
         String source;
 
-        public ClientClass(PackageKind pk) {
+        public ClientClass(PackageKind pk, DiamondKind dk) {
             super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
-            source = sourceStub.replace("#I", pk.importDecl);
+            source = sourceStub.replace("#I", pk.importDecl).replace("#D", dk.expr);
         }
 
         @Override
@@ -112,20 +123,22 @@
     public static void main(String... args) throws Exception {
         for (PackageKind pk : PackageKind.values()) {
             for (ConstructorKind ck : ConstructorKind.values()) {
-                    compileAndCheck(pk, ck);
+                for (DiamondKind dk : DiamondKind.values()) {
+                    compileAndCheck(pk, ck, dk);
+                }
             }
         }
     }
 
-    static void compileAndCheck(PackageKind pk, ConstructorKind ck) throws Exception {
+    static void compileAndCheck(PackageKind pk, ConstructorKind ck, DiamondKind dk) throws Exception {
         FooClass foo = new FooClass(pk, ck);
-        ClientClass client = new ClientClass(pk);
+        ClientClass client = new ClientClass(pk, dk);
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         ErrorListener el = new ErrorListener();
         JavacTask ct = (JavacTask)tool.getTask(null, null, el,
                 null, null, Arrays.asList(foo, client));
         ct.analyze();
-        if (el.errors > 0 == check(pk, ck)) {
+        if (el.errors > 0 == check(pk, ck, dk)) {
             String msg = el.errors > 0 ?
                 "Error compiling files" :
                 "No error when compiling files";
@@ -133,9 +146,10 @@
         }
     }
 
-    static boolean check(PackageKind pk, ConstructorKind ck) {
+    static boolean check(PackageKind pk, ConstructorKind ck, DiamondKind dk) {
         switch (pk) {
-            case A: return ck == ConstructorKind.PUBLIC;
+            case A: return ck == ConstructorKind.PUBLIC ||
+                    (ck  == ConstructorKind.PROTECTED && dk == DiamondKind.ANON);
             case DEFAULT: return ck != ConstructorKind.PRIVATE;
             default: throw new AssertionError("Unknown package kind");
         }
--- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6996914 7020044
+ * @bug 6996914 7020044 8062373
  * @summary  Diamond inference: problem when accessing protected constructor
  * @compile T6996914b.java
  */
@@ -35,4 +35,5 @@
 
 class Test {
     Super<String,Integer> ssi1 = new Super<>(1, "", 2);
+    Super<String,Integer> ssi2 = new Super<>(1, "", 2) {};
 }
--- a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 8065986
+ * @bug 8065986 8062373
  *
  * @summary Compiler fails to NullPointerException when calling super with Object<>()
  * @compile/fail/ref=T8065986b.out T8065986b.java -XDrawDiagnostics
@@ -29,5 +29,12 @@
         this(cond ? o1 : o2);
     }
 
+    T8065986b(int x) {
+        this(new Object<>() {});
+    }
+
+    T8065986b(int x, int y) {
+        this(new ArrayList<>() {});
+    }
     static void m() { }
 }
--- a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,8 @@
 T8065986b.java:13:24: compiler.err.cant.apply.diamond.1: java.lang.Object, (compiler.misc.diamond.non.generic: java.lang.Object)
-T8065986b.java:17:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList<java.lang.Object>,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-T8065986b.java:21:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @435,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-T8065986b.java:25:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @516,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-T8065986b.java:29:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @603,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-5 errors
+T8065986b.java:17:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList<java.lang.Object>,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:21:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @443,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:25:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @524,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:29:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @611,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:33:24: compiler.err.cant.apply.diamond.1: java.lang.Object, (compiler.misc.diamond.non.generic: java.lang.Object)
+T8065986b.java:37:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList<java.lang.Object>,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+7 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/MultipleInferenceHooksTest.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8062373
+ * @summary Test that <>(){} works fine without verify error when there are multiple post inference hooks.
+ */
+
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Set;
+
+public class MultipleInferenceHooksTest {
+    public static void main(String[] args) {
+        Set<String> result = Collections.newSetFromMap(new IdentityHashMap<>() {});
+    }
+}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  Check that diamond fails when inference violates declared bounds
  *           (basic test with nested class, generic/non-generic constructors)
@@ -25,5 +25,16 @@
         Neg01<? extends String> n6 = new Neg01<>("", "");
         Neg01<?> n7 = new Neg01<>("", "");
         Foo<? super String> n8 = new Neg01<>("", "");
+
+        Neg01<String> n9 = new Neg01<>("", ""){};
+        Neg01<? extends String> n10 = new Neg01<>("", ""){};
+        Neg01<?> n11 = new Neg01<>("", ""){};
+        Neg01<? super String> n12 = new Neg01<>("", ""){};
+
+        Neg01<String> n13 = new Neg01<>(""){};
+        Neg01<? extends String> n14 = new Neg01<>(""){};
+        Neg01<?> n15 = new Neg01<>(""){};
+        Neg01<? super String> n16 = new Neg01<>(""){};
+
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.out	Mon Mar 30 17:09:14 2015 +0530
@@ -12,4 +12,18 @@
 Neg01.java:26:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
 Neg01.java:27:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
 Neg01.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-14 errors
+Neg01.java:29:15: compiler.err.not.within.bounds: java.lang.String, X
+Neg01.java:29:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:30:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg01.java:30:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:31:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:32:15: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg01.java:32:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:34:15: compiler.err.not.within.bounds: java.lang.String, X
+Neg01.java:34:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:35:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg01.java:35:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:36:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:37:15: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg01.java:37:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+28 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  Check that diamond fails when inference violates declared bounds
  *           (test with nested class, qualified/simple type expressions)
@@ -26,6 +26,16 @@
         Foo<? extends String> f6 = new Foo<>("", "");
         Foo<?> f7 = new Foo<>("", "");
         Foo<? super String> f8 = new Foo<>("", "");
+
+        Foo<String> f9 = new Foo<>(""){};
+        Foo<? extends String> f10 = new Foo<>(""){};
+        Foo<?> f11 = new Foo<>(""){};
+        Foo<? super String> f12 = new Foo<>(""){};
+
+        Foo<String> f13 = new Foo<>("", ""){};
+        Foo<? extends String> f14 = new Foo<>("", ""){};
+        Foo<?> f15 = new Foo<>("", ""){};
+        Foo<? super String> f16 = new Foo<>("", ""){};
     }
 
     void testQualified() {
@@ -38,5 +48,15 @@
         Foo<? extends String> f6 = new Neg02.Foo<>("", "");
         Foo<?> f7 = new Neg02.Foo<>("", "");
         Foo<? super String> f8 = new Neg02.Foo<>("", "");
+
+        Foo<String> f9 = new Neg02.Foo<>(""){};
+        Foo<? extends String> f10 = new Neg02.Foo<>(""){};
+        Foo<?> f11 = new Neg02.Foo<>(""){};
+        Foo<? super String> f12 = new Neg02.Foo<>(""){};
+
+        Foo<String> f13 = new Neg02.Foo<>("", ""){};
+        Foo<? extends String> f14 = new Neg02.Foo<>("", ""){};
+        Foo<?> f15 = new Neg02.Foo<>("", ""){};
+        Foo<? super String> f16 = new Neg02.Foo<>("", ""){};
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.out	Mon Mar 30 17:09:14 2015 +0530
@@ -12,18 +12,46 @@
 Neg02.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
 Neg02.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, X
 Neg02.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:32:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:37:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-28 errors
+Neg02.java:30:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:30:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:31:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:31:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:32:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:33:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:33:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:35:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:35:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:36:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:37:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:38:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:38:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:42:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:42:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:43:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:43:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:44:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:45:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:45:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:47:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:47:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:48:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:48:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:49:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:50:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:50:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:52:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:52:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:53:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:53:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:54:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:55:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:55:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:57:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:57:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:58:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:58:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:59:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:60:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:60:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+56 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  Check that diamond fails when inference violates declared bounds
  *           (test with inner class, qualified/simple type expressions)
@@ -26,6 +26,16 @@
         Foo<? extends String> f6 = new Foo<>("", "");
         Foo<?> f7 = new Foo<>("", "");
         Foo<? super String> f8 = new Foo<>("", "");
+
+        Foo<String> f9 = new Foo<>(""){};
+        Foo<? extends String> f10 = new Foo<>(""){};
+        Foo<?> f11 = new Foo<>(""){};
+        Foo<? super String> f12 = new Foo<>(""){};
+
+        Foo<String> f13 = new Foo<>("", ""){};
+        Foo<? extends String> f14 = new Foo<>("", ""){};
+        Foo<?> f15 = new Foo<>("", ""){};
+        Foo<? super String> f16 = new Foo<>("", ""){};
     }
 
     void testQualified_1() {
@@ -38,6 +48,16 @@
         Foo<? extends String> f6 = new Neg03<U>.Foo<>("", "");
         Foo<?> f7 = new Neg03<U>.Foo<>("", "");
         Foo<? super String> f8 = new Neg03<U>.Foo<>("", "");
+
+        Foo<String> f9 = new Neg03<U>.Foo<>(""){};
+        Foo<? extends String> f10 = new Neg03<U>.Foo<>(""){};
+        Foo<?> f11 = new Neg03<U>.Foo<>(""){};
+        Foo<? super String> f12 = new Neg03<U>.Foo<>(""){};
+
+        Foo<String> f13 = new Neg03<U>.Foo<>("", ""){};
+        Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){};
+        Foo<?> f15 = new Neg03<U>.Foo<>("", ""){};
+        Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){};
     }
 
     void testQualified_2(Neg03<U> n) {
@@ -50,5 +70,15 @@
         Foo<? extends String> f6 = n.new Foo<>("", "");
         Foo<?> f7 = n.new Foo<>("", "");
         Foo<? super String> f8 = n.new Foo<>("", "");
+
+        Foo<String> f9 = n.new Foo<>(""){};
+        Foo<? extends String> f10 = n.new Foo<>(""){};
+        Foo<?> f11 = n.new Foo<>(""){};
+        Foo<? super String> f12 = n.new Foo<>(""){};
+
+        Foo<String> f13 = n.new Foo<>("", ""){};
+        Foo<? extends String> f14 = n.new Foo<>("", ""){};
+        Foo<?> f15 = n.new Foo<>("", ""){};
+        Foo<? super String> f16 = n.new Foo<>("", ""){};
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.out	Mon Mar 30 17:09:14 2015 +0530
@@ -12,32 +12,74 @@
 Neg03.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
 Neg03.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, V
 Neg03.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:32:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:37:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:44:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:44:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:45:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:45:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:46:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:47:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:49:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:49:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:50:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:50:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:51:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:52:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:52:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-42 errors
+Neg03.java:30:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:30:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:31:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:31:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:32:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:33:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:33:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:35:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:35:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:36:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:37:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:38:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:38:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:42:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:42:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:43:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:43:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:44:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:45:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:45:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:47:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:47:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:48:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:48:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:49:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:50:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:50:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:52:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:52:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:53:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:53:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:54:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:55:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:55:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:57:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:57:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:58:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:58:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:59:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:60:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:60:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:64:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:64:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:65:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:65:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:66:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:67:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:67:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:69:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:69:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:70:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:70:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:71:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:72:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:72:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:74:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:74:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:75:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:75:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:76:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:77:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:77:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:79:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:79:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:80:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:80:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:81:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:82:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:82:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+84 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  Check that diamond fails when inference violates declared bounds
  *           (test with local class, qualified/simple type expressions)
@@ -25,5 +25,15 @@
         Foo<? extends String> n6 = new Foo<>("", "");
         Foo<?> n7 = new Foo<>("", "");
         Foo<? super String> n8 = new Foo<>("", "");
+
+        Foo<String> n9 = new Foo<>(""){};
+        Foo<? extends String> n10 = new Foo<>(""){};
+        Foo<?> n11 = new Foo<>(""){};
+        Foo<? super String> n12 = new Foo<>(""){};
+
+        Foo<String> n13 = new Foo<>("", ""){};
+        Foo<? extends String> n14 = new Foo<>("", ""){};
+        Foo<?> n15 = new Foo<>("", ""){};
+        Foo<? super String> n16 = new Foo<>("", ""){};
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.out	Mon Mar 30 17:09:14 2015 +0530
@@ -12,4 +12,18 @@
 Neg04.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
 Neg04.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V
 Neg04.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-14 errors
+Neg04.java:29:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg04.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg04.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg04.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:34:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg04.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg04.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg04.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+28 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  Check that usage of rare types doesn't cause spurious diamond diagnostics
  * @author mcimadamore
@@ -25,6 +25,16 @@
         Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>("", "");
         Neg05<?>.Foo<?> f7 = new Neg05.Foo<>("", "");
         Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>("", "");
+
+        Neg05<?>.Foo<String> f9 = new Neg05.Foo<>(""){};
+        Neg05<?>.Foo<? extends String> f10 = new Neg05.Foo<>(""){};
+        Neg05<?>.Foo<?> f11 = new Neg05.Foo<>(""){};
+        Neg05<?>.Foo<? super String> f12 = new Neg05.Foo<>(""){};
+
+        Neg05<?>.Foo<String> f13 = new Neg05.Foo<>("", ""){};
+        Neg05<?>.Foo<? extends String> f14 = new Neg05.Foo<>("", ""){};
+        Neg05<?>.Foo<?> f15 = new Neg05.Foo<>("", ""){};
+        Neg05<?>.Foo<? super String> f16 = new Neg05.Foo<>("", ""){};
     }
 
     void testRare_2(Neg05 n) {
@@ -37,5 +47,15 @@
         Neg05<?>.Foo<? extends String> f6 = n.new Foo<>("", "");
         Neg05<?>.Foo<?> f7 = n.new Foo<>("", "");
         Neg05<?>.Foo<? super String> f8 = n.new Foo<>("", "");
+
+        Neg05<?>.Foo<String> f9 = n.new Foo<>(""){};
+        Neg05<?>.Foo<? extends String> f10 = n.new Foo<>(""){};
+        Neg05<?>.Foo<?> f11 = n.new Foo<>(""){};
+        Neg05<?>.Foo<? super String> f12 = n.new Foo<>(""){};
+
+        Neg05<?>.Foo<String> f13 = n.new Foo<>("", ""){};
+        Neg05<?>.Foo<? extends String> f14 = n.new Foo<>("", ""){};
+        Neg05<?>.Foo<?> f15 = n.new Foo<>("", ""){};
+        Neg05<?>.Foo<? super String> f16 = n.new Foo<>("", ""){};
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.out	Mon Mar 30 17:09:14 2015 +0530
@@ -6,20 +6,52 @@
 Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param
 Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param
 Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:31:37: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:31:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
-Neg05.java:32:47: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:32:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
-Neg05.java:33:32: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:33:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
-Neg05.java:34:45: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:34:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
-Neg05.java:36:37: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:36:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
-Neg05.java:37:47: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:37:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
-Neg05.java:38:32: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:38:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
-Neg05.java:39:45: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:39:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
-24 errors
+Neg05.java:29:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:29:35: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:30:59: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:30:46: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:31:44: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:31:31: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:32:57: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:32:44: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:34:49: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:34:36: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:35:59: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:35:46: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:36:44: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:36:31: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:37:57: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:37:44: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:41:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:41:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:42:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:42:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:43:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:43:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:44:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:44:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+Neg05.java:46:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:46:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:47:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:47:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:48:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:48:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:49:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:49:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+Neg05.java:51:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:51:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:52:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:52:55: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:53:33: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:53:40: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:54:46: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:54:53: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+Neg05.java:56:38: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:56:45: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:57:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:57:55: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:58:33: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:58:40: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:59:46: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:59:53: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+56 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  Check that diamond works where LHS is supertype of RHS (nilary constructor)
  * @author mcimadamore
@@ -9,9 +9,13 @@
  */
 
 class Neg06 {
+   interface ISuperFoo<X> {}
+   interface IFoo<X extends Number> extends ISuperFoo<X> {}
 
    static class CSuperFoo<X> {}
    static class CFoo<X extends Number> extends CSuperFoo<X> {}
 
+   ISuperFoo<String> isf = new IFoo<>() {};
    CSuperFoo<String> csf1 = new CFoo<>();
+   CSuperFoo<String> csf2 = new CFoo<>() {};
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.out	Mon Mar 30 17:09:14 2015 +0530
@@ -1,2 +1,6 @@
-Neg06.java:16:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
-1 error
+Neg06.java:18:36: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
+Neg06.java:18:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, Neg06.ISuperFoo<java.lang.String>)
+Neg06.java:19:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
+Neg06.java:20:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
+Neg06.java:20:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: <any>, Neg06.CSuperFoo<java.lang.String>)
+5 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  Check that diamond works where LHS is supertype of RHS (1-ary constructor)
  * @author mcimadamore
@@ -15,4 +15,5 @@
    }
 
    SuperFoo<String> sf1 = new Foo<>("");
+   SuperFoo<String> sf2 = new Foo<>("") {};
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.out	Mon Mar 30 17:09:14 2015 +0530
@@ -1,2 +1,3 @@
 Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)
-1 error
+Neg07.java:18:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)
+2 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,10 +1,10 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 7020044
+ * @bug 7020044 8062373
  *
- * @summary  Check that diamond is not allowed with anonymous inner class expressions
+ * @summary  Check that diamond is not allowed with anonymous inner class expressions at source < 9
  * @author Maurizio Cimadamore
- * @compile/fail/ref=Neg09.out Neg09.java -XDrawDiagnostics
+ * @compile/fail/ref=Neg09.out Neg09.java -source 8 -XDrawDiagnostics
  *
  */
 
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.out	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,7 @@
-Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class: Neg09.Member<X>)
-Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class: Neg09.Nested<X>)
-Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class: Neg09.Member<X>)
-Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class: Neg09.Nested<X>)
+- compiler.warn.source.no.bootclasspath: 1.8
+Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
+Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
+Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
+Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
 4 errors
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary  Test diamond + anonymous classes with non-denotable types
+ * @author mcimadamore
+ * @compile/fail/ref=Neg12.out Neg12.java -XDrawDiagnostics
+ *
+ */
+
+ class Neg12 {
+    static class Foo<X> {
+        Foo(X x) {  }
+    }
+
+    static class DoubleFoo<X,Y> {
+        DoubleFoo(X x,Y y) {  }
+    }
+
+    static class TripleFoo<X,Y,Z> {
+        TripleFoo(X x,Y y,Z z) {  }
+    }
+
+    Foo<? extends Integer> fi = new Foo<>(1);
+    Foo<?> fw = new Foo<>(fi) {}; // Error.
+    Foo<?> fw1 = new Foo<>(fi); // OK.
+    Foo<? extends Double> fd = new Foo<>(3.0);
+    DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd) {}; // Error.
+    DoubleFoo<?,?> dw1 = new DoubleFoo<>(fi,fd); // OK.
+    Foo<String> fs = new Foo<>("one");
+    TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs) {}; // Error.
+    TripleFoo<?,?,?> tw1 = new TripleFoo<>(fi,fd,fs); // OK.
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,4 @@
+Neg12.java:25:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.Foo), (compiler.misc.diamond.invalid.arg: Neg12.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>, (compiler.misc.diamond: Neg12.Foo))
+Neg12.java:28:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.DoubleFoo), (compiler.misc.diamond.invalid.args: Neg12.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg12.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg12.DoubleFoo))
+Neg12.java:31:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.TripleFoo), (compiler.misc.diamond.invalid.args: Neg12.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg12.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg12.TripleFoo))
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg13.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,49 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary  Test diamond + anonymous classes with abstract super type
+ * @author sadayapalam
+ * @compile/fail/ref=Neg13.out Neg13.java -XDrawDiagnostics
+ *
+ */
+class Neg13 {
+
+    static abstract class A<T> {
+        abstract void foo();
+    }
+
+    static void foo(A<String> as) {}
+
+    public static void main(String[] args) {
+
+        // Method invocation context - good <>(){}
+        foo(new A<>() {
+            public void foo() {}
+        });
+
+        // Assignment context - good <>(){}
+        A<?> aq = new A<>() {
+            public void foo() {}
+        };
+
+        // When the anonymous type subtypes an abstract class but is missing definitions for
+        // abstract methods, expect no overload resolution error, but an attribution error
+        // while attributing anonymous class body.
+
+
+        // Method invocation context - bad <>(){}
+        foo(new A<>() {
+        });
+
+        // Assignment invocation context - bad <>(){}
+        aq = new A<>() {
+        };
+
+        // Method invocation context - bad <>()
+        foo(new A<>());
+
+        // Assignment invocation context - bad <>()
+        aq = new A<>();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg13.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,5 @@
+Neg13.java:36:23: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg13$3, foo(), Neg13.A
+Neg13.java:40:24: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg13$4, foo(), Neg13.A
+Neg13.java:44:13: compiler.err.abstract.cant.be.instantiated: Neg13.A
+Neg13.java:47:14: compiler.err.abstract.cant.be.instantiated: Neg13.A
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg14.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,49 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary  Test diamond + anonymous classes with super type being an interface.
+ * @author sadayapalam
+ * @compile/fail/ref=Neg14.out Neg14.java -XDrawDiagnostics
+ *
+ */
+class Neg14 {
+
+    static interface A<T> {
+        void foo();
+    }
+
+    static void foo(A<String> as) {}
+
+    public static void main(String[] args) {
+
+        // Method invocation context - good <>(){}
+        foo(new A<>() {
+            public void foo() {}
+        });
+
+        // Assignment context - good <>(){}
+        A<?> aq = new A<>() {
+            public void foo() {}
+        };
+
+        // When the anonymous type subtypes an interface but is missing definitions for
+        // abstract methods, expect no overload resolution error, but an attribution error
+        // while attributing anonymous class body.
+
+
+        // Method invocation context - bad <>(){}
+        foo(new A<>() {
+        });
+
+        // Assignment invocation context - bad <>(){}
+        aq = new A<>() {
+        };
+
+        // Method invocation context - bad <>()
+        foo(new A<>());
+
+        // Assignment invocation context - bad <>()
+        aq = new A<>();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg14.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,5 @@
+Neg14.java:36:23: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg14$3, foo(), Neg14.A
+Neg14.java:40:24: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg14$4, foo(), Neg14.A
+Neg14.java:44:13: compiler.err.abstract.cant.be.instantiated: Neg14.A
+Neg14.java:47:14: compiler.err.abstract.cant.be.instantiated: Neg14.A
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg15.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,66 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary  Test that javac complains when a <> inferred class contains a public method that does override a supertype method.
+ * @author sadayapalam
+ * @compile/fail/ref=Neg15.out Neg15.java -XDrawDiagnostics
+ *
+ */
+
+class Neg15 {
+
+    interface Predicate<T> {
+        default boolean test(T t) {
+            System.out.println("Default method");
+            return false;
+        }
+    }
+
+
+    static void someMethod(Predicate<? extends Number> p) {
+        if (!p.test(null))
+            throw new Error("Blew it");
+    }
+
+    public static void main(String[] args) {
+
+        someMethod(new Predicate<Integer>() {
+            public boolean test(Integer n) {
+                System.out.println("Override");
+                return true;
+            }
+            boolean test(Integer n, int i) {
+                System.out.println("Override");
+                return true;
+            }
+            protected boolean test(Integer n, int i, int j) {
+                System.out.println("Override");
+                return true;
+            }
+            private boolean test(Integer n, int i, long j) {
+                System.out.println("Override");
+                return true;
+            }
+        });
+
+        someMethod(new Predicate<>() {
+            public boolean test(Integer n) { // bad.
+                System.out.println("Override");
+                return true;
+            }
+            boolean test(Integer n, int i) { // bad, package access.
+                System.out.println("Override");
+                return true;
+            }
+            protected boolean test(Integer n, int i, int j) { // bad, protected access.
+                System.out.println("Override");
+                return true;
+            }
+            private boolean test(Integer n, int i, long j) { // OK, private method.
+                System.out.println("Override");
+                return true;
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg15.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,4 @@
+Neg15.java:48:28: compiler.err.method.does.not.override.superclass
+Neg15.java:52:21: compiler.err.method.does.not.override.superclass
+Neg15.java:56:31: compiler.err.method.does.not.override.superclass
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg16.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,36 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that javac does not recommend a diamond site that would result in error.
+ * @compile/ref=Neg16.out -Xlint:-options Neg16.java -XDrawDiagnostics -XDfind=diamond
+ */
+
+class Neg16 {
+
+   interface Predicate<T> {
+        default boolean test(T t) {
+            System.out.println("Default method");
+            return false;
+        }
+    }
+
+    static void someMethod(Predicate<? extends Number> p) {
+        if (!p.test(null))
+            throw new Error("Blew it");
+    }
+
+    public static void main(String[] args) {
+        someMethod(new Predicate<Integer>() { // cannot convert to diamond
+            public boolean test(Integer n) {
+                System.out.println("Override");
+                return true;
+            }
+        });
+        someMethod(new Predicate<Number>() { // can convert to diamond.
+            public boolean test(Number n) {
+                System.out.println("Override");
+                return true;
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg16.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,2 @@
+Neg16.java:29:33: compiler.warn.diamond.redundant.args
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg17.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that the anonymous class constructor appears to returns a Foo<T>, when it actually returns a Anon$1. (status as of now - may change in future)
+ * @compile/fail/ref=Neg17.out Neg17.java -XDrawDiagnostics
+ */
+
+import java.util.Collections;
+
+abstract class Neg17<T> {
+
+   abstract void m();
+
+   public static void main(String[] args) {
+       Collections.singletonList(new Neg17<>() { void m() {} }).get(0).m(); // good.
+       Collections.singletonList(new Neg17<>() {
+                 void m() {}
+                 private void n() {}
+           }).get(0).n(); // bad unknown method n()
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg17.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,2 @@
+Neg17.java:19:21: compiler.err.cant.resolve.location.args: kindname.method, n, , , (compiler.misc.location: kindname.class, Neg17<java.lang.Object>, null)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg18.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that inaccessible vararg element type triggers an error during diamond inferred anonymous class instance creation.
+ * @compile/fail/ref=Neg18.out Neg18.java -XDrawDiagnostics
+ */
+
+import java.util.Collections;
+import pkg.Neg18_01;
+
+class Neg18 {
+
+   public static void main(String[] args) {
+        new Neg18_01<>() {};
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg18.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,3 @@
+Neg18.java:14:21: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: pkg.Neg18_01), (compiler.misc.inaccessible.varargs.type: pkg.Neg18_01.PkgPrivate, kindname.class, Neg18))
+Neg18.java:14:26: compiler.err.not.def.public.cant.access: pkg.Neg18_01.PkgPrivate, pkg.Neg18_01
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg19.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that when inaccessible types constitute the inferred types of <> the compiler complains.
+ * @compile/fail/ref=Neg19.out Neg19.java -XDrawDiagnostics
+ */
+
+
+
+class Neg19 {
+    public static void main(String[] args) {
+        new Neg19_01<Neg19>().foo(new Neg19_01<>()); // OK.
+        new Neg19_01<Neg19>().foo(new Neg19_01<>() {}); // ERROR.
+    }
+}
+
+class Neg19_01<T> {
+    private class Private {}
+    Neg19_01() {}
+    void foo(Neg19_01<Private> p) {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg19.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,2 @@
+Neg19.java:13:34: compiler.err.report.access: Neg19_01.Private, private, Neg19_01
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/pkg/Neg18_01.java	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg;
+
+public class Neg18_01<T> {
+    static class PkgPrivate {}
+    public Neg18_01 (PkgPrivate ... pp) {}
+}
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos01.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos01.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  basic test for diamond (generic/non-generic constructors)
  * @author mcimadamore
@@ -48,7 +48,17 @@
         Pos01<? extends Integer> p6 = new Pos01<>(1, "");
         Pos01<?> p7 = new Pos01<>(1, "");
         Pos01<? super Integer> p8 = new Pos01<>(1, "");
-    }
+
+        Pos01<Integer> p9 = new Pos01<>(1){};
+        Pos01<? extends Integer> p10 = new Pos01<>(1){};
+        Pos01<?> p11 = new Pos01<>(1){};
+        Pos01<? super Integer> p12 = new Pos01<>(1){};
+
+        Pos01<Integer> p13 = new Pos01<>(1, ""){};
+        Pos01<? extends Integer> p14= new Pos01<>(1, ""){};
+        Pos01<?> p15 = new Pos01<>(1, ""){};
+        Pos01<? super Integer> p16 = new Pos01<>(1, ""){};
+   }
 
     public static void main(String[] args) {
         Pos01<String> p1 = new Pos01<>("");
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos02.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos02.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  basic test for diamond (simple/qualified type-expressions)
  * @author mcimadamore
@@ -48,6 +48,16 @@
         Foo<? extends Integer> f6 = new Foo<>(1, "");
         Foo<?> f7 = new Foo<>(1, "");
         Foo<? super Integer> f8 = new Foo<>(1, "");
+
+        Foo<Integer> f9 = new Foo<>(1){};
+        Foo<? extends Integer> f10 = new Foo<>(1){};
+        Foo<?> f11 = new Foo<>(1){};
+        Foo<? super Integer> f12 = new Foo<>(1){};
+
+        Foo<Integer> f13 = new Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = new Foo<>(1, ""){};
+        Foo<?> f15 = new Foo<>(1, ""){};
+        Foo<? super Integer> f16 = new Foo<>(1, ""){};
     }
 
     void testQualified() {
@@ -60,6 +70,16 @@
         Foo<? extends Integer> f6 = new Pos02.Foo<>(1, "");
         Foo<?> f7 = new Pos02.Foo<>(1, "");
         Foo<? super Integer> f8 = new Pos02.Foo<>(1, "");
+
+        Foo<Integer> f9 = new Pos02.Foo<>(1){};
+        Foo<? extends Integer> f10 = new Pos02.Foo<>(1){};
+        Foo<?> f11 = new Pos02.Foo<>(1){};
+        Foo<? super Integer> f12 = new Pos02.Foo<>(1){};
+
+        Foo<Integer> f13 = new Pos02.Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = new Pos02.Foo<>(1, ""){};
+        Foo<?> f15 = new Pos02.Foo<>(1, ""){};
+        Foo<? super Integer> f16 = new Pos02.Foo<>(1, ""){};
     }
 
     public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos03.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos03.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  basic test for diamond (simple/qualified type-expressions, member inner)
  * @author mcimadamore
@@ -49,6 +49,16 @@
         Foo<? extends Integer> f6 = new Foo<>(1, "");
         Foo<?> f7 = new Foo<>(1, "");
         Foo<? super Integer> f8 = new Foo<>(1, "");
+
+        Foo<Integer> f9 = new Foo<>(1){};
+        Foo<? extends Integer> f10 = new Foo<>(1){};
+        Foo<?> f11 = new Foo<>(1){};
+        Foo<? super Integer> f12 = new Foo<>(1){};
+
+        Foo<Integer> f13 = new Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = new Foo<>(1, ""){};
+        Foo<?> f15 = new Foo<>(1, ""){};
+        Foo<? super Integer> f16 = new Foo<>(1, ""){};
     }
 
     void testQualified_1() {
@@ -61,6 +71,16 @@
         Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1, "");
         Foo<?> f7 = new Pos03<U>.Foo<>(1, "");
         Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1, "");
+
+        Foo<Integer> f9 = new Pos03<U>.Foo<>(1){};
+        Foo<? extends Integer> f10 = new Pos03<U>.Foo<>(1){};
+        Foo<?> f11 = new Pos03<U>.Foo<>(1){};
+        Foo<? super Integer> f12 = new Pos03<U>.Foo<>(1){};
+
+        Foo<Integer> f13 = new Pos03<U>.Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = new Pos03<U>.Foo<>(1, ""){};
+        Foo<?> f15 = new Pos03<U>.Foo<>(1, ""){};
+        Foo<? super Integer> f16 = new Pos03<U>.Foo<>(1, ""){};
     }
 
     void testQualified_2(Pos03<U> p) {
@@ -73,6 +93,16 @@
         Foo<? extends Integer> f6 = p.new Foo<>(1, "");
         Foo<?> f7 = p.new Foo<>(1, "");
         Foo<? super Integer> f8 = p.new Foo<>(1, "");
+
+        Foo<Integer> f9 = p.new Foo<>(1){};
+        Foo<? extends Integer> f10 = p.new Foo<>(1){};
+        Foo<?> f11 = p.new Foo<>(1){};
+        Foo<? super Integer> f12 = p.new Foo<>(1){};
+
+        Foo<Integer> f13 = p.new Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = p.new Foo<>(1, ""){};
+        Foo<?> f15 = p.new Foo<>(1, ""){};
+        Foo<? super Integer> f16 = p.new Foo<>(1, ""){};
     }
 
     public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos04.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos04.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  basic test for diamond (simple/qualified type-expressions, local class)
  * @author mcimadamore
@@ -48,6 +48,16 @@
         Foo<? extends Integer> p6 = new Foo<>(1, "");
         Foo<?> p7 = new Foo<>(1, "");
         Foo<? super Integer> p8 = new Foo<>(1, "");
+
+        Foo<Integer> p9 = new Foo<>(1){};
+        Foo<? extends Integer> p10 = new Foo<>(1){};
+        Foo<?> p11 = new Foo<>(1){};
+        Foo<? super Integer> p12 = new Foo<>(1){};
+
+        Foo<Integer> p13 = new Foo<>(1, ""){};
+        Foo<? extends Integer> p14 = new Foo<>(1, ""){};
+        Foo<?> p15 = new Foo<>(1, ""){};
+        Foo<? super Integer> p16 = new Foo<>(1, ""){};
     }
 
     public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos05.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos05.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,10 @@
 
 /*
  * @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
  *
  * @summary  Check that 'complex' inference sometimes works in method context
  * @author mcimadamore
- * @compile Pos05.java
  *
  */
 
@@ -41,5 +40,11 @@
 
     void test() {
         m(new Foo<>(1));
+        m(new Foo<>(1) {});
     }
+
+    public static void main(String [] args) {
+        new Pos05().test();
+    }
+
 }
--- a/langtools/test/tools/javac/generics/inference/8055963/T8055963.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/generics/inference/8055963/T8055963.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,10 @@
 
 /**
  * @test
- * @bug 8055963
+ * @bug 8055963 8062373
  * @summary Inference failure with nested invocation
- * @compile T8055963.java
  */
-class T8055963 {
+public class T8055963 {
 
     static class C<T> {}
 
@@ -38,4 +37,8 @@
     void test() {
         C<String> cs = choose(new C<String>(), new C<>());
     }
+
+    public static void main(String [] args) {
+      new T8055963().test();
+    }
 }
--- a/langtools/test/tools/javac/lambda/8066974/T8066974.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/lambda/8066974/T8066974.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 8066974
+ * @bug 8066974 8062373
  * @summary Compiler doesn't infer method's generic type information in lambda body
  * @compile/fail/ref=T8066974.out -XDrawDiagnostics T8066974.java
  */
@@ -34,11 +34,13 @@
         map(p->p.m(rt));
         map(mapper(rt));
         map(new ThrowingMapper<>(rt));
+        map(new ThrowingMapper<>(rt) {});
     }
 
     void testChecked(CheckedThrowing ct) {
         map(p->p.m(ct));
         map(mapper(ct));
         map(new ThrowingMapper<>(ct));
+        map(new ThrowingMapper<>(ct) {});
     }
 }
--- a/langtools/test/tools/javac/lambda/8066974/T8066974.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/lambda/8066974/T8066974.out	Mon Mar 30 17:09:14 2015 +0530
@@ -1,4 +1,5 @@
-T8066974.java:40:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
 T8066974.java:41:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-T8066974.java:42:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-3 errors
+T8066974.java:42:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T8066974.java:43:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T8066974.java:44:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+4 errors
--- a/langtools/test/tools/javac/lambda/TargetType46.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType46.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 8003280
+ * @bug 8003280 8062373
  * @summary Add lambda tests
  *  compiler doesn't report accessibility problem due to inaccessible target
  * @compile/fail/ref=TargetType46.out -XDrawDiagnostics TargetType46.java
@@ -22,6 +22,7 @@
         outer.m(()->{}); //access error
         outer.m(this::g); //access error
         outer.m(new ArrayList<>()); //ok
+        outer.m(new ArrayList<>() {}); // access error
         outer.m(Collections.emptyList()); //ok
     }
 
--- a/langtools/test/tools/javac/lambda/TargetType46.out	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType46.out	Mon Mar 30 17:09:14 2015 +0530
@@ -1,3 +1,4 @@
 TargetType46.java:22:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
 TargetType46.java:23:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
-2 errors
+TargetType46.java:25:16: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
+3 errors
--- a/langtools/test/tools/javac/lambda/TargetType68.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType68.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug 8010303
+ * @bug 8010303 8062373
  * @summary Graph inference: missing incorporation step causes spurious inference error
- * @compile TargetType68.java
+ * @compile/fail/ref=TargetType68.out -XDrawDiagnostics TargetType68.java
  */
 import java.util.*;
 
@@ -58,6 +58,6 @@
             List<XYChart.Data<Number, Number>> data_2 = new ArrayList<>();
             numberChart.getData().setAll(
                     Arrays.asList(new XYChart.Series<>("Data", FXCollections.observableList(data_1)),
-                    new XYChart.Series<>("Data", FXCollections.observableList(data_2))));
+                    new XYChart.Series<>("Data", FXCollections.observableList(data_2)) {}));
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType68.out	Mon Mar 30 17:09:14 2015 +0530
@@ -0,0 +1,3 @@
+TargetType68.java:61:32: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series
+TargetType68.java:61:39: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series
+2 errors
--- a/langtools/test/tools/javac/lambda/TargetType69.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType69.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8010303
+ * @bug 8010303 8062373
  * @summary Graph inference: missing incorporation step causes spurious inference error
  * @compile TargetType69.java
  */
@@ -47,5 +47,6 @@
 
     void test(Function<Integer, Integer> classifier, Function<Integer, Map<Integer, List<Integer>>> coll) {
         exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier));
+        exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier) {});
     }
 }
--- a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -108,9 +108,10 @@
     public static List<Pair<TestKind, Hierarchy>> generateCases() {
         ArrayList<Pair<TestKind,Hierarchy>> list = new ArrayList<>();
         HierarchyGenerator hg = new HierarchyGenerator();
+        int i = 0;
         for (TestKind tk : TestKind.values()) {
             for (Hierarchy hs : tk.getHierarchy(hg)) {
-                list.add(new Pair<>(tk, hs));
+                list.add((i++ % 2) == 0 ? new Pair<>(tk, hs) {} : new Pair<>(tk, hs));
             }
         }
         return list;
--- a/langtools/test/tools/javac/scope/DupUnsharedTest.java	Sat Mar 28 10:18:27 2015 -0700
+++ b/langtools/test/tools/javac/scope/DupUnsharedTest.java	Mon Mar 30 17:09:14 2015 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@
     }
 
     void runScopeContentTest() throws Exception {
-        Set<Symbol> expected = Collections.newSetFromMap(new IdentityHashMap<>());
+        Set<Symbol> expected = Collections.newSetFromMap(new IdentityHashMap<>() {});
         Set<Symbol> notExpected = Collections.newSetFromMap(new IdentityHashMap<>());
         WriteableScope s1 = WriteableScope.create(symtab.rootPackage);
         ClassSymbol acceptSym = symtab.arrayClass;
@@ -105,7 +105,7 @@
     }
 
     Set<Symbol> toSet(Iterable<Symbol> it) {
-        Set<Symbol> result = Collections.newSetFromMap(new IdentityHashMap<>());
+        Set<Symbol> result = Collections.newSetFromMap(new IdentityHashMap<>() {});
 
         for (Symbol sym : it) {
             result.add(sym);