diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java index e9d64a6ad72..de37229f68f 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java @@ -130,6 +130,7 @@ public class Lint values.add(LintCategory.PREVIEW); } values.add(LintCategory.SYNCHRONIZATION); + values.add(LintCategory.INCUBATING); } // Look for specific overrides @@ -215,6 +216,11 @@ public class Lint */ FINALLY("finally"), + /** + * Warn about use of incubating modules. + */ + INCUBATING("incubating"), + /** * Warn about compiler possible lossy conversions. */ diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java index 6c4729c217a..6dd4a368f44 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java @@ -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.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 class Modules extends JCTree.Visitor { 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 @@ public class Modules extends JCTree.Visitor { .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; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties index d9bd05ba62a..7893d328afa 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties @@ -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. diff --git a/src/jdk.compiler/share/classes/module-info.java b/src/jdk.compiler/share/classes/module-info.java index c8716233c0f..9826b3f576b 100644 --- a/src/jdk.compiler/share/classes/module-info.java +++ b/src/jdk.compiler/share/classes/module-info.java @@ -162,6 +162,7 @@ import javax.tools.StandardLocation; *