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

Add parameter to control warning about memory constraints #5162

Merged
merged 10 commits into from Sep 28, 2022
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Expand Up @@ -6,6 +6,9 @@ Version 3.26.0 (October 4, 2022)
Annotations are available for some new JDK 17 APIs (some of those
introduced since JDK 11).

Added `-AnoWarnMemoryConstraints` to change the "Memory constraints are impeding
performance; please increase max heap size" message from a warning to a note.

**Implementation details:**

**Closed issues:**
Expand Down
1 change: 1 addition & 0 deletions docs/manual/contributors.tex
Expand Up @@ -56,6 +56,7 @@
Jugal Mistry,
Junhao Hu,
Kartikeya Goswami,
Kenneth Knowles,
Kivanc Muslu,
Konstantin Weitz,
Lazaro Clapp,
Expand Down
4 changes: 4 additions & 0 deletions docs/manual/creating-a-checker.tex
Expand Up @@ -1920,6 +1920,10 @@
already reported the bug, and you want to continue using the checker on a
large codebase without being inundated in stack traces.

\item \code{-AnoWarnMemoryConstraints}: when memory constraints are
impeding performance, issue a note rather than a warning.
This prevents the message from being elevated to an error by \code{-Werror}.

\item \code{-AdumpOnErrors}: Outputs a stack trace when reporting errors or warnings.

\end{itemize}
Expand Down
Expand Up @@ -296,6 +296,9 @@
// org.checkerframework.framework.source.SourceChecker.logBugInCF
"noPrintErrorStack",

// If true, issue a NOTE rather than a WARNING when performance is impeded by memory constraints.
"noWarnMemoryConstraints",

// Only output error code, useful for testing framework
// org.checkerframework.framework.source.SourceChecker.message(Kind, Object, String, Object...)
"nomsgtext",
Expand Down Expand Up @@ -940,7 +943,12 @@ public void typeProcess(TypeElement e, TreePath p) {
if (!warnedAboutGarbageCollection) {
String gcUsageMessage = SystemPlume.gcUsageMessage(.25, 60);
if (gcUsageMessage != null) {
messager.printMessage(Kind.WARNING, gcUsageMessage);
boolean noWarnMemoryConstraints =
(processingEnv != null
&& processingEnv.getOptions() != null
&& processingEnv.getOptions().containsKey("noWarnMemoryConstraints"));
Kind kind = noWarnMemoryConstraints ? Kind.NOTE : Kind.WARNING;
messager.printMessage(kind, gcUsageMessage);
warnedAboutGarbageCollection = true;
}
}
Expand Down