Aw: Re: How to exclude modules?
Jörg Sautter
joerg.sautter at gmx.net
Mon Aug 12 15:08:03 UTC 2024
Hi Alan,
M1 does reference M2 and uses it in some rare cases, but usually the M1 works without M2.
Als long as the missing classes are not directly invoked everything is fine.
I have put some dummy code here to show the way how i am using an empty module as replacement to the "io.opentelemetry.context" module:
https://github.com/joerg1985/jigsaw/tree/main
In this case the Main.main(String[] args) code runs fine, until i provoke the access to a missing class.
This will end in the expected java.lang.NoClassDefFoundError after the code above has been executed.
I guess the classes are lazy loaded, otherwise it should fail earlier.
Kind regards
Jörg
Gesendet: Montag, 12. August 2024 um 09:54 Uhr
Von: "Alan Bateman" <alan.bateman at oracle.com>
An: "Jörg Sautter" <joerg.sautter at gmx.net>, jigsaw-dev at openjdk.org
Betreff: Re: How to exclude modules?
On 05/08/2024 12:38, Jörg Sautter wrote:
Hi all,
i am using the module system for a while now and have some problems with removing dependencies from the classpath.
In the past i could just exclude them from the maven project and everything was working fine.
Now with modules enabled i get an error some modules are missing and i have to workaround with empty modules.
You may ask why i want to remove some modules, there are several reasons:
- i have to do complex FOSS licences checks / health checks for each dependency i use, so i try to minimize them
- deploy smaller container images and lower the surface for supply chain attacks
- minimize the efforts to update depencencies i do not use (and cooperate toolchain will complain i should upgrade)
I know it is kind of risky to exclude them, but especially when using open source depencencies there are alot
projects which do not have adopted the module system at all and do miss a structure which does allow the
automatic modules to work well.
Is there a better way to exclude these modules from the module system than creating empty dummies?
Modules are about reliable configuration so excluding modules that are required by other modules doesn't make sense.
I'm curious about your workaround to use "empty modules" as I would expect NoClassDefFoundError. Are you saying that M1 requires M2 but has not reference to any classes in M2?
-Alan
More information about the jigsaw-dev
mailing list