java-topology/test/langtools/tools/javac/lint/NoWarn.java
russell@unturf.com 0a580b313d undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com

Patches, unit tests, benchmarks, whitepaper, and outreach briefs.
Public domain — no copyright claimed. Use freely.
2026-03-26 17:11:57 -04:00

20 lines
1.5 KiB
Java

/**
* @test /nodynamiccopyright/
* @bug 6183484 8352612
* @summary Restrict -Xlint:none to affect only lint categories, while -nowarn disables all warnings
* @compile/ref=NoWarn1.out -XDfind=diamond -XDrawDiagnostics -Xlint:none NoWarn.java
* @compile/ref=NoWarn2.out -XDfind=diamond -XDrawDiagnostics -Xlint:divzero,unchecked NoWarn.java
* @compile/ref=NoWarn2.out -XDfind=diamond -XDrawDiagnostics -Xlint:none,divzero,unchecked NoWarn.java
* @compile/ref=NoWarn3.out -XDfind=diamond -XDrawDiagnostics -Xlint:none -nowarn NoWarn.java
* @compile/ref=NoWarn4.out -XDfind=diamond -XDrawDiagnostics -Xlint:divzero,unchecked -nowarn NoWarn.java
* @compile/ref=NoWarn4.out -XDfind=diamond -XDrawDiagnostics -Xlint:none,divzero,unchecked -nowarn NoWarn.java
*/
import java.util.*;
class NoWarn {
Set<?> z = null; // Mandatory Lint Lint Category How can it be suppressed?
// --------- ---- ------------- -------------------------
sun.misc.Unsafe b; // Yes No N/A Not possible
Set<String> a = new HashSet<String>(); // No No N/A "-nowarn" only (requires -XDfind=diamond)
Set<String> d = (Set<String>)z; // Yes Yes "unchecked" "-Xlint:-unchecked" only
int c = 1/0; // No Yes "divzero" "-Xlint:-divzero" or "-nowarn"
}