[antlr-interest] class loaders

Micheal J open.zone at virgin.net
Tue Aug 8 00:38:39 PDT 2006


Hi,

> > I think the problem is indeed that there is no correct way of doing
> > this. Java supports AFAIK two ways of doing this, one is the class  
> > loader hierarchy that is being used with Class.forName() and the  
> > other one is the hack with Thread.currentThread 
> > ().getContextClassLoader(), which is used by Tomcat et al. where  
> > containers can set this class loader for the sub-contexts in the  
> > app. Both ways have their justification.
> 
> Thanks Martin.  I have set to allow both in both ANTLR and ST:
> 
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> if ( cl==null ) {
>      cl = this.getClass().getClassLoader();
> }
> ...

Would be more useful it it was configurable via some API (preferable on a
per-instance basis). This better supports the use of ST, ANTLR and
ANTLR-based products in embedded mode.

Micheal



More information about the antlr-interest mailing list