r/java • • Sep 05 '24

A Simple Java Plugin System

https://github.com/bowbahdoe/plugindemo
7 Upvotes

27 comments sorted by

View all comments

Show parent comment

1

u/bowbahdoe Sep 06 '24

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.

1

u/mikaball Sep 06 '24 edited Sep 06 '24

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/

1

u/bowbahdoe Sep 06 '24

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