This came as a surprise: I am able to declare a variable with the name record even though it now has become a keyword. Have a look at this:
public class Main {
static class Foo {
void bar() { System.out.println("Foo.bar"); }
}
record R (int a) {}
public static void main(String[] args) {
Foo record = new Foo();
record.bar();
R r = new R(5);
System.out.println(r);
}
}
When compiled and run with Java 17 this gives:
Foo.bar
R[a=5]
I had expected this to result in an error as is the case when trying to declare a variable named class. As I know the Java guys, they are extremely careful not to break existing code, and so I think this might be a deliberate choice.
(You can't even declare a variable named const because that one const is a keyword in Java.)