Merge
authorlana
Thu, 05 Nov 2015 13:42:20 -0800
changeset 33557 27b563ba49e8
parent 33550 5a0a9e942d79 (current diff)
parent 33556 a14a556cf2c9 (diff)
child 33558 fd0807825b82
Merge
--- a/langtools/make/gendata/Gendata-jdk.compiler.gmk	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/make/gendata/Gendata-jdk.compiler.gmk	Thu Nov 05 13:42:20 2015 -0800
@@ -23,6 +23,7 @@
 # questions.
 #
 
+include JarArchive.gmk
 include JavaCompilation.gmk
 include SetupJavaCompilers.gmk
 
@@ -52,9 +53,9 @@
 	    $(@D)
 	$(TOUCH) $@
 
-# Can't generate ct.sym directly into modules libs as the SetupArchive macro
+# Can't generate ct.sym directly into modules libs as the SetupJarArchive macro
 # creates meta data files in the output dir.
-$(eval $(call SetupArchive, CREATE_CTSYM, \
+$(eval $(call SetupJarArchive, CREATE_CTSYM, \
     DEPENDENCIES := $(SUPPORT_OUTPUTDIR)/symbols/ct.sym-files/_the.symbols, \
     SRCS := $(SUPPORT_OUTPUTDIR)/symbols/ct.sym-files, \
     SUFFIXES := .sig, \
--- a/langtools/make/test/sym/CreateSymbolsTest.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/make/test/sym/CreateSymbolsTest.java	Thu Nov 05 13:42:20 2015 -0800
@@ -56,21 +56,21 @@
         Path compileDir = testClasses.resolve("data");
         deleteRecursively(compileDir);
         Files.createDirectories(compileDir);
-        Path createSymbols = findFile("../../make/src/build/tools/symbolgenerator/CreateSymbols.java");
+        Path createSymbols = findFile("../../make/src/classes/build/tools/symbolgenerator/CreateSymbols.java");
 
         if (createSymbols == null) {
             System.err.println("Warning: cannot find CreateSymbols, skipping.");
             return ;
         }
 
-        Path createTestImpl = findFile("../../make/test/tools/sym/CreateSymbolsTestImpl.java");
+        Path createTestImpl = findFile("../../make/test/sym/CreateSymbolsTestImpl.java");
 
         if (createTestImpl == null) {
-            System.err.println("Warning: cannot find CreateSymbols, skipping.");
+            System.err.println("Warning: cannot find CreateSymbolsTestImpl, skipping.");
             return ;
         }
 
-        Path toolBox = findFile("../../langtools/test/tools/lib/ToolBox.java");
+        Path toolBox = findFile("../../test/tools/lib/ToolBox.java");
 
         if (toolBox == null) {
             System.err.println("Warning: cannot find ToolBox, skipping.");
--- a/langtools/make/test/sym/CreateSymbolsTestImpl.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/make/test/sym/CreateSymbolsTestImpl.java	Thu Nov 05 13:42:20 2015 -0800
@@ -41,12 +41,12 @@
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
-import symbolgenerator.CreateSymbols;
-import symbolgenerator.CreateSymbols.ClassDescription;
-import symbolgenerator.CreateSymbols.ClassList;
-import symbolgenerator.CreateSymbols.CtSymKind;
-import symbolgenerator.CreateSymbols.ExcludeIncludeList;
-import symbolgenerator.CreateSymbols.VersionDescription;
+import build.tools.symbolgenerator.CreateSymbols;
+import build.tools.symbolgenerator.CreateSymbols.ClassDescription;
+import build.tools.symbolgenerator.CreateSymbols.ClassList;
+import build.tools.symbolgenerator.CreateSymbols.CtSymKind;
+import build.tools.symbolgenerator.CreateSymbols.ExcludeIncludeList;
+import build.tools.symbolgenerator.CreateSymbols.VersionDescription;
 
 public class CreateSymbolsTestImpl {
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Thu Nov 05 13:42:20 2015 -0800
@@ -583,11 +583,13 @@
         return false;
     }
 
+    /**
+     * A compound type is a special class type whose supertypes are used to store a list
+     * of component types. There are two kinds of compound types: (i) intersection types
+     * {@see IntersectionClassType} and (ii) union types {@see UnionClassType}.
+     */
     public boolean isCompound() {
-        // Compound types can't have a (non-terminal) completer.  Calling
-        // flags() will complete the symbol causing the compiler to load
-        // classes unnecessarily.  This led to regression 6180021.
-        return tsym.isCompleted() && (tsym.flags() & COMPOUND) != 0;
+        return false;
     }
 
     public boolean isIntersection() {
@@ -1200,6 +1202,11 @@
             return true;
         }
 
+        @Override
+        public boolean isCompound() {
+            return getLub().isCompound();
+        }
+
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public TypeKind getKind() {
             return TypeKind.UNION;
@@ -1242,6 +1249,11 @@
             return Collections.unmodifiableList(getExplicitComponents());
         }
 
+        @Override
+        public boolean isCompound() {
+            return true;
+        }
+
         public List<Type> getComponents() {
             return interfaces_field.prepend(supertype_field);
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java	Thu Nov 05 13:42:20 2015 -0800
@@ -1495,10 +1495,10 @@
                     }
                 }
 
-                if (t.isIntersection() || s.isIntersection()) {
-                    return !t.isIntersection() ?
-                            visitIntersectionType((IntersectionClassType)s, t, true) :
-                            visitIntersectionType((IntersectionClassType)t, s, false);
+                if (t.isCompound() || s.isCompound()) {
+                    return !t.isCompound() ?
+                            visitCompoundType((ClassType)s, t, true) :
+                            visitCompoundType(t, s, false);
                 }
 
                 if (s.hasTag(CLASS) || s.hasTag(ARRAY)) {
@@ -1576,9 +1576,9 @@
                 return false;
             }
 
-            boolean visitIntersectionType(IntersectionClassType ict, Type s, boolean reverse) {
+            boolean visitCompoundType(ClassType ct, Type s, boolean reverse) {
                 Warner warn = noWarnings;
-                for (Type c : ict.getComponents()) {
+                for (Type c : directSupertypes(ct)) {
                     warn.clear();
                     if (reverse ? !isCastable(s, c, warn) : !isCastable(c, s, warn))
                         return false;
@@ -2399,14 +2399,9 @@
                         ? interfaces(type)
                         : interfaces(type).prepend(sup);
                 } else {
-                    return visitIntersectionType((IntersectionClassType) type);
+                    return ((IntersectionClassType)type).getExplicitComponents();
                 }
             }
-
-            private List<Type> visitIntersectionType(final IntersectionClassType it) {
-                return it.getExplicitComponents();
-            }
-
         };
 
     public boolean isDirectSuperInterface(TypeSymbol isym, TypeSymbol origin) {
@@ -4152,7 +4147,7 @@
 
     private boolean giveWarning(Type from, Type to) {
         List<Type> bounds = to.isCompound() ?
-                ((IntersectionClassType)to).getComponents() : List.of(to);
+                directSupertypes(to) : List.of(to);
         for (Type b : bounds) {
             Type subFrom = asSub(from, b.tsym);
             if (b.isParameterized() &&
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java	Thu Nov 05 13:42:20 2015 -0800
@@ -527,7 +527,7 @@
      * Compare the javac_state recorded public apis of packages on the classpath
      * with the actual public apis on the classpath.
      */
-    public void taintPackagesDependingOnChangedClasspathPackages() {
+    public void taintPackagesDependingOnChangedClasspathPackages() throws IOException {
 
         // 1. Collect fully qualified names of all interesting classpath dependencies
         Set<String> fqDependencies = new HashSet<>();
@@ -549,6 +549,7 @@
         for (String cpDep : fqDependencies) {
             onDiskPubApi.put(cpDep, pubApiExtractor.getPubApi(cpDep));
         }
+        pubApiExtractor.close();
 
         // 3. Compare them with the public APIs as of last compilation (loaded from javac_state)
         nextPkg:
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/PubApiExtractor.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/PubApiExtractor.java	Thu Nov 05 13:42:20 2015 -0800
@@ -25,6 +25,7 @@
 
 package com.sun.tools.sjavac;
 
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Arrays;
 
@@ -46,8 +47,10 @@
 public class PubApiExtractor {
     // Setup a compiler context for finding classes in the classpath
     // and to execute annotation processors.
-    Context context;
-    CompilationTask task;
+    final Context context;
+    final CompilationTask task;
+
+    final SmartFileManager fileManager;
 
     /**
      * Setup a compilation context, used for reading public apis of classes on the classpath
@@ -55,7 +58,7 @@
      */
     public PubApiExtractor(Options options) {
         JavacTool compiler = com.sun.tools.javac.api.JavacTool.create();
-        SmartFileManager fileManager = new SmartFileManager(compiler.getStandardFileManager(null, null, null));
+        fileManager = new SmartFileManager(compiler.getStandardFileManager(null, null, null));
         context = new com.sun.tools.javac.util.Context();
         String[] args = options.prepJavacArgs();
         task = compiler.getTask(new PrintWriter(System.err),
@@ -82,4 +85,8 @@
         v.visit(cs);
         return v.getCollectedPubApi();
     }
+
+    public void close() throws IOException {
+        fileManager.close();
+    }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SjavacImpl.java	Thu Nov 05 13:42:20 2015 -0800
@@ -209,21 +209,20 @@
             // Go through all sources and taint all packages that miss artifacts.
             javac_state.taintPackagesThatMissArtifacts();
 
-            // Check recorded classpath public apis. Taint packages that depend on
-            // classpath classes whose public apis have changed.
-            javac_state.taintPackagesDependingOnChangedClasspathPackages();
+            try {
+                // Check recorded classpath public apis. Taint packages that depend on
+                // classpath classes whose public apis have changed.
+                javac_state.taintPackagesDependingOnChangedClasspathPackages();
 
-            // Now clean out all known artifacts belonging to tainted packages.
-            javac_state.deleteClassArtifactsInTaintedPackages();
-            // Copy files, for example property files, images files, xml files etc etc.
-            javac_state.performCopying(Util.pathToFile(options.getDestDir()), suffixRules);
-            // Translate files, for example compile properties or compile idls.
-            javac_state.performTranslation(Util.pathToFile(gensrc), suffixRules);
-            // Add any potentially generated java sources to the tobe compiled list.
-            // (Generated sources must always have a package.)
-            Map<String,Source> generated_sources = new HashMap<>();
-
-            try {
+                // Now clean out all known artifacts belonging to tainted packages.
+                javac_state.deleteClassArtifactsInTaintedPackages();
+                // Copy files, for example property files, images files, xml files etc etc.
+                javac_state.performCopying(Util.pathToFile(options.getDestDir()), suffixRules);
+                // Translate files, for example compile properties or compile idls.
+                javac_state.performTranslation(Util.pathToFile(gensrc), suffixRules);
+                // Add any potentially generated java sources to the tobe compiled list.
+                // (Generated sources must always have a package.)
+                Map<String,Source> generated_sources = new HashMap<>();
 
                 Source.scanRoot(Util.pathToFile(options.getGenSrcDir()), Util.set(".java"), null, null, null, null,
                         generated_sources, modules, current_module, false, true, false);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/8141343/T8141343.java	Thu Nov 05 13:42:20 2015 -0800
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8141343
+ * @summary Subtle semantics changes for union types in cast conversion
+ * @compile/fail/ref=T8141343.out -XDrawDiagnostics T8141343.java
+ */
+
+class T8141343 {
+    interface Foo<X> { }
+
+    static class A extends Exception implements Foo<A> { }
+    static class B extends Exception implements Foo<B> { }
+
+    void test(boolean cond) {
+        try {
+            if (cond) {
+                throw new A();
+            } else {
+                throw new B();
+            }
+        } catch (A | B ex) {
+            Foo<Integer> fa = (Foo<Integer>)ex;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/8141343/T8141343.out	Thu Nov 05 13:42:20 2015 -0800
@@ -0,0 +1,2 @@
+T8141343.java:22:45: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Exception&T8141343.Foo<? extends java.lang.Exception&T8141343.Foo<?>>, T8141343.Foo<java.lang.Integer>)
+1 error
--- a/langtools/test/tools/sjavac/ApiExtraction.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/test/tools/sjavac/ApiExtraction.java	Thu Nov 05 13:42:20 2015 -0800
@@ -92,6 +92,7 @@
         Options options = Options.parseArgs("-d", "bin", "--state-dir=bin", "-cp", ".");
         PubApiExtractor pubApiExtr = new PubApiExtractor(options);
         PubApi actualApi = pubApiExtr.getPubApi("TestClass");
+        pubApiExtr.close();
 
         // Validate result
         PubApi expectedApi = getExpectedPubApi();
--- a/langtools/test/tools/sjavac/NoState.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/test/tools/sjavac/NoState.java	Thu Nov 05 13:42:20 2015 -0800
@@ -36,8 +36,9 @@
 
 import com.sun.tools.javac.util.Assert;
 
-import java.util.*;
+import java.io.IOException;
 import java.nio.file.*;
+import java.util.stream.Stream;
 
 public class NoState extends SJavacTester {
     public static void main(String... args) throws Exception {
@@ -57,7 +58,13 @@
         Assert.check(Files.exists(BIN.resolve("pkg/A.class")));
 
         // Make sure we have no other files (such as a javac_state file) in the bin directory
-        Assert.check(Files.list(BIN).count() == 1);
-        Assert.check(Files.list(BIN.resolve("pkg")).count() == 1);
+        Assert.check(countPathsInDir(BIN) == 1);
+        Assert.check(countPathsInDir(BIN.resolve("pkg")) == 1);
+    }
+
+    private long countPathsInDir(Path dir) throws IOException {
+        try (Stream<Path> files = Files.list(dir)) {
+            return files.count();
+        }
     }
 }
--- a/langtools/test/tools/sjavac/PackagePathMismatch.java	Thu Nov 05 08:15:46 2015 -0800
+++ b/langtools/test/tools/sjavac/PackagePathMismatch.java	Thu Nov 05 13:42:20 2015 -0800
@@ -47,8 +47,10 @@
                           "package a.b.c; class Test { }");
 
         // Compile should fail since package a.b.c does not match path a/x/c.
-        String server = "--server:portfile=testserver,background=false";
-        int rc1 = compile(server, "-d", classes, src);
+        int rc1 = compile("--server:portfile=testserver,background=false",
+                          "-d", classes,
+                          "--state-dir=" + classes,
+                          src);
         if (rc1 == 0)
             throw new AssertionError("Compilation succeeded unexpectedly");
     }