diff --git a/docs/pages/pmd/languages/java.md b/docs/pages/pmd/languages/java.md
index 73029ef0a0..b3737a878c 100644
--- a/docs/pages/pmd/languages/java.md
+++ b/docs/pages/pmd/languages/java.md
@@ -7,33 +7,35 @@ permalink: pmd_languages_java.html
Usually the latest non-preview Java Version is the default version.
-Java Version |Alias | Supported by PMD since |
--------------|------|------------------------|
-18-preview | | 6.44.0 |
-18 (default) | | 6.44.0 |
-17-preview | | 6.37.0 |
-17 | | 6.37.0 |
-16 | | 6.32.0 |
-15 | | 6.27.0 |
-14 | | 6.22.0 |
-13 | | 6.18.0 |
-12 | | 6.13.0 |
-11 | | 6.6.0 |
-10 | 1.10 | 6.4.0 |
-9 | 1.9 | 6.0.0 |
-8 | 1.8 | 5.1.0 |
-7 | 1.7 | 5.0.0 |
-6 | 1.6 | 3.9 |
-5 | 1.5 | 3.0 |
-1.4 | | 1.2.2 |
-1.3 | | 1.0.0 |
+| Java Version | Alias | Supported by PMD since |
+|--------------|-------|------------------------|
+| 19-preview | | 6.48.0 |
+| 19 (default) | | 6.48.0 |
+| 18-preview | | 6.44.0 |
+| 18 | | 6.44.0 |
+| 17-preview | | 6.37.0 |
+| 17 | | 6.37.0 |
+| 16 | | 6.32.0 |
+| 15 | | 6.27.0 |
+| 14 | | 6.22.0 |
+| 13 | | 6.18.0 |
+| 12 | | 6.13.0 |
+| 11 | | 6.6.0 |
+| 10 | 1.10 | 6.4.0 |
+| 9 | 1.9 | 6.0.0 |
+| 8 | 1.8 | 5.1.0 |
+| 7 | 1.7 | 5.0.0 |
+| 6 | 1.6 | 3.9 |
+| 5 | 1.5 | 3.0 |
+| 1.4 | | 1.2.2 |
+| 1.3 | | 1.0.0 |
## Using Java preview features
In order to analyze a project with PMD that uses preview language features, you'll need to enable
-it via the environment variable `PMD_JAVA_OPTS` and select the new language version, e.g. `18-preview`:
+it via the environment variable `PMD_JAVA_OPTS` and select the new language version, e.g. `19-preview`:
export PMD_JAVA_OPTS=--enable-preview
- ./run.sh pmd -language java -version 18-preview ...
+ ./run.sh pmd -language java -version 19-preview ...
Note: we only support preview language features for the latest two java versions.
diff --git a/docs/pages/pmd/userdocs/tools/ant.md b/docs/pages/pmd/userdocs/tools/ant.md
index eb7eae4367..a56acfdff6 100644
--- a/docs/pages/pmd/userdocs/tools/ant.md
+++ b/docs/pages/pmd/userdocs/tools/ant.md
@@ -237,8 +237,10 @@ nested element. Possible values are:
-
+
+
+
diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt
index 4e655ead41..d76591db30 100644
--- a/pmd-java/etc/grammar/Java.jjt
+++ b/pmd-java/etc/grammar/Java.jjt
@@ -534,30 +534,30 @@ public class JavaParser {
}
private boolean isJEP406Supported() {
- return (jdkVersion == 17 || jdkVersion == 18) && preview;
+ return (jdkVersion == 17 || jdkVersion == 18 || jdkVersion == 19) && preview;
}
private void checkForPatternMatchingInSwitch() {
if (!isJEP406Supported()) {
- throwParseException("Pattern Matching in Switch is only supported with JDK 17 Preview or JDK 18 Preview.");
+ throwParseException("Pattern Matching in Switch is only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview.");
}
}
private void checkForNullCaseLabel() {
if (!isJEP406Supported()) {
- throwParseException("Null case labels in switch are only supported with JDK 17 Preview or JDK 18 Preview.");
+ throwParseException("Null case labels in switch are only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview.");
}
}
private void checkForDefaultCaseLabel() {
if (!isJEP406Supported()) {
- throwParseException("Default case labels in switch are only supported with JDK 17 Preview or JDK 18 Preview.");
+ throwParseException("Default case labels in switch are only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview.");
}
}
private void checkForGuardedPatterns() {
if (!isJEP406Supported()) {
- throwParseException("Guarded patterns are only supported with JDK 17 Preview or JDK 18 Preview.");
+ throwParseException("Guarded patterns are only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview.");
}
}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java
index bba3743fa8..5cf3898e6f 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/JavaLanguageModule.java
@@ -32,8 +32,10 @@ public class JavaLanguageModule extends BaseLanguageModule {
addVersion("16", new JavaLanguageHandler(16));
addVersion("17", new JavaLanguageHandler(17));
addVersion("17-preview", new JavaLanguageHandler(17, true));
- addDefaultVersion("18", new JavaLanguageHandler(18)); // 18 is the default
+ addVersion("18", new JavaLanguageHandler(18));
addVersion("18-preview", new JavaLanguageHandler(18, true));
+ addDefaultVersion("19", new JavaLanguageHandler(19)); // 19 is the default
+ addVersion("19-preview", new JavaLanguageHandler(19, true));
}
}
diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java17PreviewTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java17PreviewTreeDumpTest.java
index 4f8d583872..2b8c6f9f8e 100644
--- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java17PreviewTreeDumpTest.java
+++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java17PreviewTreeDumpTest.java
@@ -38,7 +38,7 @@ public class Java17PreviewTreeDumpTest extends BaseTreeDumpTest {
}
});
Assert.assertTrue("Unexpected message: " + thrown.getMessage(),
- thrown.getMessage().contains("Pattern Matching in Switch is only supported with JDK 17 Preview or JDK 18 Preview."));
+ thrown.getMessage().contains("Pattern Matching in Switch is only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview."));
}
@Test
@@ -65,7 +65,7 @@ public class Java17PreviewTreeDumpTest extends BaseTreeDumpTest {
}
});
Assert.assertTrue("Unexpected message: " + thrown.getMessage(),
- thrown.getMessage().contains("Null case labels in switch are only supported with JDK 17 Preview or JDK 18 Preview."));
+ thrown.getMessage().contains("Null case labels in switch are only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview."));
}
@Test
@@ -82,7 +82,7 @@ public class Java17PreviewTreeDumpTest extends BaseTreeDumpTest {
}
});
Assert.assertTrue("Unexpected message: " + thrown.getMessage(),
- thrown.getMessage().contains("Guarded patterns are only supported with JDK 17 Preview or JDK 18 Preview."));
+ thrown.getMessage().contains("Guarded patterns are only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview."));
}
@Test
diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java18PreviewTreeDumpTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java18PreviewTreeDumpTest.java
index 19ff4e4cd9..9ecab7efea 100644
--- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java18PreviewTreeDumpTest.java
+++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java18PreviewTreeDumpTest.java
@@ -38,7 +38,7 @@ public class Java18PreviewTreeDumpTest extends BaseTreeDumpTest {
}
});
Assert.assertTrue("Unexpected message: " + thrown.getMessage(),
- thrown.getMessage().contains("Null case labels in switch are only supported with JDK 17 Preview or JDK 18 Preview."));
+ thrown.getMessage().contains("Null case labels in switch are only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview."));
}
@Test
@@ -65,7 +65,7 @@ public class Java18PreviewTreeDumpTest extends BaseTreeDumpTest {
}
});
Assert.assertTrue("Unexpected message: " + thrown.getMessage(),
- thrown.getMessage().contains("Guarded patterns are only supported with JDK 17 Preview or JDK 18 Preview."));
+ thrown.getMessage().contains("Guarded patterns are only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview."));
}
@Test
@@ -82,7 +82,7 @@ public class Java18PreviewTreeDumpTest extends BaseTreeDumpTest {
}
});
Assert.assertTrue("Unexpected message: " + thrown.getMessage(),
- thrown.getMessage().contains("Pattern Matching in Switch is only supported with JDK 17 Preview or JDK 18 Preview."));
+ thrown.getMessage().contains("Pattern Matching in Switch is only supported with JDK 17 Preview or JDK 18 Preview or JDK 19 Preview."));
}
@Test
diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt
index d07e05bbee..87a89ca30c 100644
--- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt
+++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/KotlinTestingDsl.kt
@@ -24,7 +24,8 @@ enum class JavaVersion : Comparable {
J15,
J16,
J17, J17__PREVIEW,
- J18, J18__PREVIEW;
+ J18, J18__PREVIEW,
+ J19, J19__PREVIEW;
/** Name suitable for use with e.g. [JavaParsingHelper.parse] */
val pmdName: String = name.removePrefix("J").replaceFirst("__", "-").replace('_', '.').toLowerCase()