Do empty directories in a .jar cause conflicts in the classloader?

M

Miguel Farah

I'm writing a utility to detect conflicts between jars in the classpath,
and I'm a bit confused with respect to empty directories - it is a bit
of a dumb question, but I want to make sure I'm getting this right.

Let's say I have two JARs in the classpath:

jarone.jar: contains
com/
com/example/
com/example/onehand/
com/example/otherhand/
com/example/onehand/hello.class
com/example/onehand/world.class
com/example/otherhand/bye.class

jartwo.jar: contains
com/
com/example/
com/example/otherhand/
com/example/grippinghand/
com/example/otherhand/coffee.class
com/example/grippinghand/percolator.class

As we all know, the presence of com/example/otherhand.class and
com/example/otherhand/coffee.class provokes a conflict. Let's say I
manipulate the .jar file using zip/unzip, to get rid of the
coffee.class, so it now is:

jartwo.jar:
com/
com/example/
com/example/otherhand/
com/example/grippinghand/
com/example/grippinghand/percolator.class

I removed the class file but forgot to erase the directory. Is there now
a conflict? I say no, an empty directory does not create a conflict, but
I'm not certain. Does it?

Thanks.
 
J

John McGrath

I removed the class file but forgot to erase the directory. Is there now
a conflict? I say no, an empty directory does not create a conflict, but
I'm not certain. Does it?

I agree that it should not. That does not mean that an implementation
will not have a problem with the emty directory, but if they do, I would
argue that the implementation is wrong.

The "language lawyer" argument on this is: While the Java Language
Specification is not very clear about what makes a package *exist*, it is
clear that a package is only *observable* if its members are observable.
So if one argues that this package exists, it has no members, so it is not
observable, and so its name is not in scope.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,251
Latest member
41Ki

Latest Threads

Top