--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Mon Oct 21 15:11:44 2019 +0200
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Mon Oct 21 15:38:26 2019 +0200
@@ -93,6 +93,7 @@
private final Source source;
private final Target target;
private final Profile profile;
+ private final Preview preview;
private final boolean warnOnAnyAccessToMembers;
// The set of lint options currently in effect. It is initialized
@@ -139,6 +140,7 @@
syntheticNameChar = target.syntheticNameChar();
profile = Profile.instance(context);
+ preview = Preview.instance(context);
boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION);
boolean verboseRemoval = lint.isEnabled(LintCategory.REMOVAL);
@@ -224,6 +226,23 @@
}
}
+ /** Warn about deprecated symbol.
+ * @param pos Position to be used for error reporting.
+ * @param sym The deprecated symbol.
+ */
+ void warnPreview(DiagnosticPosition pos, Symbol sym) {
+ warnPreview(pos, Warnings.IsPreview(sym));
+ }
+
+ /** Log a preview warning.
+ * @param pos Position to be used for error reporting.
+ * @param msg A Warning describing the problem.
+ */
+ public void warnPreview(DiagnosticPosition pos, Warning warnKey) {
+ if (!lint.isSuppressed(LintCategory.PREVIEW))
+ preview.reportPreviewWarning(pos, warnKey);
+ }
+
/** Warn about unchecked operation.
* @param pos Position to be used for error reporting.
* @param msg A string describing the problem.
@@ -434,6 +453,13 @@
localClassNameIndexes.clear();
}
+ public void clear() {
+ deprecationHandler.clear();
+ removalHandler.clear();
+ uncheckedHandler.clear();
+ sunApiHandler.clear();
+ }
+
public void putCompiled(ClassSymbol csym) {
compiled.put(Pair.of(csym.packge().modle, csym.flatname), csym);
}
@@ -3290,6 +3316,16 @@
}
}
+ void checkPreview(DiagnosticPosition pos, Symbol s) {
+ if ((s.flags() & PREVIEW_API) != 0) {
+ if ((s.flags() & PREVIEW_ESSENTIAL_API) != 0 && !preview.isEnabled()) {
+ log.error(pos, Errors.IsPreview(s));
+ } else {
+ deferredLintHandler.report(() -> warnPreview(pos, s));
+ }
+ }
+ }
+
/* *************************************************************************
* Check for recursive annotation elements.
**************************************************************************/