This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new e6ddec2 Add Java 12 and Java 13 support e6ddec2 is described below commit e6ddec25eaaf24d87e40cb59eb01f26388ccaf5c 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 | 57 +++++++++++++++++++--- .../jasper/resources/LocalStrings.properties | 4 ++ webapps/docs/changelog.xml | 8 +++ 3 files changed, 63 insertions(+), 6 deletions(-) diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java b/java/org/apache/jasper/compiler/JDTCompiler.java index 6e20eed..4950f3f 100644 --- a/java/org/apache/jasper/compiler/JDTCompiler.java +++ b/java/org/apache/jasper/compiler/JDTCompiler.java @@ -346,14 +346,26 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler { JDT_JAVA_9_VERSION); } else if(opt.equals("10")) { // Constant not available in latest ECJ version that runs on - // Java 7 + // Java 7. + // This is checked against the actual version below. settings.put(CompilerOptions.OPTION_Source, "10"); } else if(opt.equals("11")) { // Constant not available in latest ECJ version that runs on - // Java 7 + // Java 7. + // This is checked against the actual version below. settings.put(CompilerOptions.OPTION_Source, "11"); + } else if(opt.equals("12")) { + // Constant not available in latest available ECJ version. + // 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 available ECJ version. + // May be supported in a snapshot build. + // This is checked against the actual version below. + settings.put(CompilerOptions.OPTION_Source, "13"); } else { - log.warn("Unknown source VM " + opt + " ignored."); + log.warn(Localizer.getMessage("jsp.warning.unknown.sourceVM", opt)); settings.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); } @@ -405,16 +417,30 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler { JDT_JAVA_9_VERSION); } else if(opt.equals("10")) { // Constant not available in latest ECJ version that runs on - // Java 7 + // Java 7. + // This is checked against the actual version below. settings.put(CompilerOptions.OPTION_TargetPlatform, "10"); settings.put(CompilerOptions.OPTION_Compliance, "10"); } else if(opt.equals("11")) { // Constant not available in latest ECJ version that runs on - // Java 7 + // Java 7. + // This is checked against the actual version below. settings.put(CompilerOptions.OPTION_TargetPlatform, "11"); settings.put(CompilerOptions.OPTION_Compliance, "11"); + } else if(opt.equals("12")) { + // Constant not available in latest available ECJ version. + // 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 available ECJ version. + // 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("Unknown target VM " + opt + " ignored."); + log.warn(Localizer.getMessage("jsp.warning.unknown.targetVM", opt)); settings.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); } @@ -485,6 +511,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 233e20b..84293ca 100644 --- a/java/org/apache/jasper/resources/LocalStrings.properties +++ b/java/org/apache/jasper/resources/LocalStrings.properties @@ -135,6 +135,10 @@ jsp.warning.unknown.element.in.variable=Unknown element [{0}] in variable jsp.warning.unknown.element.in.validator=Unknown element [{0}] in validator jsp.warning.unknown.element.in.initParam=Unknown element [{0}] in validator''s init-param jsp.warning.unknown.element.in.function=Unknown element [{0}] in function +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.error.teiclass.instantiation=Failed to load or instantiate TagExtraInfo class: [{0}] jsp.error.non_null_tei_and_var_subelems=Tag [{0}] has one or more variable subelements and a TagExtraInfo class that returns one or more VariableInfo jsp.error.parse.error.in.TLD=Parse Error in the tag library descriptor: [{0}] diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index e3e2029..c7b8cdd 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-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org