java-topology/test/langtools/tools/javac/lint/TextBlockSuppress.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

61 lines
1.6 KiB
Java

/*
* @test /nodynamiccopyright/
* @bug 8224228
* @summary Verify SuppressWarnings works for LintCategore.TEXT_BLOCKS
* @compile/fail/ref=TextBlockSuppress.out -XDrawDiagnostics -Xlint:text-blocks -Werror TextBlockSuppress.java
*/
public class TextBlockSuppress {
public static class Example1 {
public void method() {
String s = """
trailing space here:\u0020
"""; // SHOULD get a warning here
}
}
@SuppressWarnings("text-blocks")
public static class Example2 {
public void method() {
String s = """
trailing space here:\u0020
"""; // SHOULD NOT get a warning here
}
}
public static class Example3 {
@SuppressWarnings("text-blocks")
public void method() {
String s = """
trailing space here:\u0020
"""; // SHOULD NOT get a warning here
}
}
public static class Example4 {
{
String s = """
trailing space here:\u0020
"""; // SHOULD get a warning here
}
}
@SuppressWarnings("text-blocks")
public static class Example5 {
{
String s = """
trailing space here:\u0020
"""; // SHOULD NOT get a warning here
}
}
public static class Example6 {
public void method() {
@SuppressWarnings("text-blocks")
String s = """
trailing space here:\u0020
"""; // SHOULD NOT get a warning here
}
}
}