Quantcast

Read JSR 045 SMAP Files Produced by Jasper

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Read JSR 045 SMAP Files Produced by Jasper

Eric Sheridan-3
List,

I am developing an application that programmatically leverages the
Apache Jasper JspC facilities to translate JSP source files into their
Java (Servlet) equivalents. For this application, I need to be able to
translate a Java line number back to the original JSP line number. I
have JspC producing SMAP files which should contain most/all the
information I need. However, I am having trouble finding any existing
open source libraries that have the ability to parse JSR 045 SMAP files.
I was hoping to come across an open source library that offered API such as:

SmapParser parser = new SmapParser(inputStream);
Smap smap = parser.parse();
int jspLineNumber = smap.getJspLineNumber(javaLineNumber);

Does any such code exist? If so, would you mind pointing me to
it? If not, any alternative solutions to looking up the original JSP
line number given that I am working with Apache Jasper?

-Eric

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Read JSR 045 SMAP Files Produced by Jasper

Martin Gainty

/* org.apache.jasper.JspCompilationContext implements either of  2 JSP Compilers in TC7  */
            if (options.getCompiler() == null) {
                jspCompiler = createCompiler("org.apache.jasper.compiler.JDTCompiler");
                if (jspCompiler == null) {
                    jspCompiler = createCompiler("org.apache.jasper.compiler.AntCompiler");
                }

 //JDTCompiler has JSR45 support here
     protected void generateClass(String[] smap)
     {
........
        if (! options.isSmapSuppressed()) {
            SmapUtil.installSmap(smap);
        }
    }

// AntCompiler has JSR45 Support
    protected void generateClass(String[] smap)
   {
.............
        if (! options.isSmapSuppressed()) {
            SmapUtil.installSmap(smap);
        }
}

does this answer your question?

Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.






> Date: Mon, 14 Mar 2011 16:53:34 -0400
> From: [hidden email]
> To: [hidden email]
> Subject: Read JSR 045 SMAP Files Produced by Jasper
>
> List,
>
> I am developing an application that programmatically leverages the
> Apache Jasper JspC facilities to translate JSP source files into their
> Java (Servlet) equivalents. For this application, I need to be able to
> translate a Java line number back to the original JSP line number. I
> have JspC producing SMAP files which should contain most/all the
> information I need. However, I am having trouble finding any existing
> open source libraries that have the ability to parse JSR 045 SMAP files.
> I was hoping to come across an open source library that offered API such as:
>
> SmapParser parser = new SmapParser(inputStream);
> Smap smap = parser.parse();
> int jspLineNumber = smap.getJspLineNumber(javaLineNumber);
>
> Does any such code exist? If so, would you mind pointing me to
> it? If not, any alternative solutions to looking up the original JSP
> line number given that I am working with Apache Jasper?
>
> -Eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
     
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Read JSR 045 SMAP Files Produced by Jasper

markt
In reply to this post by Eric Sheridan-3
On 14/03/2011 20:53, Eric Sheridan wrote:
> SmapParser parser = new SmapParser(inputStream);
> Smap smap = parser.parse();
> int jspLineNumber = smap.getJspLineNumber(javaLineNumber);
>
> Does any such code exist? If so, would you mind pointing me to
> it? If not, any alternative solutions to looking up the original JSP
> line number given that I am working with Apache Jasper?

Not that I can think of, but that could be a valuable feature for Jasper
if you were interested in writing a patch. See [1] for more background.
There would be several benefits to being able parse SMAP info.

Mark


[1] https://issues.apache.org/bugzilla/show_bug.cgi?id=49176

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Read JSR 045 SMAP Files Produced by Jasper

Christopher Schultz-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark and Eric,

On 3/15/2011 5:14 AM, Mark Thomas wrote:

> On 14/03/2011 20:53, Eric Sheridan wrote:
>> SmapParser parser = new SmapParser(inputStream);
>> Smap smap = parser.parse();
>> int jspLineNumber = smap.getJspLineNumber(javaLineNumber);
>>
>> Does any such code exist? If so, would you mind pointing me to
>> it? If not, any alternative solutions to looking up the original JSP
>> line number given that I am working with Apache Jasper?
>
> Not that I can think of, but that could be a valuable feature for Jasper
> if you were interested in writing a patch. See [1] for more background.
> There would be several benefits to being able parse SMAP info.

This sounds like something that could be done with a bit of hacking. I
didn't find anything Googling around, either. I did find something
called jclasslib that can be used for inspecting Java .class files but
it's most built as a bytecode browser and decompiler: much more that we
really need.

This information is evidently available via JVMDI, so the JVM must be
loading it somehow. Maybe poking around in OpenJDK would yield some
fruitful results.

The syntax for the Source Maps is pretty simple: the tough part will be
reading it from a Class file because of all the cruft you have to sift
through just to get to the part you want.

I could pretty easily write some code to extract the SMAP extension from
the .class file. It's not hard to ignore a lot of the .class content.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1/jMwACgkQ9CaO5/Lv0PCqcACgiMO65f4Aikj9BtUKkb3TZKIW
EJwAoJBQ7gsGuLYv6Y50YW45dBv4YnQ+
=7HCt
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Read JSR 045 SMAP Files Produced by Jasper

Illya Kysil-2
In reply to this post by Eric Sheridan-3
Eric Sheridan <esheri3 <at> gmail.com> writes:

>
> List,
>
> I am developing an application that programmatically leverages the
> Apache Jasper JspC facilities to translate JSP source files into their
> Java (Servlet) equivalents. For this application, I need to be able to
> translate a Java line number back to the original JSP line number. I
> have JspC producing SMAP files which should contain most/all the
> information I need. However, I am having trouble finding any existing
> open source libraries that have the ability to parse JSR 045 SMAP files.
> I was hoping to come across an open source library that offered API such as:
>
> SmapParser parser = new SmapParser(inputStream);
> Smap smap = parser.parse();
> int jspLineNumber = smap.getJspLineNumber(javaLineNumber);
>
> Does any such code exist? If so, would you mind pointing me to
> it? If not, any alternative solutions to looking up the original JSP
> line number given that I am working with Apache Jasper?

I've just uploaded a code which does source map parsing and resolves the line
numbers across stratum. This code was created back in 2004 as part of
JspCompiler module for NetBeans 3.6.

See class Resolver and methods main and resolve.

See https://github.com/ikysil/sourcemap for the code repository.





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...