-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
After upgrade of ECJ version Jastow is unable to properly compile some JSPs with local classes (i.e. nested classes defined in scriplet) - ECJ now issues additional call 'isPackage' for such classes and existing implementation in JDTCompiler class doesn't work with nested classes.
Here is an example of simple JSP, which fails compilation:
<%@ page import="java.util.*"%><% class InnerClass { } List<InnerClass> list = new ArrayList<>(); for(InnerClass elements : list) { } %>
Attempt to compile this JSP causes following error:
org.apache.jasper.JasperException: org.apache.jasper.JasperException: JBWEB004001: Unable to compile class for JSP at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549) [jastow-2.0.10.Final.jar:2.0.10.Final] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:379) [jastow-2.0.10.Final.jar:2.0.10.Final] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403) [jastow-2.0.10.Final.jar:2.0.10.Final] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347) [jastow-2.0.10.Final.jar:2.0.10.Final] <...> Caused by: org.apache.jasper.JasperException: JBWEB004001: Unable to compile class for JSP at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:667) [jastow-2.0.10.Final.jar:2.0.10.Final] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358) [jastow-2.0.10.Final.jar:2.0.10.Final] ... 47 more Caused by: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.PlainPackageBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.TypeBinding at org.eclipse.jdt.internal.compiler.ClassFile.getTypeBinding(ClassFile.java:6328) at org.eclipse.jdt.internal.compiler.ClassFile.traverse(ClassFile.java:7402) at org.eclipse.jdt.internal.compiler.ClassFile.generateStackMapTableAttribute(ClassFile.java:5199) at org.eclipse.jdt.internal.compiler.ClassFile.completeCodeAttribute(ClassFile.java:1688) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:368) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:291) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:761) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:831) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:412) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:913) at org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:575) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:475) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426) at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:445) [jastow-2.0.10.Final.jar:2.0.10.Final] at org.apache.jasper.compiler.Compiler.compile(Compiler.java:359) [jastow-2.0.10.Final.jar:2.0.10.Final] at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334) [jastow-2.0.10.Final.jar:2.0.10.Final] at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321) [jastow-2.0.10.Final.jar:2.0.10.Final] at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:652) [jastow-2.0.10.Final.jar:2.0.10.Final] ... 48 more
This fix seems to be simple – JDTCompiler.isPackage method need to be updated to handle nested classes name, i.e. instead of:
private boolean isPackage(String result) { if (result.equals(targetClassName)) { return false; } ...
it should be following:
{code:java}private boolean isPackage(String result) { if (result.equals(targetClassName) || result.startsWith(targetClassName + '$')) { return false; } ...
This issue was already observed in original Jasper project:
- Tomcat thread: https://www.mail-archive.com/users@tomcat.apache.org/msg135001.html
- Tomcat fix: https://github.com/apache/tomcat/commit/85e93fbf55e22dcfb6bbc54b9413051ccbabe5c0
And similar issue was also fixes in OpenLiberty project:
- OpenLiberty issue: https://github.com/OpenLiberty/open-liberty/issues/19197
- OpenLiberty fix: https://github.com/OpenLiberty/open-liberty/pull/19202
This issue in Undertow / Jastow code causes regression in WildFly 25+ – the same JSP page was compiling without problem in WF 24, but fails in later version.
- is incorporated by
-
JBEAP-23729 [GSS](7.4.z) UNDERTOW-2104 - JSP compilation error when using inner classes
- Closed
-
WFLY-16745 Upgrade legacy jastow from 2.0.10.Final to 2.0.11.Final
- Closed
- is related to
-
UNDERTOW-1909 Switch Eclipse JDT group coordinates from org.eclipse.jdt.core.compiler to org.eclipse.jdt
- Resolved