8187591: -Werror turns incubator module warning to an error
Reviewed-by: jlahoda
This commit is contained in:
parent
570dffb104
commit
53eb6f126b
@ -130,6 +130,7 @@ public class Lint
|
|||||||
values.add(LintCategory.PREVIEW);
|
values.add(LintCategory.PREVIEW);
|
||||||
}
|
}
|
||||||
values.add(LintCategory.SYNCHRONIZATION);
|
values.add(LintCategory.SYNCHRONIZATION);
|
||||||
|
values.add(LintCategory.INCUBATING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for specific overrides
|
// Look for specific overrides
|
||||||
@ -215,6 +216,11 @@ public class Lint
|
|||||||
*/
|
*/
|
||||||
FINALLY("finally"),
|
FINALLY("finally"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warn about use of incubating modules.
|
||||||
|
*/
|
||||||
|
INCUBATING("incubating"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warn about compiler possible lossy conversions.
|
* Warn about compiler possible lossy conversions.
|
||||||
*/
|
*/
|
||||||
|
@ -117,6 +117,7 @@ import com.sun.tools.javac.code.Kinds;
|
|||||||
import static com.sun.tools.javac.code.Kinds.Kind.ERR;
|
import static com.sun.tools.javac.code.Kinds.Kind.ERR;
|
||||||
import static com.sun.tools.javac.code.Kinds.Kind.MDL;
|
import static com.sun.tools.javac.code.Kinds.Kind.MDL;
|
||||||
import static com.sun.tools.javac.code.Kinds.Kind.MTH;
|
import static com.sun.tools.javac.code.Kinds.Kind.MTH;
|
||||||
|
import com.sun.tools.javac.code.Lint;
|
||||||
|
|
||||||
import com.sun.tools.javac.code.Symbol.ModuleResolutionFlags;
|
import com.sun.tools.javac.code.Symbol.ModuleResolutionFlags;
|
||||||
|
|
||||||
@ -134,6 +135,7 @@ public class Modules extends JCTree.Visitor {
|
|||||||
private static final String ALL_SYSTEM = "ALL-SYSTEM";
|
private static final String ALL_SYSTEM = "ALL-SYSTEM";
|
||||||
private static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
|
private static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
|
||||||
|
|
||||||
|
private final Lint lint;
|
||||||
private final Log log;
|
private final Log log;
|
||||||
private final Names names;
|
private final Names names;
|
||||||
private final Symtab syms;
|
private final Symtab syms;
|
||||||
@ -185,6 +187,7 @@ public class Modules extends JCTree.Visitor {
|
|||||||
protected Modules(Context context) {
|
protected Modules(Context context) {
|
||||||
context.put(Modules.class, this);
|
context.put(Modules.class, this);
|
||||||
log = Log.instance(context);
|
log = Log.instance(context);
|
||||||
|
lint = Lint.instance(context);
|
||||||
names = Names.instance(context);
|
names = Names.instance(context);
|
||||||
syms = Symtab.instance(context);
|
syms = Symtab.instance(context);
|
||||||
attr = Attr.instance(context);
|
attr = Attr.instance(context);
|
||||||
@ -1351,13 +1354,15 @@ public class Modules extends JCTree.Visitor {
|
|||||||
.forEach(result::add);
|
.forEach(result::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
String incubatingModules = filterAlreadyWarnedIncubatorModules(result.stream()
|
if (lint.isEnabled(LintCategory.INCUBATING)) {
|
||||||
.filter(msym -> msym.resolutionFlags.contains(ModuleResolutionFlags.WARN_INCUBATING))
|
String incubatingModules = filterAlreadyWarnedIncubatorModules(result.stream()
|
||||||
.map(msym -> msym.name.toString()))
|
.filter(msym -> msym.resolutionFlags.contains(ModuleResolutionFlags.WARN_INCUBATING))
|
||||||
.collect(Collectors.joining(","));
|
.map(msym -> msym.name.toString()))
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
|
||||||
if (!incubatingModules.isEmpty()) {
|
if (!incubatingModules.isEmpty()) {
|
||||||
log.warning(Warnings.IncubatingModules(incubatingModules));
|
log.warning(Warnings.IncubatingModules(incubatingModules));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allModules = result;
|
allModules = result;
|
||||||
|
@ -213,6 +213,9 @@ javac.opt.Xlint.desc.fallthrough=\
|
|||||||
javac.opt.Xlint.desc.finally=\
|
javac.opt.Xlint.desc.finally=\
|
||||||
Warn about finally clauses that do not terminate normally.
|
Warn about finally clauses that do not terminate normally.
|
||||||
|
|
||||||
|
javac.opt.Xlint.desc.incubating=\
|
||||||
|
Warn about use of incubating modules.
|
||||||
|
|
||||||
javac.opt.Xlint.desc.lossy-conversions=\
|
javac.opt.Xlint.desc.lossy-conversions=\
|
||||||
Warn about possible lossy conversions in compound assignment.
|
Warn about possible lossy conversions in compound assignment.
|
||||||
|
|
||||||
|
@ -162,6 +162,7 @@ import javax.tools.StandardLocation;
|
|||||||
* <tr><th scope="row">{@code fallthrough} <td>falling through from one case of a {@code switch} statement to
|
* <tr><th scope="row">{@code fallthrough} <td>falling through from one case of a {@code switch} statement to
|
||||||
* the next
|
* the next
|
||||||
* <tr><th scope="row">{@code finally} <td>{@code finally} clauses that do not terminate normally
|
* <tr><th scope="row">{@code finally} <td>{@code finally} clauses that do not terminate normally
|
||||||
|
* <tr><th scope="row">{@code incubating} <td>use of incubating modules
|
||||||
* <tr><th scope="row">{@code lossy-conversions} <td>possible lossy conversions in compound assignment
|
* <tr><th scope="row">{@code lossy-conversions} <td>possible lossy conversions in compound assignment
|
||||||
* <tr><th scope="row">{@code missing-explicit-ctor} <td>missing explicit constructors in public and protected classes
|
* <tr><th scope="row">{@code missing-explicit-ctor} <td>missing explicit constructors in public and protected classes
|
||||||
* in exported packages
|
* in exported packages
|
||||||
|
@ -725,6 +725,8 @@ a switch statement to the next.
|
|||||||
\f[V]finally\f[R]: Warns about \f[V]finally\f[R] clauses that do not
|
\f[V]finally\f[R]: Warns about \f[V]finally\f[R] clauses that do not
|
||||||
terminate normally.
|
terminate normally.
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
|
\f[V]incubating\f[R]: Warns about the use of incubating modules.
|
||||||
|
.IP \[bu] 2
|
||||||
\f[V]lossy-conversions\f[R]: Warns about possible lossy conversions in
|
\f[V]lossy-conversions\f[R]: Warns about possible lossy conversions in
|
||||||
compound assignment.
|
compound assignment.
|
||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8171177
|
* @bug 8171177 8187591
|
||||||
* @summary Verify that ModuleResolution attribute flags are honored.
|
* @summary Verify that ModuleResolution attribute flags are honored.
|
||||||
* @library /tools/lib
|
* @library /tools/lib
|
||||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||||
@ -238,6 +238,16 @@ public class IncubatingTest extends ModuleTestBase {
|
|||||||
if (!expected.equals(log)) {
|
if (!expected.equals(log)) {
|
||||||
throw new AssertionError("Unexpected output: " + log);
|
throw new AssertionError("Unexpected output: " + log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//test disable lint incubating
|
||||||
|
new JavacTask(tb)
|
||||||
|
.options("--module-path", classes.toString(),
|
||||||
|
"-XDrawDiagnostics",
|
||||||
|
"-Xlint:-incubating",
|
||||||
|
"-Werror")
|
||||||
|
.outdir(testModuleClasses)
|
||||||
|
.files(findJavaFiles(testModuleSrc))
|
||||||
|
.run(Expect.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyJavaBase(Path targetDir) throws IOException {
|
private void copyJavaBase(Path targetDir) throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user