[records] static final fields without initializer are accepted by javac
Tagir Valeev
amaembo at gmail.com
Sat Jan 4 15:16:49 UTC 2020
Hello!
The following code can be compiled by javac:
record Test() {
static final int x;
public static void main(String[] args) {
System.out.println(x);
}
}
>"C:\Program Files\Java\jdk-14\bin\java.exe" --enable-preview --source=14 Test.java
Note: Test.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
0
>"C:\Program Files\Java\jdk-14\bin\java.exe" --version
openjdk 14-ea 2020-03-17
OpenJDK Runtime Environment (build 14-ea+28-1366)
OpenJDK 64-Bit Server VM (build 14-ea+28-1366, mixed mode, sharing)
Javac correctly rejects the code if we change `record Test()` to `class Test`.
With best regards,
Tagir Valeev.
More information about the amber-dev
mailing list