jdk/test/langtools/tools/javac/lint/TextBlockSuppress.java
Archie Cobbs 3e60ab51fe 8348611: Eliminate DeferredLintHandler and emit warnings after attribution
8224228: No way to locally suppress lint warnings in parser/tokenizer or preview features
8353758: Missing calls to Log.useSource() in JavacTrees

Reviewed-by: mcimadamore, vromero, jlahoda
2025-08-20 15:04:48 +00:00

62 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
}
}
}