I was previously using this contrived code
record Foo(int bar[]) {}
which is making use of the C-style array-notation. And it compiled fine in Java 15.
Now, all of the sudden, with the official release of records in Java 16, it does not compile anymore. Here is the output from jshell:
jshell> record Foo(int bar[]) {} | Error: | legacy array notation not allowed on record components | record Foo(int bar[]) {} | ^
Why did it compile in Java 15, was this a bug? Out of curiousity, why is it not supported in records, while being supported anywhere else in Java?
I am using javac
from Adoptium (based on OpenJDK).