Merge
authorlana
Tue, 06 Oct 2015 08:43:24 -0700
changeset 32914 fe2f2101a692
parent 32907 bd87d6d4b81c (current diff)
parent 32913 586e23a1b116 (diff)
child 32915 eb290482d42f
Merge
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java	Tue Oct 06 08:43:24 2015 -0700
@@ -29,6 +29,7 @@
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.comp.ArgumentAttr.LocalCacheContext;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCBlock;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
@@ -54,7 +55,6 @@
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
-import com.sun.tools.javac.util.Filter;
 import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
 import com.sun.tools.javac.util.List;
@@ -72,7 +72,6 @@
 import static com.sun.tools.javac.code.Flags.SYNTHETIC;
 import static com.sun.tools.javac.code.TypeTag.CLASS;
 import static com.sun.tools.javac.tree.JCTree.Tag.APPLY;
-import static com.sun.tools.javac.tree.JCTree.Tag.CLASSDEF;
 import static com.sun.tools.javac.tree.JCTree.Tag.METHODDEF;
 import static com.sun.tools.javac.tree.JCTree.Tag.NEWCLASS;
 import static com.sun.tools.javac.tree.JCTree.Tag.TYPEAPPLY;
@@ -88,6 +87,7 @@
     final Log log;
     final Attr attr;
     final DeferredAttr deferredAttr;
+    final ArgumentAttr argumentAttr;
     final TreeMaker make;
     final Names names;
     private final boolean allowDiamondWithAnonymousClassCreation;
@@ -107,6 +107,7 @@
         log = Log.instance(context);
         attr = Attr.instance(context);
         deferredAttr = DeferredAttr.instance(context);
+        argumentAttr = ArgumentAttr.instance(context);
         make = TreeMaker.instance(context);
         names = Names.instance(context);
         Options options = Options.instance(context);
@@ -363,8 +364,13 @@
 
             TreeMapper treeMapper = new TreeMapper(context);
             //TODO: to further refine the analysis, try all rewriting combinations
