Missing annotations and contextual keywords in Java
The following contextual keywords (except var
) are missing from the Java's definition file:
https://en.wikipedia.org/wiki/List_of_Java_keywords#Reserved_Identifiers
Note that the keywords exports
, module
, open
, opens
, provides
, requires
, to
, transitive
, uses
, and with
are only available in module-info.java
files. I'm not sure if there's a way to detect the file name. These are not valid in other Java source files.
Keywords non-sealed
, permits
, record
, sealed
, and yield
should be added, at least. All of those features are already included in the latest stable LTS version of Java.
In addition Java contains a list of well-defined built-in annotations: https://en.wikipedia.org/wiki/Java_annotation#Built-in_annotations_2
At least @Override
, @Deprecated
, @SuppressWarnings
, @SafeVarargs
, and @FunctionalInterface
are commonly used in all sorts of code. The definition file currently includes one annotation, @interface
. However I don't think this is widely used and has any standard meaning. I'd suggest removing that annotation and including the ones I listed.