3 ms·
Java has a very similar solution to the problem using OSGi. It uses class loaders to encapsulate sets of classes to isolate them and also uses the class loader
by moring 7y ago
Java has a very similar solution to the problem using OSGi. It uses class loaders to encapsulate sets of classes to isolate them and also uses the class loader for disambiguation.
Compare the solutions: "It seems there's four basic components incorporated in a mangled symbol name:"
* "The fully qualified name of the symbol." -- same in Java
* "Generic type parameters." -- missing in Java because of type erasure
* "The name of the crate containing the symbol." -- represented by the class loader in Java
* "An arbitrary “disambiguator” string" -- not present in Java, and I'm not sure why this is needed at all
It even comes with almost the same downsides: "This solution isn't perfect though:"
* "...we can't pass objects around between different versions of a library" -- similar with OSGi (you can pass objects using the opaque "Object" type), but you might be able to have libraries agree on a common interface, defined by an "API library", which has the same version for both and allows to pass objects.
* "Any static variables or global state will be duplicated" -- same with OSGi
* "Our binary size increases necessarily" -- same with OSGi
(edit: formatting)
- wst_ 7y agoEven without OSGi there are plugins allowing so called package names shadowing and, as a consequence, for multiple versions of the same dependency coexist in the same classpath. Rust, though, have this as a part of the language. This is a whole new level of user (or developer in that case) experience.