<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: Jasper: The Saga Continues.</title>
    <link>http://blog.objectmentor.com/articles/2007/02/04/jasper-the-saga-continues</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Jasper: The Saga Continues.</title>
      <description>&lt;p&gt;It&amp;#8217;s Sunday.  Justin came in second in his wrestling tournament.  And I downloaded the source code for Tomcat to figure out how the Jasper compiler works.  &lt;em&gt;sigh&lt;/em&gt;&lt;/p&gt;


	&lt;p&gt;I have an hour or so before Ann Marie and I drive to Angela&amp;#8217;s house to visit our three granddaughters, then pick up some things at Sam&amp;#8217;s club, and then I fly to Pennsylvania to kick off an Agile transition for a new customer.&lt;/p&gt;


	&lt;p&gt;Last night, after the tournament, I started studying how &lt;code&gt;Jasper&lt;/code&gt; works.  At the high level, Jasper is a fairly standard compiler that parses it&amp;#8217;s input and creates an intermediate representation of nodes.  It generates java output by walking those nodes with code-generating visitors.&lt;/p&gt;


	&lt;p&gt;At the low level Jasper was written by slinging a lot of brute force code around.  There are long &lt;code&gt;if/else&lt;/code&gt; chains, and funky variables like &lt;code&gt;t1&lt;/code&gt;, &lt;code&gt;t2&lt;/code&gt;, &lt;code&gt;t3&lt;/code&gt;, and &lt;code&gt;t4&lt;/code&gt;.  For some reason the authors felt they should do their own parsing rather than using &lt;code&gt;antlr&lt;/code&gt; or &lt;code&gt;javacc&lt;/code&gt;; but that&amp;#8217;s fine with me.  &lt;span class="caps"&gt;JSP&lt;/span&gt; is a pretty simple syntax after all.&lt;/p&gt;


	&lt;p&gt;What I&amp;#8217;ve learned so far is that there are quite a few ways for the compiler to ignore the &lt;code&gt;taglib&lt;/code&gt; directive.  I don&amp;#8217;t understand yet what all those reasons are, I can just see the &lt;code&gt;if&lt;/code&gt; statements that silently bypass that processing.  Some are based on a variable named &lt;code&gt;isDirective&lt;/code&gt;.  This variable is passed down a long chain of calls from the upper levels of the compiler, down to the lower reaches of the generators.  I still haven&amp;#8217;t figured out why it gets set, but I think it might have something to do with a special compiler pass or something.&lt;/p&gt;


	&lt;p&gt;Anyway, I won&amp;#8217;t bore you with the details right now.  I&amp;#8217;ll just see if I can learn anything more about how this thing works.&lt;/p&gt;


But I will say that it&amp;#8217;s a shame that I have to dig through compiler code to figure out why Jasper generates code differently in the tomcat environment and the command-line environment.
&lt;hr&gt;
Two hours later&amp;#8230;  
While digging through the compiler code, I noticed that there are lots of nice debug logging messages.  If I could turn on debug logging, I could get a sense about what&amp;#8217;s happening inside the compiler.

	&lt;p&gt;So now all I have to do is turn on debug logging.  That ought to be easy, right?...&lt;/p&gt;</description>
      <pubDate>Sun, 04 Feb 2007 11:04:19 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b24afc16-958c-45bb-ae0a-abbfeddb60ec</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2007/02/04/jasper-the-saga-continues</link>
      <category>Uncle Bob's Blatherings</category>
      <trackback:ping>http://blog.objectmentor.com/articles/trackback/132</trackback:ping>
    </item>
  </channel>
</rss>
