Bug 21168 - Incorrect paths in generated SMAP file entries
Summary: Incorrect paths in generated SMAP file entries
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.0.3
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2003-06-29 01:22 UTC by Jim Hennessy
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
Proposed patch (2.10 KB, patch)
2003-07-22 08:41 UTC, Eric Carmichael
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Hennessy 2003-06-29 01:22:29 UTC
One of the new features of Jasper in Tomcat 5 is that it attaches a "Source
Map" attribute to class files to describe the file name and line number
mapping from a JSP source file to the generated Java source file.

The SMAP that I see in the class files generated by Jasper (5.0.3 alpha)
has a couple of small problems:

1. The second line of the SMAP, according to JSR-45, is the name of the
   generated source file.  This name should be without path information,
   but path information appears in the version generated by Jasper.

2. In the "*F" section, there's a pair of lines that defines the JSP file.
   The second line is the source path for the JSP file.  The path created
   by Jasper contains a leading slash, making it an absolute path.  It
   should be relative; the leading slash should not appear.
Comment 1 Eric Carmichael 2003-07-22 08:40:24 UTC
The second line of the SMAP contains path information on Windows machines 
because SmapUtil.java's generateSmap() method calls unqualify() to remove the 
path information, and unqualify() only works on pathname strings with "/" as 
the name-separator character.  I fixed this by rewriting unqualify().

The leading slash in the source path in the "*F" section originates deep 
within Tomcat (for instance, in a call to HttpServletRequest.getServletPath() 
when the request is first touched), so I chose to remove the leading slash 
just before writing the source path to the SMAP.

I will attach a patch containing these fixes.
Comment 2 Eric Carmichael 2003-07-22 08:41:29 UTC
Created attachment 7441 [details]
Proposed patch
Comment 3 Jan Luehe 2003-08-05 01:17:54 UTC
Applied patch with slight modification:

Instead of (as suggested in the patch):

  private static String unqualify(String path) {
    File f = new File(path);
    return f.getName();
  }

the impl now does this:

  private static String unqualify(String path) {
    return path.substring(path.lastIndexOf(File.separator) + 1);
  }

which avoids generation of a File object.