Bug 1193553 - Web container isn't able to compile JSPs containing JDK 8 specific code (lambda expressions)
Summary: Web container isn't able to compile JSPs containing JDK 8 specific code (lamb...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Web
Version: 6.4.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ER3
: EAP 6.4.0
Assignee: Rémy Maucherat
QA Contact: Michael Cada
URL:
Whiteboard:
Depends On: 1194560 1194562
Blocks: 1194436
TreeView+ depends on / blocked
 
Reported: 2015-02-17 15:25 UTC by Radim Hatlapatka
Modified: 2019-08-19 12:41 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1194436 (view as bug list)
Environment:
Last Closed: 2019-08-19 12:41:03 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
reproducer web app (2.07 KB, application/zip)
2015-02-17 15:25 UTC, Radim Hatlapatka
no flags Details
new reproducer web app (2.06 KB, application/zip)
2015-02-19 15:45 UTC, Radim Hatlapatka
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1195911 0 unspecified CLOSED RHEL6 RPMs: Upgrade ecj-eap6 to 4.4.2.redhat-1 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 1195912 0 unspecified CLOSED RHEL5 RPMs: Upgrade ecj-eap6 to 4.4.2.redhat-1 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 1195914 0 unspecified CLOSED RHEL7 RPMs: Upgrade ecj-eap6 to 4.4.2.redhat-1 2021-02-22 00:41:40 UTC
Red Hat Issue Tracker WFLY-4362 0 Critical Closed Web container (undertow) isn't able to compile JSPs containing JDK 8 specific code (lambda expressions) 2018-02-22 08:35:53 UTC

Internal Links: 1195911 1195912 1195914

Description Radim Hatlapatka 2015-02-17 15:25:19 UTC
Created attachment 992740 [details]
reproducer web app

Description of problem:
Accessing JSP with JDK8 specific code (namely lambda expressions) fails due compilation error

Version-Release number of selected component (if applicable): EAP 6.4.0


How reproducible:
always

Steps to Reproduce:
1. Deploy web app with jsp containing lambda expressions (you can use attached app)
2. Visit the jsp from URL (http://localhost:8080/lambda-expression-test/jsp-with-lambdas.jsp)


Actual results: JSP failed to compile, see [1]

Expected results: JSP was compiled and properly evaluated

Additional info:
I have tried changing source-vm and target-vm in /subsystem=web/configuration=jsp-configuration to 1.8 and it didn't help, by looking to code (org.apache.jasper.compiler.JDTCompiler) it seems that only version till 1.7 can be set.


[1]
org.apache.jasper.JasperException: JBWEB004062: Unable to compile class for JSP: 

JBWEB004060: An error occurred at line: 10 in the jsp file: /jsp-with-lambdas.jsp
n cannot be resolved to a variable
7: //    System.out.println(answerToEverything);
8: 
9:     List<Integer> list = Arrays.asList(1, 2, 3);
10:     Arrays.asList(1).forEach(n-> System.out.println(n));
11: 
12:     list.forEach(n -> response.getWriter().write("<p>" + n + "</p>"));
13: 


JBWEB004060: An error occurred at line: 10 in the jsp file: /jsp-with-lambdas.jsp
Syntax error on token "-", -- expected
7: //    System.out.println(answerToEverything);
8: 
9:     List<Integer> list = Arrays.asList(1, 2, 3);
10:     Arrays.asList(1).forEach(n-> System.out.println(n));
11: 
12:     list.forEach(n -> response.getWriter().write("<p>" + n + "</p>"));
13: 


JBWEB004060: An error occurred at line: 10 in the jsp file: /jsp-with-lambdas.jsp
n cannot be resolved to a variable
7: //    System.out.println(answerToEverything);
8: 
9:     List<Integer> list = Arrays.asList(1, 2, 3);
10:     Arrays.asList(1).forEach(n-> System.out.println(n));
11: 
12:     list.forEach(n -> response.getWriter().write("<p>" + n + "</p>"));
13: 


JBWEB004060: An error occurred at line: 12 in the jsp file: /jsp-with-lambdas.jsp
n cannot be resolved to a variable
9:     List<Integer> list = Arrays.asList(1, 2, 3);
10:     Arrays.asList(1).forEach(n-> System.out.println(n));
11: 
12:     list.forEach(n -> response.getWriter().write("<p>" + n + "</p>"));
13: 
14: %>
15: </body>


JBWEB004060: An error occurred at line: 12 in the jsp file: /jsp-with-lambdas.jsp
Syntax error on token "-", -- expected
9:     List<Integer> list = Arrays.asList(1, 2, 3);
10:     Arrays.asList(1).forEach(n-> System.out.println(n));
11: 
12:     list.forEach(n -> response.getWriter().write("<p>" + n + "</p>"));
13: 
14: %>
15: </body>


JBWEB004060: An error occurred at line: 12 in the jsp file: /jsp-with-lambdas.jsp
n cannot be resolved to a variable
9:     List<Integer> list = Arrays.asList(1, 2, 3);
10:     Arrays.asList(1).forEach(n-> System.out.println(n));
11: 
12:     list.forEach(n -> response.getWriter().write("<p>" + n + "</p>"));
13: 
14: %>
15: </body>


JBWEB004211: Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:69)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:461)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:361)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:326)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:606)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:309)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:242)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

Comment 1 Rémy Maucherat 2015-02-17 16:03:24 UTC
It would also need JDT 4.4. I see no actual user benefit, so dev- for 6.4.0.

Comment 2 Jimmy Wilson 2015-02-17 16:31:58 UTC
@Remy, how can we NAK something like this while saying we support Java 8?

Comment 3 Rémy Maucherat 2015-02-17 17:20:48 UTC
This is not about running on Java 8, it is about putting some Java 8 code in webapps sources.

But anyway, if it is a blocker, someone needs to set the blocker flag.

Comment 5 JBoss JIRA Server 2015-02-19 11:58:35 UTC
Tomaz Cerar <tomaz.cerar> updated the status of jira WFLY-4362 to Coding In Progress

Comment 6 Dimitris Andreadis 2015-02-19 13:14:05 UTC
The primary reason our customers will want to move to Java 8 is because Oracle Java 7 goes EOL in April 2015, not because they re-wrote their applications to use lambda expressions.

So IMO this can be release noted and solved in a CP.

Comment 7 Tomaz Cerar 2015-02-19 13:28:01 UTC
For upstream fix is two part.
1) fix the jastow (jasper fork for undertow) to allow source & target to be 1.8
PR for that: https://github.com/undertow-io/jastow/pull/15
2) update ecj to 4.4.1 in wildfly

PR for wildfly is pending jastow release.

Comment 8 Rémy Maucherat 2015-02-19 15:33:36 UTC
Very well then, changing the dev flag.

Comment 9 Radim Hatlapatka 2015-02-19 15:45:22 UTC
Created attachment 993682 [details]
new reproducer web app

In the previous example war there wasn't caught IOException causing that it would fail even after JDK 1.8 compilation fix. Updating the example with correct web app.

Comment 10 John Doyle 2015-02-19 16:40:00 UTC
I removed the blocker flag.  If we can get this into ER3 then let's do that.  If we cannot get it in that build, and need another build, then it can go there.  If ER3 is the GA, then let's target it for a CP.

Comment 11 Rémy Maucherat 2015-02-19 17:14:50 UTC
The update to ECJ 4.4 is not risky at all, it is a compiler with very high use, and is already integrated in Tomcat.

Comment 12 Radim Hatlapatka 2015-02-27 14:04:31 UTC
Verified with EAP 6.4.0.ER3


Note You need to log in before you can comment on or make changes to this bug.