[antlr-interest] class loaders
Terence Parr
parrt at cs.usfca.edu
Mon Aug 7 17:04:03 PDT 2006
On Aug 5, 2006, at 1:56 AM, Martin Probst wrote:
> Hi,
>
>> I know hibernate and other people have asked me to correct this
>> previously in ANTLR.the " correct" method was as you see first above.
>>
>> So, what is the correct answer? do we need a flag that says
>> which flavor to use?
>
> 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();
}
...
Ter
More information about the antlr-interest
mailing list