Bug 56012 - wrong import statement generation while using the extends attribute of the page directive
Summary: wrong import statement generation while using the extends attribute of the pa...
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: trunk
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2014-01-15 07:30 UTC by Eugene Chung (TmaxSoft)
Modified: 2014-01-18 21:30 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Chung (TmaxSoft) 2014-01-15 07:30:17 UTC
Here is the test example, extends.jsp,

<%@ page import="dvt.jsp.jaspertest.*" %>
<%@ page extends="TestJspBase" %>

and its TestJspBase.java.

package dvt.jsp.jaspertest;

import jeus.servlet.jsp.HttpJspBase;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class TestJspBase extends HttpJspBase {
    public void _jspService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /* do nothing here */

I know that the fully qualified class name must be used while using the extends attribute of the page directive. But the java generator of jasper has also a problem.

 * Generated by the Jasper component of Apache Tomcat
 * Version: Apache Tomcat/7.0.50
 * Generated at: 2014-01-15 04:56:28 UTC
 * Note: The last modified time of this file was set to
 *       the last modified time of the source file after
 *       generation to assist with modification tracking.
package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import dvt.jsp.jaspertest.*;
import TestJspBase;

public final class extends_jsp extends TestJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

The problem is 'import TestJspBase;'.

The java language spec. does not allow the class name of default package.

In my opinion, no import statement generation would be best for the simple class name.


    public void setExtends(String value, Node.PageDirective n) {
        xtends = value;

FYI, there was a time that such import statement was possible to use until it was fixed at JDK 1.4.
Comment 1 Eugene Chung (TmaxSoft) 2014-01-15 07:35:46 UTC
It is a compile time error to import a type from the unnamed package.
(from http://docs.oracle.com/javase/specs/jls/se5.0/html/packages.html#70209)
Comment 2 Mark Thomas 2014-01-18 21:30:44 UTC
Thanks for the report and especially for the references. Having that information to hand makes the fix a lot quicker as we don't have to go digging to find it ourselves

The fix has been applied to 8.0.x for 8.0.0 onwards and to 7.0.x for 7.0.51 onwards.