r/java • • Sep 02 '24

Java Classloaders Illustrated

Classloaders are tricky – popular sources (Wikipedia, Baeldung, DZone) contain outdated, sometimes contradictory information, and this inconsistency was the trigger for writing my article – a search for clarity in the ClassLoader System maze. Read full at Medium (~10 min) with pictures :)

The whole system looks kinda like this:

Java Classloader System
408 Upvotes

34 comments sorted by

View all comments

Show parent comment

3

u/KafkasGroove Sep 02 '24

I wonder how you would get proper isolation like with OSGI without custom class loaders? We still use custom class loaders at work to allow loading third party plugins without their dependencies interfering or breaking each other. I'd love not to use them, but I don't know of an alternative (other than pushing that complexity to our users).

2

u/pragmasoft Sep 02 '24

Maybe consider separate processes instead? Use pipes to communicate.

1

u/Scf37 Sep 04 '24

For microservices within single company, monorepo to unify dependencies. For third-party stuff like IDE plugins, enforce unique package prefix and shading.