4 ms·
Two responses to the diamond problem: - I see this often with Guava. A wants 18 and B wants 21, neither works with the other, but they both with with 20. Becau
by voodootrucker 8y ago
Two responses to the diamond problem:
- I see this often with Guava. A wants 18 and B wants 21, neither works with the other, but they both with with 20. Because this tool looks at the actual methods being invoked, even if 100% of the methods are present, it's fine as long as 100% of the ones being invoked are.
- Technically, as long as objects aren't exchanged between modules, it would be possible to use ClassLoader isolation to have two libraries each load their own incompatible dependency at run time. It's on my blue-sky TODO list.
- sleepychu 8y agoIsn't choosing to sub in 20 just helping you build more on an unstable foundation? 1 - how can you be sure the method implementation is the same? That there aren't side effects you don't know about. (I don't think you can!) 2 - when it emerges that B2 really does need 25 what are you going to do? IMO it would be better to resolve this earlier than later.
- Slartie 8y ago> Technically, as long as objects aren't exchanged between modules, it would be possible to use ClassLoader isolation to have two libraries each load their own incompatible dependency at run time. It's on my blue-sky TODO list. Not only technically, this also works practically. We've done this for years in a POS application in order to be able to load different incompatible versions of vendor-provided hardware drivers at the same time, with the decision on which to use (one, the other, or maybe even both at the same time) being done at runtime. It's based on OSGi for modularization, which also provides other benefits besides classloader isolation, like allowing to bundle multiple native libs for different OSes and bit-nesses within a single jar and automatically choosing the right one to dynamically link into your JVM process that is needed for a particular platform that the application finds itself running on.
- voodootrucker 8y agoTaken to a logical extent, I think this tool could be used to generate conflict-aware ClassLoaders at application start time, and automatically give each module the version it wants. I guess it would take generating a new jar with a bootloader main() to wrap the existing main()?