Hi,

The current scheme ( used by some IDEs ) is to generate a comment in 
the source code. This could be used by parsing the java file and
constructing a map.

I would like to change that to generate a "real" map that could be 
used programmatically by the error reporting code ( and simplify the work
 for debuggers ).

I'm not sure what would be the best structure for that.

One solution is to generate something very simple:

// The files that are used ( the first part of all marks
String _fileId[]= { "file1.jsp" , "file2.jsp" };

int _lineMap[][] = { { 1, 2, 3, 4, 5 }, ... };

The int[][] will have start-stop line number in the java code, 
start-stop positions in the jsp page, and file id ( index in _fileId[] )

If an exception happens ( or if you debug the page ) the 2 arrays are
processed into something easier to process ( Map, etc ), but the generated
code is much easier and the overhead is minimal.

One alternative would be to generate the real structure - but that would
involve a lot of Object creations.


A related issue:

For "large" JSP pages we can generate a .dat file containing the chunks. 
We also geneate a .ver file ( for a simplified versioning class mangling).

Long term, I would like to generalize this and for each JSP page generate
2 files: the java ( or direct class ) file and a .dat file combining all
those informations:
- version, other usefull meta-data ( compile date, timing for
generation/compiliation, etc )
- all the chunks ( as UTF16 )
- pre-processed chunks to the desired encoding ( for fast output when
the container allow that ) ( equivalent with a byte[] addition to the java
file )
- line mappings

There are few big benefits on going this route:
- much lower overhead on the VM ( smaller class files). It is prety hard
to unload class files.
- better scalability ( as a result of the previous ). Lower memory
overhead and the ability to control the amount of static data that is kept 
in memory.
- enable a number of big performance tricks: the Liaison could even go
directly to the connector and send pointer to the chunks instead of actual
chunks, and let apache use it's magic to send file regions.
   
What do you think ?

Costin

Reply via email to