ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Cody <>
Subject RE: Code format validation
Date Mon, 14 Jan 2002 23:58:10 GMT
Importscrubber is nice, but is doesn't really work.  I cannot recommend it
for anything other than the simplest code. 

Importscrubber uses the BCEL library to figure out what classes are needed
by a particular source file, eliminates unneeded import statements, and
sorts the result.  So far so good.  However, due to the fact that constants
are folded into the bytecode by ${build.compiler}, it removes some import
statements that are required to compile but not included in the classfile.
For example:

import org.example.Constants;

switch (val) {
case (Constants.A):

If you run importscrubber against this, the import statement will be removed
since the switch constants were folded into the bytecode and there is no
need to put the class reference in the classfile constant pool.  So the next
time you try to compile it from source, it fails.

Anyway, the solution requires a more sophisticated approach that basically
boils down to writing part of a java compiler.  I'm interested if other
people know if (open) tools that do this correctly...


> -----Original Message-----
> From: Ylan Segal []
> Sent: Monday, January 14, 2002 4:00 PM
> To: Ant Users List
> Subject: RE: Code format validation
> Take a lok at:
> There is a link there for Importscrubber.. it is just what you want.
> I tried it myself and found it to be a nice tool. It does 
> clean up import
> statements, but sometimes sources will fail to compile 
> afterwards. In my
> case it happened in classes where I was using objects with 
> same name like
> java.util.Date and java.sql.Date. importscrubber thought I 
> should import
> both, which caused ambiguity and the compiler complained. Easily fixed
> though.
> I suggest running it against a copy of your sources to be 
> safe and decide
> for yourself if you like what you see.
> Ylan.
> >  -----Original Message-----
> > From: 	Matthew Pullen []
> > Sent:	Monday, January 14, 2002 5:49 PM
> > To:
> > Subject:	Code format validation
> >
> > Hello,
> > 	As with all projects, they tend to change a bit over 
> time.  This leaves
> you with unused import statments all over the place. I don't 
> like the import
> blah.* format either.  I was curious if there is an automated 
> way to check
> this in particular using ant, or an add in to ant?  I have tried using
> checkstyle, but it doesn't appear to work with 1.4.
> >
> > Matthew Pullen << File: ATT00013.txt >>
> --
> To unsubscribe, e-mail:   
> <>
> For additional commands, e-mail: 
> <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message