Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
First identify which tool reported the warning and its exact rule ID. Fix the underlying code if practical; otherwise, use that tool’s narrowest supported suppression, explain why the exception is safe, and rerun the same tool to verify the result. Java’s @SuppressWarnings annotation is not a universal switch for static-analysis tools.
Identify which tool reported the warning
Start with the diagnostic, not a suppression annotation. A Java project may show warnings from javac, Checkstyle, PMD, SpotBugs, Error Prone, or an IDE inspection. Each has its own warning names and suppression rules.
- Build output: Check the command or task that emitted the message, along with the diagnostic’s category or rule ID.
- Analysis reports: Look for the analyzer name and bug pattern or rule identifier; consult that tool’s rule documentation if the report is unclear.
- IDE highlighting: Use the inspection name or its context action, then determine whether the same finding also appears in the build or CI.
Identifiers are not interchangeable: unchecked is a compiler warning key, PMD.UnusedLocalVariable is a PMD suppression name, and NP_NULL_ON_SOME_PATH is a SpotBugs bug code. A Java annotation only affects another analyzer when that analyzer is configured to recognize it.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsDecide whether to fix or suppress it
Prefer a code change when it removes the risk or makes the intent clearer. Suppression is reasonable when a finding is incorrect for this case, or the flagged construct is required and its risk is handled by a specific, reviewable guarantee.
#1 Best Overall
- Used Book in Good Condition
- Read the warning and inspect the reported code.
- Fix the underlying issue if possible.
- If suppression is still warranted, record the invariant or validation that makes this instance acceptable.
- Apply the narrowest scope the tool supports and rerun that tool with the project’s usual configuration.
A warning disappearing only confirms that the tool stopped reporting it; it does not establish that the code is safe.
Suppress Java compiler warnings with @SuppressWarnings
For javac warnings, place @SuppressWarnings on the smallest declaration that contains the operation and supports annotations. The Java SE 26 API says the annotation applies to the annotated element and its contained elements, recommends the deepest effective placement, and specifies source retention. See the Java SE 26 SuppressWarnings API.
@SuppressWarnings("unchecked")
List<String> values = (List<String>) legacyValues();
This illustrates placement, not a blanket endorsement of unchecked casts: validate the value or restructure the code where practical. The appropriate declaration syntax depends on the construct producing the warning.
Use the compiler’s warning key
Common standard names include unchecked, deprecation, removal, and preview. For ordinary deprecation warnings use "deprecation"; removal warnings use "removal". To cover both, the annotation can take an array such as @SuppressWarnings({"deprecation", "removal"}). Oracle’s Java notifications and warnings guide describes the distinction.
Rank #2
javac also accepts documented lint keys in annotations, with exceptions including path and processing. Keys and details can vary with the JDK: check the project’s actual compiler documentation or run javac --help-lint. The JDK 26 javac manual documents that version’s keys and nonsuppressible warnings.
An unrecognized annotation value may be ignored rather than treated as an error, so a typo or unsupported key can leave the warning untouched. A command-line option such as -Xlint:deprecation controls warning reporting for a compilation run; it is not a location-specific suppression.
Use the matching analyzer’s suppression mechanism
For third-party analyzers, use the identifier and mechanism documented by that analyzer. Examples below are separate tool paths, not interchangeable Java syntax.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Checkstyle: configure annotation support first
Checkstyle can consume Java @SuppressWarnings annotations only when its configuration includes SuppressWarningsHolder under TreeWalker and SuppressWarningsFilter under Checker. A minimal configuration shape is:
<module name="Checker">
<module name="TreeWalker">
<module name="SuppressWarningsHolder"/>
<module name="MemberName"/>
</module>
<module name="SuppressWarningsFilter"/>
</module>
With those modules configured, a declaration can target the check name, case-insensitively and without the Check suffix; the checkstyle: prefix is also supported:
@SuppressWarnings("checkstyle:MemberName")
private int legacyField;
See Checkstyle’s documentation for SuppressWarningsFilter and SuppressWarningsHolder. Without the required modules or a matching check name or ID, the annotation may have no effect.
PMD: use a rule annotation or reported-line marker
PMD for Java supports rule-specific annotations, multiple values, and // NOPMD markers. For example:
@SuppressWarnings("PMD.UnusedLocalVariable")
void process() { ... }
Put // NOPMD on the same line PMD reports. For a multiline construct, use the reported line rather than assuming the marker belongs on the visually prominent line. PMD allows the marker to be customized through a CLI option. Its suppression documentation also covers configuration-level violationSuppressRegex and violationSuppressXPath; use these carefully because message matching depends on text, and XPath behavior differs between PMD versions. PMD 7 uses XPath 3.1; earlier versions used XPath 1.0.
Rank #4
- INCLUDES THE ACTUAL NAVAJO CODE AND RARE PICTURES
The same documentation describes an experimental Java rule, UnnecessaryWarningSuppression, available since PMD 7.14.0, for finding suppressions that no longer suppress violations. Check its availability and status in the PMD version used by the project.
SpotBugs: use its annotation or a constrained XML filter
SpotBugs provides its own edu.umd.cs.findbugs.annotations.SuppressFBWarnings annotation. The stable SpotBugs documentation identifies spotbugs-annotations version 4.10.4; use a dependency compatible with the project’s SpotBugs setup rather than copying a version without checking.
@SuppressFBWarnings(
value = "NP_NULL_ON_SOME_PATH",
justification = "The framework validates this value before invoking the callback.")
void handle(Request request) { ... }
Use the bug code and annotation attributes supported by the version in the project. See the SpotBugs 4.10.4 annotations documentation.
For findings that cannot be annotated in source, SpotBugs supports XML include and exclude filters. Constrain a match by the specific bug pattern or code and the relevant class, method, field, or source where possible. The CLI documentation shows -exclude myExcludeFilter.xml. In a filter Match, predicates are conjunctive; names beginning with ~ are regular expressions matched against the whole name, and findings involving multiple classes may match only the primary class. See the SpotBugs 4.10.4 filter documentation.
Best Value
Error Prone: use the bug-pattern name
Error Prone recognizes @SuppressWarnings with the finding’s bug-pattern name. For example, its documentation shows suppression forms for ParameterName and DoNotCall. Copy the precise name from the diagnostic or rule documentation; a Checkstyle or PMD name will not substitute. Error Prone’s compiler flags can enable or disable checks or change severity, but those settings affect the compilation configuration rather than a single occurrence.
Suppress an IntelliJ IDEA inspection
In IntelliJ IDEA, place the caret on the inspection and press Alt+Enter, then use the context action to suppress it. For Java, IDEA inserts @SuppressWarnings for class, method, or field scope, and //noinspection for a statement. The generated marker and scope are preferable to guessing an inspection ID.
Choosing to disable an inspection changes the current inspection profile; it is not a local source suppression. Some inspections cannot be suppressed. These behaviors are documented for IntelliJ IDEA 2026.2 in Disable and suppress inspections. An IDE suppression may affect only editor highlighting, so check whether the build or CI tool still reports the finding.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Use external filters when source annotations are impractical
External suppression files can be useful for generated, framework-driven, legacy, or otherwise uneditable code. Constrain the exception by both the rule and the relevant program element or path. Avoid excluding a whole category or broad directory when a narrower match is possible.
Checkstyle’s SuppressionFilter can match file, check name or ID, line, column, and optionally message. Message matching depends on runtime locale, so a check or ID is generally more robust. SpotBugs XML filters offer bug-pattern and program-element matching; account for their matching rules when reviewing the filter. Line-based exceptions can drift when code moves, so recheck that they still target the intended finding.
When a suppression does not work
- The wrong tool was targeted: An annotation for
javacwill not automatically silence an unrelated analyzer or IDE inspection. - The identifier is wrong or unsupported: Copy the exact key or rule ID from the diagnostic. A compiler may ignore an unrecognized
@SuppressWarningsvalue. - Checkstyle annotation support is missing: Confirm both required modules are configured in their specified locations.
- The PMD marker is on the wrong line: Move
// NOPMDto the line PMD reports. - The IDE and build disagree: Rerun the tool that produced the warning with the same configuration used in CI.
- The warning cannot be suppressed locally: Some warning categories or inspections have no local suppression mechanism; a compiler error is not necessarily suppressible as a warning. Fix the code or adjust tool configuration only when justified.
Keep suppressions reviewable
Add a short nearby comment or suppression justification stating the relevant validation, invariant, or accepted exception. Periodically remove suppressions whose code or warning no longer exists, and rerun analysis after edits to suppression filters. For PMD, check whether the installed version supports the documented experimental UnnecessaryWarningSuppression rule.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.

