Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8187591: -Werror turns incubator module warning to an error #16454

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -130,6 +130,7 @@ protected Lint(Context context) {
values.add(LintCategory.PREVIEW);
}
values.add(LintCategory.SYNCHRONIZATION);
values.add(LintCategory.INCUBATING);
}

// Look for specific overrides
@@ -215,6 +216,11 @@ public enum LintCategory {
*/
FINALLY("finally"),

/**
* Warn about use of incubating modules.
*/
INCUBATING("incubating"),

/**
* Warn about compiler possible lossy conversions.
*/
Original file line number Diff line number Diff line change
@@ -117,6 +117,7 @@
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.MTH;
import com.sun.tools.javac.code.Lint;

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_MODULE_PATH = "ALL-MODULE-PATH";

private final Lint lint;
private final Log log;
private final Names names;
private final Symtab syms;
@@ -185,6 +187,7 @@ public static Modules instance(Context context) {
protected Modules(Context context) {
context.put(Modules.class, this);
log = Log.instance(context);
lint = Lint.instance(context);
names = Names.instance(context);
syms = Symtab.instance(context);
attr = Attr.instance(context);
@@ -1351,13 +1354,15 @@ private void setupAllModules() {
.forEach(result::add);
}

String incubatingModules = filterAlreadyWarnedIncubatorModules(result.stream()
.filter(msym -> msym.resolutionFlags.contains(ModuleResolutionFlags.WARN_INCUBATING))
.map(msym -> msym.name.toString()))
.collect(Collectors.joining(","));
if (lint.isEnabled(LintCategory.INCUBATING)) {
String incubatingModules = filterAlreadyWarnedIncubatorModules(result.stream()
.filter(msym -> msym.resolutionFlags.contains(ModuleResolutionFlags.WARN_INCUBATING))
.map(msym -> msym.name.toString()))
.collect(Collectors.joining(","));

if (!incubatingModules.isEmpty()) {
log.warning(Warnings.IncubatingModules(incubatingModules));
if (!incubatingModules.isEmpty()) {
log.warning(Warnings.IncubatingModules(incubatingModules));
}
}

allModules = result;
Original file line number Diff line number Diff line change
@@ -213,6 +213,9 @@ javac.opt.Xlint.desc.fallthrough=\
javac.opt.Xlint.desc.finally=\
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=\
Warn about possible lossy conversions in compound assignment.

1 change: 1 addition & 0 deletions src/jdk.compiler/share/classes/module-info.java
Original file line number Diff line number Diff line change
@@ -162,6 +162,7 @@
* <tr><th scope="row">{@code fallthrough} <td>falling through from one case of a {@code switch} statement to
* the next
* <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 missing-explicit-ctor} <td>missing explicit constructors in public and protected classes
* in exported packages
2 changes: 2 additions & 0 deletions src/jdk.compiler/share/man/javac.1
Original file line number Diff line number Diff line change
@@ -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
terminate normally.
.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
compound assignment.
.IP \[bu] 2
12 changes: 11 additions & 1 deletion test/langtools/tools/javac/modules/IncubatingTest.java
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@

/*
* @test
* @bug 8171177
* @bug 8171177 8187591
* @summary Verify that ModuleResolution attribute flags are honored.
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
@@ -238,6 +238,16 @@ public void testIncubating(Path base) throws Exception {
if (!expected.equals(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 {