Bug#305325: checkstyle: Antlr dependency should be == 2.7.2

David Blaikie David Blaikie <dblaikie@bigpond.net.au>, 305325@bugs.debian.org
Wed Apr 20 04:54:01 2005


On Wed, Apr 20, 2005 at 05:35:13AM +0200, Michael Koch wrote:
> On Wed, Apr 20, 2005 at 01:37:44PM +1000, David Blaikie wrote:
> > On Tue, Apr 19, 2005 at 11:57:56AM +0200, Michael Koch wrote:
> > > On Tue, Apr 19, 2005 at 07:30:47PM +1000, David Blaikie wrote:
> > > > Package: checkstyle
> > > > Version: 3.4-8
> > > > Severity: important
> > > > 
> > > > Checkstyle apparently cannot run properly with Antlr 2.7.5 (latest in Debian
> > > > Sid). I haven't tested intermediate versions but Checkstyle's documentation
> > > > (and my experimentation) shows that it runs as required with Antlr 2.7.2
> > > 
> > > And what are the problems? What doesn't work? Do you have a simple testcase for this?
> > > I use checkstyle locally without any problems.
> > 
> > Sorry, I just reread that bug report and realised how useless/erroneous it
> > was. Seems the specific issue I was having is that the Checkstyle Ant task
> > fails (if you are interested I can provide comparative output, but I haven't
> > produced a trivial test case) when antlr.jar is in (or linked from)
> > /usr/share/ant/lib (as is the case with the Debian antlr package). Not sure if
> > this is an irreconcileable conflict, but in any case I'm not sure it's a bug I
> > can really file against any specific package. This can be closed, sorry for
> > the inconvenience.
> 
> Please attach the output you have to this bug and I will se what I can do.

It seems there's a fundamental conflict between the ANTLR Ant Task (or more
generally, having antlr.jar in the global CLASSPATH or Ant's lib directory -
even if you aren't actively using the ANTLR Task) and the Checkstyle Ant Task.
There's a passing comment about it in an Ant development proposal here:

http://fisheye.cenqua.com/viewrep/~raw,r=1.3/ant/proposal/mutant/docs/desc.html

Basically if I have Ant with antlr.jar in ant/lib (as is the state when the
antlr and ant debian packages are installed) and I use the checkstyle task,
including in its classpath all the checkstyle jars (including or excluding
antlr.jar, it doesn't matter) then checkstyle will fail to run properly,
producing errors such as this:

[checkstyle] Can't find/access AST Node
typecom.puppycrawl.tools.checkstyle.api.DetailAST

(repeated several times)

[checkstyle]
/home/dblaikie/work/honours/ssaburg/src/au/edu/usyd/it/ssaburg/Expression.java:0:
Got an exception - java.lang.ClassCastException: antlr.CommonAST

(things like this for every source file)

due to the way Ant sets up the ClassLoader hierarchy, the Antlr classes are
loaded by the base loader which is above the loader used for the checkstyle
classes, therefore the Antlr classes cannot access the checkstyle classes (but
checkstyle can access antlr classes). Even including the antlr.jar in the
local classpath used to load the checkstyle task is insufficient as Java's
ClassLoader delegation model still causes the base antlr.jar to be used.

And this is all quite a pity, but I don't think there's much to be done about
it. I think I'll just manually execute Checkstyle 4.0 (has a few more features
that are nice, and can handle generics, more or less) every now and then.. 

Thanks,
David

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d+@ s++: a-- C++++ ULS++ P L++ !E W++ N+ o? K? w(+) O? M@ V? PS+ PE@ 
Y+ PGP- t(+) 5 X+ R? tv+ b+ DI++ D++ G+ e h! r !y
------END GEEK CODE BLOCK------