Avoiding same-package conflicts

Karl Sanders karlsanders75 at gmail.com
Thu Oct 29 06:57:30 UTC 2015

Hi Alex,

indeed I'm on JDK 8 but at the moment I don't have different versions
of the same library in the classpath.
However sooner or later I will have to satisfy this requirement.
I can wait the year or so that separates us from the GA release of JDK
9 but I'm afraid that Jigsaw won't be able to help me.
Hence my questions.

Also, just for the record, I understand that having multiple versions
of the same library isn't a best practice to say the least.
But I'm afraid that this is one of the cases where the library vendor
can't modify the current code to fit my requirements and extracting
the part that I need from an older version and refactoring it into a
separate library would be quite an undertaking.

Thanks for your time.


On Thu, Oct 29, 2015 at 1:03 AM, Alex Buckley <alex.buckley at oracle.com> wrote:
> Hi Karl,
> Serious question: does your Java SE application expect that different
> versions of the same library are placed on the classpath in JDK 8?
> Alex
> On 10/28/2015 1:34 PM, Karl Sanders wrote:
>> Hi,
>> I'm trying out the JDK 9 EA with Jigsaw.
>> I created two modules, A and B, which are required by module C.
>> Modules A and B contain a non-exported package with the same name.
>> After compiling each module separately I start module C and get a
>> java.lang.reflect.LayerInstantiationException saying that modules A
>> and B contain a package with the same name.
>> In light of this behaviour I have two questions.
>> - Is it correct to say that for a simple Java SE application to work
>> with this configuration the only solution, in the realm of what will
>> be provided with the GA version of JDK 9, is through the concept of
>> layers of modules?
>> - In that case will there be some sort of out-of-the box functionality
>> to have this scenario work or will I have to write some non-trivial
>> code to manage these layers?
>> In other words, I have to use different versions of the same library
>> in a Java SE application.
>> Since Jigsaw is approaching I thought I could wait for it instead of
>> learning and having to deal with OSGi.
>> But from what I see by using only Jigsaw I won't be able to satisfy
>> this requirement.
>> At least not without writing some non-trivial code that I'm afraid is
>> above my skill level.
>> Cheers,
>> Karl

More information about the jigsaw-dev mailing list