jdk-24/test/langtools/tools/javac/lambda/UnderscoreAsIdent.java
Aggelos Biboudis 8aa50288a1 8302344: Compiler Implementation for Unnamed patterns and variables (Preview)
8307444: java.lang.AssertionError when using unnamed patterns
8307482: Compiler should accept var _ in nested patterns in switch case
8307007: Implementation for javax.lang.model for unnamed variables (Preview)
8308312: Compiler should fail when a local variable declaration does not include an Identifier and does not have an initializer
8308309: Compiler should accept mixed masked and unmasked variables in lambda parameters

Co-authored-by: Jan Lahoda <jlahoda@openjdk.org>
Co-authored-by: Aggelos Biboudis <abimpoudis@openjdk.org>
Reviewed-by: vromero, darcy
2023-05-22 08:52:36 +00:00

35 lines
873 B
Java

/*
* @test /nodynamiccopyright/
* @summary Check usages of underscore as identifier generate warnings
* @compile/fail/ref=UnderscoreAsIdent8.out --release 8 -XDrawDiagnostics -Xlint:-options -Werror UnderscoreAsIdent.java
* @compile/fail/ref=UnderscoreAsIdent9.out -XDrawDiagnostics -Werror UnderscoreAsIdent.java
* @compile/fail/ref=UnderscoreAsIdent21.out -source ${jdk.version} --enable-preview -XDrawDiagnostics UnderscoreAsIdent.java
*/
package _._;
import _._;
class _ {
String _ = null;
void _(String _) { }
void testLocal() {
String _ = null;
}
void testFor() {
for (int _ = 0; _ < 10; _++);
}
void testTry() {
try { } catch (Throwable _) { }
}
void testLabel() {
_:
for (;;) {
break _;
}
_:
for (;;) {
continue _;
}
}
}