On 22/01/2013 22:40, Williams, Nick wrote:
> As you can see from my testing and comment in bug 54461
> (https://issues.apache.org/bugzilla/show_bug.cgi?id=54461), after
> much effort I discovered that "complier" is indeed a parameter, but
> so is "compilerClassName." In order to use anything other than the
> Eclipse JDT compiler, "compilerClassName" must be set to the class
> name of an alternative org.apache.jasper.compiler.Compiler

That statement is not correct.

> The only other implementation at the moment is
> org.apache.jasper.compiler.AntCompiler. The "compiler" parameter ONLY
> affects the AntCompiler compiler right now, and is ignored if the
> JDTCompiler is in use. (No matter what I set "compiler" to, I get
> "org.apache.jasper.compiler.JDTCompiler generateClass WARNING:
> Unknown source VM 1.8 ignored" warnings UNLESS I also set
> compilerClassName to AntCompiler.)

Again, those statements are incorrect. You are doing something wrong.

See org.apache.jasper.JspCompilationContext#createCompiler()


> That aside, my original problem is still unanswered. It appears
> AntCompiler, like JDTCompiler, still uses some compiler other than
> the JDK's built-in javac compiler. Whether I specify "classic,"
> "modern," or "extJavac" as the "compiler" for AntCompiler, I get
> syntax errors for the lambda expression in my JSP. The same lambda
> expression compiles fine in my JDK compiler.

That first statement is also not correct. Ant uses whichever compiler
you tell it to use via the compiler init parameter.

> So, is there any way to use the JDK compiler to compile JSPs?

Yes. The docs [1] cover what you need to do to use javac. To summarise:
- set compiler init parameter for the JSP servlet to modern (or any
  other value from the Ant docs) in $CATALINA_BASE/conf/web.xml
- remove $CATALINA_HOME/ecj-*.jar
- copy ant.jar and ant-launcher.jar to $CATALINA_HOME/lib

>From your description you may have missed some of those steps.

You may also need to copy tools.jar from your Java 8 install to
$CATALINA_HOME/lib. There will be an error message in the logs if
tools.jar is not on the classpath. I didn't check if this was a Java 8
quirk or required for all Java versions. I suspect the latter in which
case it is worth adding to the docs as not everyone reads error messages
that carefully.

> Or, am
> I stuck compiling JSPs at Java 7 until either Eclipse or Ant starts
> supporting Java 8?

Ant already supports Java 8. This is clearly documented in the Ant docs
for the javac task.

There are a few additional changes you'll need to use Java 8.
- set the compilerSourceVM and compilerTargetVM JSP init params to 1.8
  (again this is documented in [1])
- set the suppressSmap JSP init param to false
  Java 8 doesn't like something about the JSP debug info. I'm not sure
  what the root cause is here (Tomcat bug, Java bug or new Java 8
  feature that needs to be supported).

Mark

[1] http://tomcat.apache.org/tomcat-7.0-doc/jasper-howto.html

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

Reply via email to