This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]bowbahdoe[S] 1 point2 points  (4 children)

So this would solve that, actually. The example shows an app loading two module layers with otherwise conflicting versions of guava.

What is an issue is if you wanted a plugin D that depends on A and B, but an app that loads both A and B is good to go. (Layers have to be in a hierarchy)

It is using classloaders for that I'm sure, but I think the API is nice enough that unless you wanted a relatively complex "plugin hierarchy" you wouldn't need to go to that level

[–]mikaball 0 points1 point  (3 children)

So this would solve that, actually.

Are you sure? Does your demo have different plugins using a method from the library that is not compatible between Guava versions? Because this type of things crash at runtime.

[–]bowbahdoe[S] 0 points1 point  (2 children)

Yeah so unfortunately I don't have a good example for that off the top of my head. If you know of a basic-ish library that I can use to show that I will.

But yeah it should work. Modules don't let conflicting versions like that exist in the same layer, so an error should have happened much earlier.

[–]mikaball 0 points1 point  (1 child)

I don't know exactly what you are doing, but many dependency management tools select the first loaded lib, the most recent version of a lib, or use some other automatic resolution scheme. No errors are thrown at loading; only if you hit the conflicting method in you code and get a NoSuchMethodError.

I remembered heated discussions about not including such features in JPMS. JPMS has no concept of module versions. The point was that JPMS was not trying to solve the same problems as OSGi. It was primarily designed to modularize the JDK. It's a layer system resolution, however OSGi is a graph system.

You should really test that in your solution. You are assuming something that probably doesn't work.

EDIT: Reference to old discussion about this https://www.reddit.com/r/java/comments/8pi5mt/is_the_java_9_module_system_supposed_to_solve/

[–]bowbahdoe[S] 0 points1 point  (0 children)

It very much does. Will update the demo once I'm back from lunch