Merge
This commit is contained in:
commit
f9a1a366d7
@ -23,6 +23,7 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
include JarArchive.gmk
|
||||
include JavaCompilation.gmk
|
||||
include SetupJavaCompilers.gmk
|
||||
|
||||
@ -52,9 +53,9 @@ $(SUPPORT_OUTPUTDIR)/symbols/ct.sym-files/_the.symbols: \
|
||||
$(@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, \
|
||||
|
@ -56,21 +56,21 @@ public class CreateSymbolsTest {
|
||||
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.");
|
||||
|
@ -41,12 +41,12 @@ import java.util.HashSet;
|
||||
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 {
|
||||
|
||||
|
@ -583,11 +583,13 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
|
||||
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 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompound() {
|
||||
return getLub().isCompound();
|
||||
}
|
||||
|
||||
@Override @DefinedBy(Api.LANGUAGE_MODEL)
|
||||
public TypeKind getKind() {
|
||||
return TypeKind.UNION;
|
||||
@ -1242,6 +1249,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
|
||||
return Collections.unmodifiableList(getExplicitComponents());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompound() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<Type> getComponents() {
|
||||
return interfaces_field.prepend(supertype_field);
|
||||
}
|
||||
|
@ -1495,10 +1495,10 @@ public class Types {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ public class Types {
|
||||
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 @@ public class Types {
|
||||
? 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 @@ public class Types {
|
||||
|
||||
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() &&
|
||||
|
@ -527,7 +527,7 @@ public class JavacState {
|
||||
* 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 @@ public class JavacState {
|
||||
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:
|
||||
|
@ -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 @@ import com.sun.tools.sjavac.pubapi.PubApi;
|
||||
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 class PubApiExtractor {
|
||||
*/
|
||||
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 @@ public class PubApiExtractor {
|
||||
v.visit(cs);
|
||||
return v.getCollectedPubApi();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
fileManager.close();
|
||||
}
|
||||
}
|
||||
|
@ -209,21 +209,20 @@ public class SjavacImpl implements Sjavac {
|
||||
// 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();
|
||||
|
||||
// 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 {
|
||||
// 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<>();
|
||||
|
||||
Source.scanRoot(Util.pathToFile(options.getGenSrcDir()), Util.set(".java"), null, null, null, null,
|
||||
generated_sources, modules, current_module, false, true, false);
|
||||
|
25
langtools/test/tools/javac/cast/8141343/T8141343.java
Normal file
25
langtools/test/tools/javac/cast/8141343/T8141343.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
2
langtools/test/tools/javac/cast/8141343/T8141343.out
Normal file
2
langtools/test/tools/javac/cast/8141343/T8141343.out
Normal file
@ -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
|
@ -92,6 +92,7 @@ public class ApiExtraction {
|
||||
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();
|
||||
|
@ -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 @@ public class NoState extends SJavacTester {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,10 @@ public class PackagePathMismatch extends SjavacBase {
|
||||
"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");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user