Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2002 10:01:54 +0100
From:      "Remco van 't Veer" <rwvtveer@xs4all.nl>
To:        Christopher Rued <c.rued@xsb.com>
Cc:        Christopher Elkins <chrise@scardini.com>, Jeff Dalton <jeff@aiai.ed.ac.uk>, Brad Cox <bcox@virtualschool.edu>, freebsd-java@FreeBSD.ORG
Subject:   class dependencies (Re: What is ant good for?)
Message-ID:  <20020227090154.GB76841@azrael.xs4all.nl>
In-Reply-To: <15483.59052.247650.5380@ool-18bacefa.dyn.optonline.net>
References:  <23144.200202261659@todday> <20020226091136.F220@uqbar.lan.scardini.com> <20020226092104.G220@uqbar.lan.scardini.com> <15483.59052.247650.5380@ool-18bacefa.dyn.optonline.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 26, 2002 at 14:49, Christopher Rued wrote:

>  > On Tue, Feb 26, 2002 at 09:11:36AM -0800, Christopher Elkins wrote:
>  > > 
>  > > Yes. <http://jakarta.apache.org/ant/manual/CoreTasks/javac.html>;
>  > 
>  > Sorry, not enough coffee yet. That should've been:
>  > 
>  > No. <http://jakarta.apache.org/ant/manual/CoreTasks/javac.html>;
> 
> That can get you *almost* there.  There are two ways that I know of to
> use the javac target:
> 
>   1) Name exactly the source file(s) you want to compile, and point it
>      to the directory under which it can find all other .java files
>      that may also need to be compiled; or 
>   2) Tell it to compile somedir/**.java which will cause it to compile
>      all java source files under the directory somedir, whether or not
>      they are really needed by the particular application you are
>      compiling.  Lots of extra cruft.
> 
> The problem with the first is that it does not check to see if a class
> file is older than the source.  The problem with the second is that it
> compiles all .java files regardless of whether or not it is needed for
> the application.  The way around it would be to name all of the .java
> files that *are* necessary, but this is kind of a hassle.
> 
> If anyone has a better way of going about doing this, I'd be glad to
> hear it :).

A better way of doing this seems obvious; keeping application
source in different directories.  ;)

Please note: it is very hard to determine which classes a given
class depends on.  Sure, if it's compiled you can use
Class.getDeclaredClasses(), Class.getInterfaces() and
Class.getSuperClass() to recursively collect all depended classes
but you will miss all classes instanciated using
Class.forName(String).  Ofcourse this does not help you with you
initial goal: only compiling needed classes.

I don't know of any source level dependency checkers and I don't
expect there are any.  Writing something like that is more
trouble than gain.  Consider finding out all possible values of
String in a simple statement like:

    public void addClassByName (String name)
    {
	classes.add(Class.forName(name));
    }

Values passed to this method can come from anywhere and these
location might even get their values from a properties file, a
database or worse; user input.

So actually "keeping application source in different directories"
really is the right way to go.

HTH,
Remco


-- 
We resolve to continue to assertively unleash our relationships as
the first step in our scheme to make our founder enough moola to
exceed the net worth of the world's richest man.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020227090154.GB76841>