You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/01/06 11:47:13 UTC

[tomcat] branch main updated: Add Java 21 source/target support for JSPs (if JDT version supports it)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new bb81a2cf7a Add Java 21 source/target support for JSPs (if JDT version supports it)
bb81a2cf7a is described below

commit bb81a2cf7abf2384e73bdac0313731b8963b9b66
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jan 6 11:46:53 2023 +0000

    Add Java 21 source/target support for JSPs (if JDT version supports it)
---
 java/org/apache/jasper/compiler/JDTCompiler.java | 21 +++++++++++++--------
 webapps/docs/changelog.xml                       |  7 +++++++
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java b/java/org/apache/jasper/compiler/JDTCompiler.java
index 1b71dc5169..65868661e0 100644
--- a/java/org/apache/jasper/compiler/JDTCompiler.java
+++ b/java/org/apache/jasper/compiler/JDTCompiler.java
@@ -316,15 +316,17 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
             } else if(opt.equals("18")) {
                 settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_18);
             } else if (opt.equals("19")) {
+                settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_19);
+            } else if (opt.equals("20")) {
                 // Constant not available in latest ECJ version shipped with
                 // Tomcat. May be supported in a snapshot build.
                 // This is checked against the actual version below.
-                settings.put(CompilerOptions.OPTION_Source, "19");
-            } else if (opt.equals("20")) {
+                settings.put(CompilerOptions.OPTION_Source, "20");
+            } else if (opt.equals("21")) {
                 // Constant not available in latest ECJ version shipped with
                 // Tomcat. May be supported in a snapshot build.
                 // This is checked against the actual version below.
-                settings.put(CompilerOptions.OPTION_Source, "20");
+                settings.put(CompilerOptions.OPTION_Source, "21");
             } else {
                 log.warn(Localizer.getMessage("jsp.warning.unknown.sourceVM", opt));
                 settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_11);
@@ -390,17 +392,20 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
                 settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_18);
                 settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_18);
             } else if (opt.equals("19")) {
-                // Constant not available in latest ECJ version shipped with
-                // Tomcat. May be supported in a snapshot build.
-                // This is checked against the actual version below.
-                settings.put(CompilerOptions.OPTION_TargetPlatform, "19");
-                settings.put(CompilerOptions.OPTION_Compliance, "19");
+                settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_19);
+                settings.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_19);
             } else if (opt.equals("20")) {
                 // Constant not available in latest ECJ version shipped with
                 // Tomcat. May be supported in a snapshot build.
                 // This is checked against the actual version below.
                 settings.put(CompilerOptions.OPTION_TargetPlatform, "20");
                 settings.put(CompilerOptions.OPTION_Compliance, "20");
+            } else if (opt.equals("21")) {
+                // Constant not available in latest ECJ version shipped with
+                // Tomcat. May be supported in a snapshot build.
+                // This is checked against the actual version below.
+                settings.put(CompilerOptions.OPTION_TargetPlatform, "21");
+                settings.put(CompilerOptions.OPTION_Compliance, "21");
             } else {
                 log.warn(Localizer.getMessage("jsp.warning.unknown.targetVM", opt));
                 settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_11);
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e032a9a203..268b2cb7d7 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -167,6 +167,13 @@
         is already called from within a privileged block and skipping the
         unnecessary privileged block improves performance. (markt)
       </fix>
+      <add>
+        Add support for specifying Java 21 (with the value <code>21</code>) as
+        the compiler source and/or compiler target for JSP compilation. If used
+        with an Eclipse JDT compiler version that does not support these values,
+        a warning will be logged and the default will used.
+        (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Other">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org