[antlr-interest] StringTemplate issue

Terence Parr parrt at cs.usfca.edu
Mon Jun 21 10:39:04 PDT 2004


On Jun 21, 2004, at 3:03 AM, birmanstefan wrote:

> Hello Ter,
>
>     I used a jarred app, which includes a library of templates, and
> run in a "Can't load template" error. It seems that it tries to load
> template from an illegal path. I put a testcase in group's files
> directory called test4tp.jar (includes all you need to reproduce the
> issue).
>
>     The fix was to create a group without a root directory and include
> all the templates in the root of the jar. The bad thing is that it
> doesn't preserve the hierarchy in jar file and have to modify in
> original code (=> two versions : for jarred and un-jarred app).
>
>     I took a look in the  StringTemplateGroup.loadTemplate() and I saw
> that it uses some classLoader stuff to load the template. Enlarging
> this mechanism in order to be able to load templates from dir
> structure in a jar file (JAR URL) should fix the issue. I'm not very
> familiar with this mechanism, so I must ask : am I looking in the
> wrong direction?

Hmm...for the code generator I'm working on now, I use "fully 
qualified" template names like "org/antlr/codegen/templates/foo" which 
it loads from the classpath.  I do this rather than paths under a 
rootDir as I don't know where the app will be unjar'd or used.  Are you 
saying that Java's jar mechanism doesn't duplicate this when the dir is 
jar'd up?  Ack!  If so, I'll have to dig into and figure out what do.

>     On the other hand, are there any news on StringTemplates 2.0?

It's totally great!  Still haven't done the manual, but I'm testing out 
the features now for the ANTLR 3.0 code generator.  StringTemplate for 
code gen is amazingly fabulous! (er...if I do say so myself).  I expect 
to get that out in July.  Want a pre-release copy?  Send me email 
directly. :)

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Cofounder, http://www.peerscope.com pure link sharing





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list