[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Java libraries and proposal.

--- Seth Arnold <sarnold@willamette.edu> wrote:
> * Ola Lundqvist <opal@debian.org> [010406 04:09]:
> > Build:
> >   Is it possible to create a script that generates this automaticly?
> >   Like a dh_javadeps... It should also generate the dependencies
> >   in the control file...
> I like this idea. It *ought* to be fairly straightforward (famous last
> words) to implement this because Java programs declare all the classes
> they depend upon in the first few lines of their source programs, except
> for java.lang. (I don't know the Java spec well enough to know if the
> dependency information is used only at compile time or if the
> information is also available in the compiled .class files -- I bet it
> is available in the compiled .class files too.)
> Nice overview, BTW.

No, it's not that simple: you can always use the completely specified name
to refer to a class (e.g. "java.util.Vector", even if you don't import the
package nor the class). The "import" keyword is only there to ease the
developer's work.

It's also possible that 2 different (but very close) APIs have classes in
the same package. Hence including the package does not imply which API is
necessary. I don't have any example in mind, but I think it's the case
with the servlet API and the JSP API. To be confirmed!

Finally, you can also use reflection to access classes dynamically (at run
time, not at compile time). This can be done with e.g.
    Class javaUtilVectorClass = Class.forName("java.util.Vector");
Once you have the class reference, a newInstance() call on it and you have
an instance of the object.

I think the proposal was to define a file format to specify which APIs are
used in the software. It's close to the way Debian package dependencies
are specified by the packager. This same list would then be also used to
create the string used in the "-classpath" option (or the equivalent for
other implementations).


PS: I hope I have been clear enough! I'm really tired today and my english
is not fluent as usually...

Francois BOTTIN
    "How kind," the PFY sighs. "But where will I go?" 
    "Somewhere where they know nothing about computing...
where they wouldn't know a RAM chip from a potato chip!" 
    "But I don't want to visit Microsoft!" he whines.
              The BOFH 1998 - Simon Travaglia (bofh.ntk.net)

Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 

Reply to: