ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Tool to find unused methods
Date Mon, 25 Mar 2002 16:26:12 GMT
Thanks for stating the main caveat of such tools, Drew. Most tools are not
magic bullets, and require proper use and understanding of their internal
functioning. It's up to us to use them diligently. I'm sure the jarmaker (or
whatever it's real name is) folks have thought of that too. At the very
least it's up to you to provide com.lgc.Foo as one the starting point for
the search. And you can always unit test and test the generated JARs once
generated to ensure you didn't miss anything. It's all a matter of
perspective.

In the question at hand, it was more to remove dead code than to package a
lean Java app anyway. --DD

 -----Original Message-----
From: 	Drew Davidson [mailto:drew@eblox.com] 
Sent:	Monday, March 25, 2002 10:23 AM
To:	Ant Users List
Subject:	Re: Tool to find unused methods

Dominique Devienne wrote:

> I remember there's a Java tools with an ANT wrapper that can generate a
JAR
> file with only the pieces needed by an application. You give it a few
> starting classes, and it finds and adds to the JAR all the dependent
> classes. I believe it's on sourceforge, but I can't remember its name.
It's
> the closest I can think of your problem. The granularity is at the class
> level, since concerns itself with generating JARs, but maybe it can be
used
> at the method level???
>
> Also, you might use Jakarta's BCEL to parse class files, including the
code
> of methods.
>
> Something you might try is to use javap.exe to convert the class file in
> ASCII, and grep/seach it!?!?!?
>
> I hope this helps. --DD

I generally wouldn't want to use such tools in any code for which you don't
have intimate knowledge because java allows lots of dynamic behaviour wrt
class
loading.  I can do:

Class.forName("com.foo.Foo")

without having to import com.foo.Foo, so a dependency analysis based on
imports
will fail to add com.foo.Foo.class to the jar.

- Drew



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message