jdk-24/test/langtools/tools/javac/patterns/PatternVariablesAreNonFinal.java
2023-01-17 04:43:40 +00:00

22 lines
598 B
Java

/*
* @test /nodynamiccopyright/
* @bug 8231827
* @summary Pattern variables are non-final.
* @compile/fail/ref=PatternVariablesAreNonFinal.out -XDrawDiagnostics PatternVariablesAreNonFinal.java
*/
public class PatternVariablesAreNonFinal {
public static void meth() {
Object o = 32;
if (o instanceof String s) {
s = "hello again";
new Runnable() {
@Override
public void run() {
System.err.println(s);
}
};
}
System.out.println("test complete");
}
}