[java] Remove support for Java 16 Preview

This commit is contained in:
Andreas Dangel
2022-03-10 15:33:22 +01:00
parent b769594fc7
commit 937eb90a70
25 changed files with 22 additions and 212 deletions

View File

@@ -1,4 +1,9 @@
/**
* Support "JEP 420: Pattern Matching for switch (Second Preview)" for Java 18 Preview
* There were no grammar changes between 18-preview and 17-preview
* Remove support for Java 16 preview language features
* Andreas Dangel 03/2022
*====================================================================
* Promote "JEP 409: Sealed Classes" as permanent language feature with Java 17.
* Support "JEP 406: Pattern Matching for switch (Preview)" for Java 17 Preview.
* Remove support for Java 15 preview language features
@@ -445,11 +450,11 @@ public class JavaParser {
if (jdkVersion >= 16 && "record".equals(image)) {
throwParseException("With JDK >= 16, 'record' is a contextual keyword and cannot be used for type declarations!");
}
if ((jdkVersion == 16 && preview || jdkVersion >= 17) && "sealed".equals(image)) {
throwParseException("With JDK 16 Preview and JDK >= 17, 'sealed' is a contextual keyword and cannot be used for type declarations!");
if (jdkVersion >= 17 && "sealed".equals(image)) {
throwParseException("With JDK >= 17, 'sealed' is a contextual keyword and cannot be used for type declarations!");
}
if ((jdkVersion == 16 && preview || jdkVersion >= 17) && "permits".equals(image)) {
throwParseException("With JDK 16 Preview and JDK >= 17, 'permits' is a contextual keyword and cannot be used for type declarations!");
if (jdkVersion >= 17 && "permits".equals(image)) {
throwParseException("With JDK >= 17, 'permits' is a contextual keyword and cannot be used for type declarations!");
}
}
private void checkForMultipleCaseLabels() {
@@ -519,12 +524,12 @@ public class JavaParser {
}
private boolean isSealedClassSupported() {
return jdkVersion == 16 && preview || jdkVersion >= 17;
return jdkVersion >= 17;
}
private void checkForSealedClassUsage() {
if (!isSealedClassSupported()) {
throwParseException("Sealed Classes are only supported with JDK 16 Preview and JDK >= 17.");
throwParseException("Sealed Classes are only supported with JDK >= 17.");
}
}