-            deferredAttr.attribSpeculative(fakeBlock, env, attr.statInfo, treeMapper,
-                    t -> new AnalyzeDeferredDiagHandler(context));
+            LocalCacheContext localCacheContext = argumentAttr.withLocalCacheContext();
+            try {
+                deferredAttr.attribSpeculative(fakeBlock, env, attr.statInfo, treeMapper,
+                        t -> new AnalyzeDeferredDiagHandler(context));
+            } finally {
+                localCacheContext.leave();
+            }
 
             context.treeMap.entrySet().forEach(e -> {
                 context.treesToAnalyzer.get(e.getKey())
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ArgumentAttr.java	Tue Oct 06 08:43:24 2015 -0700
@@ -109,9 +109,6 @@
     /** Cache for argument types; behavior is influences by the currrently selected cache policy. */
     Map<UniquePos, ArgumentType<?>> argumentTypeCache = new LinkedHashMap<>();
 
-    /** Cache policy: should argument types be cached? */
-    private CachePolicy cachePolicy = CachePolicy.CACHE;
-
     public static ArgumentAttr instance(Context context) {
         ArgumentAttr instance = context.get(methodAttrKey);
         if (instance == null)
@@ -160,12 +157,29 @@
     }
 
     /**
-     * Sets given ache policy and returns current policy.
+     * Returns a local caching context in which argument types can safely be cached without
+     * the risk of polluting enclosing contexts. This is useful when attempting speculative
+     * attribution of potentially erroneous expressions, which could end up polluting the cache.
+     */
+    LocalCacheContext withLocalCacheContext() {
+        return new LocalCacheContext();
+    }
+
+    /**
+     * Local cache context; this class keeps track of the previous cache and reverts to it
+     * when the {@link LocalCacheContext#leave()} method is called.
      */
-    CachePolicy withCachePolicy(CachePolicy newPolicy) {
-        CachePolicy oldPolicy = this.cachePolicy;
-        this.cachePolicy = newPolicy;
-        return oldPolicy;
+    class LocalCacheContext {
+        Map<UniquePos, ArgumentType<?>> prevCache;
+
+        public LocalCacheContext() {
+            this.prevCache = argumentTypeCache;
+            argumentTypeCache = new HashMap<>();
+        }
+
+        public void leave() {
+            argumentTypeCache = prevCache;
+        }
     }
 
     /**
@@ -226,9 +240,7 @@
             setResult(that, cached.dup(that, env));
         } else {
             Z res = argumentTypeFactory.get();
-            if (cachePolicy == CachePolicy.CACHE) {
-                argumentTypeCache.put(pos, res);
-            }
+            argumentTypeCache.put(pos, res);
             setResult(that, res);
         }
     }
@@ -341,7 +353,7 @@
                 speculativeTypes.put(resultInfo, t);
                 return t;
             } else {
-                if (!env.info.isSpeculative && cachePolicy == CachePolicy.CACHE) {
+                if (!env.info.isSpeculative) {
                     argumentTypeCache.remove(new UniquePos(dt.tree));
                 }
                 return deferredAttr.basicCompleter.complete(dt, resultInfo, deferredAttrContext);
@@ -663,17 +675,4 @@
             return source.getFile().getName() + " @ " + source.getLineNumber(pos);
         }
     }
-
-    /**
-     * Argument type caching policy.
-     */
-    enum CachePolicy {
-        /** Cache argument types. */
-        CACHE,
-        /**
-         * Don't cache argument types. This is useful when performing speculative attribution on
-         * a tree that is known to contain erroneous info.
-         */
-        NO_CACHE;
-    }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Oct 06 08:43:24 2015 -0700
@@ -2215,7 +2215,7 @@
                 inferenceContext.addFreeTypeListener(List.of(tree.constructorType, tree.clazz.type),
                         instantiatedContext -> {
                             tree.constructorType = instantiatedContext.asInstType(tree.constructorType);
-                            clazz.type = instantiatedContext.asInstType(clazz.type);
+                            tree.clazz.type = clazz.type = instantiatedContext.asInstType(clazz.type);
                             ResultInfo prevResult = this.resultInfo;
                             try {
                                 this.resultInfo = resultInfoForClassDefinition;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Tue Oct 06 08:43:24 2015 -0700
@@ -808,7 +808,7 @@
      */
     List<Type> checkDiamondDenotable(ClassType t) {
         ListBuffer<Type> buf = new ListBuffer<>();
-        for (Type arg : t.getTypeArguments()) {
+        for (Type arg : t.allparams()) {
             if (!diamondTypeChecker.visit(arg, null)) {
                 buf.append(arg);
             }
@@ -831,7 +831,7 @@
                 if (t.isCompound()) {
                     return false;
                 }
-                for (Type targ : t.getTypeArguments()) {
+                for (Type targ : t.allparams()) {
                     if (!visit(targ, s)) {
                         return false;
                     }
@@ -842,13 +842,16 @@
             @Override
             public Boolean visitTypeVar(TypeVar t, Void s) {
                 /* Any type variable mentioned in the inferred type must have been declared as a type parameter
-                  (i.e cannot have been produced by capture conversion (5.1.10) or by inference (18.4)
+                  (i.e cannot have been produced by inference (18.4))
                 */
                 return t.tsym.owner.type.getTypeArguments().contains(t);
             }
 
             @Override
             public Boolean visitCapturedType(CapturedType t, Void s) {
+                /* Any type variable mentioned in the inferred type must have been declared as a type parameter
+                  (i.e cannot have been produced by capture conversion (5.1.10))
+                */
                 return false;
             }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Tue Oct 06 08:43:24 2015 -0700
@@ -29,7 +29,7 @@
 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.ArgumentAttr.CachePolicy;
+import com.sun.tools.javac.comp.ArgumentAttr.LocalCacheContext;
 import com.sun.tools.javac.comp.Resolve.ResolveError;
 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
 import com.sun.tools.javac.tree.*;
@@ -777,14 +777,14 @@
 
             boolean canLambdaBodyCompleteNormally(JCLambda tree) {
                 List<JCVariableDecl> oldParams = tree.params;
-                CachePolicy prevPolicy = argumentAttr.withCachePolicy(CachePolicy.NO_CACHE);
+                LocalCacheContext localCacheContext = argumentAttr.withLocalCacheContext();
                 try {
                     tree.params = tree.params.stream()
                             .map(vd -> make.VarDef(vd.mods, vd.name, make.Erroneous(), null))
                             .collect(List.collector());
                     return attribSpeculativeLambda(tree, env, attr.unknownExprInfo).canCompleteNormally;
                 } finally {
-                    argumentAttr.withCachePolicy(prevPolicy);
+                    localCacheContext.leave();
                     tree.params = oldParams;
                 }
             }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java	Tue Oct 06 08:43:24 2015 -0700
@@ -194,7 +194,7 @@
 
             dependencies.push((ClassSymbol) sym, CompletionCause.MEMBER_ENTER);
             try {
-                queue = completeClass.runPhase(List.of(typeEnvs.get((ClassSymbol) sym)));
+                queue = completeClass.completeEnvs(List.of(typeEnvs.get((ClassSymbol) sym)));
             } finally {
                 dependencies.pop();
             }
@@ -237,9 +237,22 @@
             this.next = next;
         }
 
-        public List<Env<AttrContext>> runPhase(List<Env<AttrContext>> envs) {
+        public final List<Env<AttrContext>> completeEnvs(List<Env<AttrContext>> envs) {
             boolean firstToComplete = queue.isEmpty();
 
+            doCompleteEnvs(envs);
+
+            if (firstToComplete) {
+                List<Env<AttrContext>> out = queue.toList();
+
+                queue.clear();
+                return next != null ? next.completeEnvs(out) : out;
+            } else {
+                return List.nil();
+            }
+        }
+
+        protected void doCompleteEnvs(List<Env<AttrContext>> envs) {
             for (Env<AttrContext> env : envs) {
                 JCClassDecl tree = (JCClassDecl)env.tree;
 
@@ -249,7 +262,7 @@
                 DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
                 try {
                     dependencies.push(env.enclClass.sym, phaseName);
-                    doRunPhase(env);
+                    runPhase(env);
                 } catch (CompletionFailure ex) {
                     chk.completionError(tree.pos(), ex);
                 } finally {
@@ -258,18 +271,9 @@
                     log.useSource(prev);
                 }
             }
-
-            if (firstToComplete) {
-                List<Env<AttrContext>> out = queue.toList();
+        }
 
-                queue.clear();
-                return next != null ? next.runPhase(out) : out;
-            } else {
-                return List.nil();
-            }
-       }
-
-        protected abstract void doRunPhase(Env<AttrContext> env);
+        protected abstract void runPhase(Env<AttrContext> env);
     }
 
     private final ImportsPhase completeClass = new ImportsPhase();
@@ -289,7 +293,7 @@
                 (imp, cf) -> chk.completionError(imp.pos(), cf);
 
         @Override
-        protected void doRunPhase(Env<AttrContext> env) {
+        protected void runPhase(Env<AttrContext> env) {
             JCClassDecl tree = env.enclClass;
             ClassSymbol sym = tree.sym;
 
@@ -699,14 +703,29 @@
             }
     }
 
-    private final class HierarchyPhase extends AbstractHeaderPhase {
+    private final class HierarchyPhase extends AbstractHeaderPhase implements Completer {
 
         public HierarchyPhase() {
             super(CompletionCause.HIERARCHY_PHASE, new HeaderPhase());
         }
 
         @Override
-        protected void doRunPhase(Env<AttrContext> env) {
+        protected void doCompleteEnvs(List<Env<AttrContext>> envs) {
+            //The ClassSymbols in the envs list may not be in the dependency order.
+            //To get proper results, for every class or interface C, the supertypes of
+            //C must be processed by the HierarchyPhase phase before C.
+            //To achieve that, the HierarchyPhase is registered as the Completer for
+            //all the classes first, and then all the classes are completed.
+            for (Env<AttrContext> env : envs) {
+                env.enclClass.sym.completer = this;
+            }
+            for (Env<AttrContext> env : envs) {
+                env.enclClass.sym.complete();
+            }
+        }
+
+        @Override
+        protected void runPhase(Env<AttrContext> env) {
             JCClassDecl tree = env.enclClass;
             ClassSymbol sym = tree.sym;
             ClassType ct = (ClassType)sym.type;
@@ -760,6 +779,14 @@
                 }
                 return false;
             }
+
+        @Override
+        public void complete(Symbol sym) throws CompletionFailure {
+            Env<AttrContext> env = typeEnvs.get((ClassSymbol) sym);
+
+            super.doCompleteEnvs(List.of(env));
+        }
+
     }
 
     private final class HeaderPhase extends AbstractHeaderPhase {
@@ -769,7 +796,7 @@
         }
 
         @Override
-        protected void doRunPhase(Env<AttrContext> env) {
+        protected void runPhase(Env<AttrContext> env) {
             JCClassDecl tree = env.enclClass;
             ClassSymbol sym = tree.sym;
             ClassType ct = (ClassType)sym.type;
@@ -824,7 +851,7 @@
         }
 
         @Override
-        protected void doRunPhase(Env<AttrContext> env) {
+        protected void runPhase(Env<AttrContext> env) {
             JCClassDecl tree = env.enclClass;
             ClassSymbol sym = tree.sym;
             ClassType ct = (ClassType)sym.type;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Tue Oct 06 08:43:24 2015 -0700
@@ -320,9 +320,9 @@
 
 javac.msg.bug=\
 An exception has occurred in the compiler ({0}). \
-Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \
-after checking the database for duplicates. \
-Include your program and the following diagnostic in your report.  Thank you.
+Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) \
+after checking the Bug Database (http://bugs.java.com) for duplicates. \
+Include your program and the following diagnostic in your report. Thank you.
 
 javac.msg.io=\
 \n\nAn input/output error occurred.\n\
--- a/langtools/test/tools/javac/classfiles/attributes/LineNumberTable/LineNumberTestBase.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/test/tools/javac/classfiles/attributes/LineNumberTable/LineNumberTestBase.java	Tue Oct 06 08:43:24 2015 -0700
@@ -23,6 +23,7 @@
 
 import com.sun.tools.classfile.*;
 
+import java.nio.file.Paths;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -62,6 +63,7 @@
         boolean failed = false;
         for (TestCase testCase : testCases) {
             try {
+                writeToFileIfEnabled(Paths.get(testCase.getName() + ".java"), testCase.src);
                 Set<Integer> coveredLines = new HashSet<>();
                 for (JavaFileObject file : compile(testCase.src).getClasses().values()) {
                     ClassFile classFile = ClassFile.read(file.openInputStream());
--- a/langtools/test/tools/javac/classfiles/attributes/annotations/AnnotationsTestBase.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/test/tools/javac/classfiles/attributes/annotations/AnnotationsTestBase.java	Tue Oct 06 08:43:24 2015 -0700
@@ -218,7 +218,7 @@
                 String source = testCase.generateSource();
                 Path sourceFile = Paths.get(getClass().getSimpleName() + i + ".java");
                 addTestCase(sourceFile.toAbsolutePath().toString());
-                writeToFile(sourceFile, source);
+                writeToFileIfEnabled(sourceFile, source);
                 echo("Testing: " + sourceFile.toString());
                 try {
                     test(testCase, compile(source).getClasses());
--- a/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesTestBase.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesTestBase.java	Tue Oct 06 08:43:24 2015 -0700
@@ -26,8 +26,10 @@
 import com.sun.tools.classfile.InnerClasses_attribute;
 import com.sun.tools.classfile.InnerClasses_attribute.Info;
 
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -87,8 +89,13 @@
      */
     public void test(String classToTest, String...skipClasses) throws TestFailedException {
         try {
-            for (TestCase test : generateTestCases()) {
-                addTestCase(test.getSource());
+            String testName = getClass().getName();
+            List<TestCase> testCases = generateTestCases();
+            for (int i = 0; i < testCases.size(); ++i) {
+                TestCase test = testCases.get(i);
+                String testCaseName = testName + i + ".java";
+                addTestCase(testCaseName);
+                writeToFileIfEnabled(Paths.get(testCaseName), test.getSource());
                 test(classToTest, test, skipClasses);
             }
         } catch (Exception e) {
@@ -330,7 +337,7 @@
                     list.add(Arrays.asList(access, mod1, mod2));
                 }
                 if (mod1 == Modifier.EMPTY) {
-                    list.add(Arrays.asList(access));
+                    list.add(Collections.singletonList(access));
                 }
             }
         }
@@ -413,7 +420,7 @@
 
         private final String classType;
 
-        private ClassType(String clazz) {
+        ClassType(String clazz) {
             this.classType = clazz;
         }
 
@@ -435,7 +442,7 @@
 
         private final String str;
 
-        private Modifier(String str) {
+        Modifier(String str) {
             this.str = str;
         }
 
--- a/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java	Mon Oct 05 20:25:08 2015 -0700
+++ b/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java	Tue Oct 06 08:43:24 2015 -0700
@@ -44,6 +44,7 @@
 public class TestBase {
 
     public static final String LINE_SEPARATOR = System.lineSeparator();
+    public static final boolean isDumpOfSourceEnabled = Boolean.getBoolean("dump.src");
 
     private <S> InMemoryFileManager compile(
             List<String> options,
@@ -176,7 +177,9 @@
      * @throws ConstantPoolException if constant pool error occurs
      */
     public ClassFile readClassFile(File file) throws IOException, ConstantPoolException {
-        return readClassFile(new FileInputStream(file));
+        try (InputStream is = new FileInputStream(file)) {
+            return readClassFile(is);
+        }
     }
 
     public void assertEquals(Object actual, Object expected, String message) {
@@ -215,6 +218,14 @@
         }
     }
 
+    public void writeToFileIfEnabled(Path path, String source) throws IOException {
+        if (isDumpOfSourceEnabled) {
+            writeToFile(path, source);
+        } else {
+            System.err.println("Source dumping disabled. To enable, run the test with '-Ddump.src=true'");
+        }
+    }
+
     public File getSourceDir() {
         return new File(System.getProperty("test.src", "."));
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg21.java	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8132535
+ * @summary Compiler fails with diamond anonymous class creation with intersection bound of enclosing class.
+ * @compile/fail/ref=Neg21.out Neg21.java -XDrawDiagnostics
+ */
+
+public class Neg21 <T extends java.io.Serializable & Cloneable> {
+
+    class A <X>{}
+
+    public void foo(){
+        new Neg21<>().new A<>(){} ;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg21.out	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,2 @@
+Neg21.java:13:28: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg21.A), (compiler.misc.diamond.invalid.arg: java.lang.Object&java.io.Serializable&java.lang.Cloneable, (compiler.misc.diamond: Neg21.A))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg22.java	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8132535
+ * @summary Compiler fails with diamond anonymous class creation with intersection bound of enclosing class.
+ * @compile/fail/ref=Neg22.out Neg22.java -XDrawDiagnostics
+ */
+
+public class Neg22  {
+
+    class Outer<X extends Runnable & java.io.Serializable> {
+        class Inner<Y> { }
+    }
+
+    class Box<Z> {
+        Box(Z z) { }
+    }
+
+    {
+        new Box<>(new Outer<>().new Inner<>()) { };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg22.out	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,2 @@
+Neg22.java:19:16: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg22.Box), (compiler.misc.diamond.invalid.arg: Neg22.Outer<java.lang.Object&java.io.Serializable&java.lang.Runnable>.Inner<java.lang.Object>, (compiler.misc.diamond: Neg22.Box))
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg23.java	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8132535
+ * @summary Compiler fails with diamond anonymous class creation with intersection bound of enclosing class.
+ * @compile/fail/ref=Neg23.out Neg23.java -XDrawDiagnostics
+ */
+
+public class Neg23  {
+    {
+        new pkg.Neg23_01<>().new Inner<>();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg23.out	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,2 @@
+Neg23.java:10:39: compiler.err.not.def.public.cant.access: pkg.Neg23_02, pkg
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/pkg/Neg23_01.java	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,30 @@
+/*
+ * 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 Neg23_01<X extends Neg23_02> {
+    public class Inner<Y> { }
+}
+
+class Neg23_02 {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos08.java	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8133135
+ *
+ * @summary Compiler internall error (NPE) on anonymous class defined by qualified instance creation expression with diamond
+ * @author sadayapalam
+ * @compile Pos08.java
+ *
+ */
+
+class Pos08 {
+
+    static class List<T> {
+    }
+
+    static class FooOuter {
+        class Foo<T> {
+            public Foo(){}
+        }
+    }
+
+    public static <T> List<T> m(List<T> list, T item) {
+        return list;
+    }
+
+
+    public static void run() {
+        m(new List<FooOuter.Foo<String>>(), new FooOuter().new Foo<>(){ });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/importscope/T8075274/C.java	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,27 @@
+/*
+ * 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 P.Q;
+
+public class C extends D {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/importscope/T8075274/D.java	Tue Oct 06 08:43:24 2015 -0700
@@ -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 P.Q;
+
+public class D {
+  public interface I {
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/importscope/T8075274/Outer.java	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,43 @@
+/*
+ * 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 8075274
+ * @summary Ensuring order of imports or inputs does not affect compilability of the sources
+ * @compile C.java D.java Outer.java
+ * @compile C.java Outer.java D.java
+ * @compile D.java C.java Outer.java
+ * @compile D.java Outer.java C.java
+ * @compile Outer.java D.java C.java
+ * @compile Outer.java C.java D.java
+ */
+package P;
+
+import static P.Outer.Nested.*;
+import static P.Q.C.*;
+
+public class Outer {
+  public static class Nested implements I {
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/importscope/T8133235/A.java	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8133235
+ * @summary Ensuring order of inputs does not affect compilability of the sources
+ * @compile A.java B.java C.java D.java
+ * @compile A.java B.java D.java C.java
+ * @compile A.java C.java B.java D.java
+ * @compile A.java C.java D.java B.java
+ * @compile A.java D.java B.java C.java
+ * @compile A.java D.java C.java B.java
+ * @compile D.java A.java B.java C.java
+ * @compile D.java A.java C.java B.java
+ * @compile D.java B.java A.java C.java
+ * @compile D.java B.java C.java A.java
+ * @compile D.java C.java B.java A.java
+ * @compile D.java C.java A.java B.java
+ */
+package pkg;
+
+public class A {
+  public interface One {
+      public interface N2 {
+          public class N3 { }
+      }
+
+      public class Foo extends D {}
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/importscope/T8133235/B.java	Tue Oct 06 08:43:24 2015 -0700
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+import pkg.A;
+
+public class B extends A {
+  public static interface Two {
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/importscope/T8133235/C.java	Tue Oct 06 08:43:24 2015 -0700
@@ -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;
+
+import pkg.B.Two;
+
+public class C implements B.One {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/importscope/T8133235/D.java	Tue Oct 06 08:43:24 2015 -0700
@@ -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;
+
+import static pkg.C.*;
+
+public class D implements C.N2 {
+}