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 2019/03/21 12:30:08 UTC
[tomcat] branch master updated: Add Java 12 and Java 13 support
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 4ee1a36 Add Java 12 and Java 13 support
4ee1a36 is described below
commit 4ee1a36a221fe31cbffb70c6ebb0c94319a76350
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Mar 21 12:29:43 2019 +0000
Add Java 12 and Java 13 support
If used with an ECJ version that does not support these values, a
warning will be logged and the latest supported version will used.
Based on a patch by Thomas Collignon.
---
java/org/apache/jasper/compiler/JDTCompiler.java | 41 ++++++++++++++++++++++
.../jasper/resources/LocalStrings.properties | 2 ++
webapps/docs/changelog.xml | 8 +++++
3 files changed, 51 insertions(+)
diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java b/java/org/apache/jasper/compiler/JDTCompiler.java
index ac97604..33955d4 100644
--- a/java/org/apache/jasper/compiler/JDTCompiler.java
+++ b/java/org/apache/jasper/compiler/JDTCompiler.java
@@ -324,6 +324,16 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
} else if(opt.equals("11")) {
settings.put(CompilerOptions.OPTION_Source,
CompilerOptions.VERSION_11);
+ } else if(opt.equals("12")) {
+ // 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, "12");
+ } else if(opt.equals("13")) {
+ // 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, "13");
} else {
log.warn(Localizer.getMessage("jsp.warning.unknown.sourceVM", opt));
settings.put(CompilerOptions.OPTION_Source,
@@ -387,6 +397,18 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
CompilerOptions.VERSION_11);
settings.put(CompilerOptions.OPTION_Compliance,
CompilerOptions.VERSION_11);
+ } else if(opt.equals("12")) {
+ // 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, "12");
+ settings.put(CompilerOptions.OPTION_Compliance, "12");
+ } else if(opt.equals("13")) {
+ // 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, "13");
+ settings.put(CompilerOptions.OPTION_Compliance, "13");
} else {
log.warn(Localizer.getMessage("jsp.warning.unknown.targetVM", opt));
settings.put(CompilerOptions.OPTION_TargetPlatform,
@@ -459,6 +481,25 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler {
compilationUnits[i] = new CompilationUnit(fileNames[i], className);
}
CompilerOptions cOptions = new CompilerOptions(settings);
+
+ // Check source/target JDK versions as the newest versions are allowed
+ // in Tomcat configuration but may not be supported by the ECJ version
+ // being used.
+ String requestedSource = ctxt.getOptions().getCompilerSourceVM();
+ if (requestedSource != null) {
+ String actualSource = CompilerOptions.versionFromJdkLevel(cOptions.sourceLevel);
+ if (!requestedSource.equals(actualSource)) {
+ log.warn(Localizer.getMessage("jsp.warning.unsupported.sourceVM", requestedSource, actualSource));
+ }
+ }
+ String requestedTarget = ctxt.getOptions().getCompilerTargetVM();
+ if (requestedTarget != null) {
+ String actualTarget = CompilerOptions.versionFromJdkLevel(cOptions.targetJDK);
+ if (!requestedTarget.equals(actualTarget)) {
+ log.warn(Localizer.getMessage("jsp.warning.unsupported.targetVM", requestedTarget, actualTarget));
+ }
+ }
+
cOptions.parseLiteralExpressionsAsConstants = true;
Compiler compiler = new Compiler(env,
policy,
diff --git a/java/org/apache/jasper/resources/LocalStrings.properties b/java/org/apache/jasper/resources/LocalStrings.properties
index 26f070d..3ae31c9 100644
--- a/java/org/apache/jasper/resources/LocalStrings.properties
+++ b/java/org/apache/jasper/resources/LocalStrings.properties
@@ -302,6 +302,8 @@ jsp.warning.tagPreDestroy=Error processing preDestroy on tag instance of [{0}]
jsp.warning.tagRelease=Error processing release on tag instance of [{0}]
jsp.warning.unknown.sourceVM=Unknown source VM [{0}] ignored
jsp.warning.unknown.targetVM=Unknown target VM [{0}] ignored
+jsp.warning.unsupported.sourceVM=Unsupported source VM [{0}] requested, using [{1}]
+jsp.warning.unsupported.targetVM=Unsupported target VM [{0}] requested, using [{1}]
jsp.warning.xpoweredBy=Warning: Invalid value for the initParam xpoweredBy. Will use the default value of "false"
jspc.delete.fail=Failed to delete file [{0}]
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 8eb14b0..6507864 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -93,6 +93,14 @@
Add support for specifying Java 11 (with the value <code>11</code>) as
the compiler source and/or compiler target for JSP compilation. (markt)
</add>
+ <add>
+ Add support for specifying Java 12 (with the value <code>12</code>) and
+ Java 13 (with the value <code>13</code>) as the compiler source and/or
+ compiler target for JSP compilation. If used with an ECJ version that
+ does not support these values, a warning will be logged and the latest
+ supported version will used. Based on a patch by Thomas Collignon.
+ (markt)
+ </add>
</changelog>
</subsection>
<subsection name="Web applications">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org