Bug 46470 - JspC may omit tld dependency from generated files when caching is on
Summary: JspC may omit tld dependency from generated files when caching is on
Status: RESOLVED WONTFIX
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 6.0.18
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-04 13:36 UTC by Konstantin Kolinko
Modified: 2009-01-04 15:53 UTC (History)
0 users



Attachments
webapp that reproduces the issue when compiled by JspC (3.56 KB, application/zip)
2009-01-04 13:55 UTC, Konstantin Kolinko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2009-01-04 13:36:58 UTC
When JspC compiler of Jasper is called with caching turned on (the default), it omits dependency on .tld file of a library from generated java code of all the pages that reference the library, except the first one compiled.

It does not occur when compiling the pages at runtime, because tag information caching is only implemented in JspC command line / ant task compiler.

The workaround is to turn caching off, but you will face performance issues (see #33650).

I do not think that this issue is of great value. Most likely nobody will be bothered by omitting that dependency. I encountered it while investigating the bug #37084
Comment 1 Konstantin Kolinko 2009-01-04 13:55:47 UTC
Created attachment 23082 [details]
webapp that reproduces the issue when compiled by JspC

To reproduce the issue:

1. Create the following subdirectory and two subdirectories in it:
 bugNnnnn
   /output
   /source

2. Unzip the war file into bugNnnnn/source

3. Launch JspC compiler from an ant task, or from command line with the following arguments:

-uriroot bugNnnnn\source -d bugNnnnn\output

4. Compare the generated files "source1_jsp.java" and "source2_jsp.java" that are in a subdirectory of bugNnnnn\output

Here is the difference:

***** source1_jsp.java

  static {
    _jspx_dependants = new java.util.ArrayList(1);
    _jspx_dependants.add("/WEB-INF/example-taglib.tld");
  }

  private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005feg_005fShowSource_0026_005fjspFile_005fnobody;
***** source2_jsp.java

  private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005feg_005fShowSource_0026_005fjspFile_005fnobody;
*****

The source1.jsp and source2.jsp files are the same, thus there should be no such difference in the generated files.

5. Delete the generated files from bugNnnnn/output

Credits: This web application is an excerpt from the examples application bundled with TC.

The cause:
This dependency information is generated by the following lines of TagLibraryInfoImpl class (as of tc6.0.x):

165:   PageInfo pageInfo = ctxt.createCompiler().getPageInfo();
166:   if (pageInfo != null) {
167:        pageInfo.addDependant(location[0]);
168:   }

Those lines belong to the constructor of the class and are not executed when the class is reused from the cache.

I reproduced the issue in the current tc6.0.x and I expect it to exist in TC 6.0.18 release as well.

I suppose that it also exists in TC 5.5.27, though have not yet tested there.
Comment 2 Mark Thomas 2009-01-04 15:53:18 UTC
The dependency information is used when doing on-the-fly compilation. I don't believe it is used in the case of pre-compilation therefore, I do not see a need to fix this.

You could go as far as arguing the dependency information is unnecessary when using JspC and remove it but I doubt that that optimisation is worth the effort it would take to code it.

If you can think of a use case where this would matter, please feel free to re-open this issue.