feat: Ability to handle load failures with multiple bundles
Feature description
Refer to title and motivation.
Motivation
The loadPatchesFromDex/Jar function loads all bundles in the provided set. Any exception during the loading process will result in successfully loaded/loadable patches to be lost. A way to solve this while still allowing cross bundle patch dependencies is shown here.
Acknowledgements
- [x] I have checked all open and closed feature requests and this is not a duplicate.
- [x] I have chosen an appropriate title.
- [x] All requested information has been provided properly.
Do we load each patch class in its own classloader? This would be even more fine grained and would allow bi directional cross dependencies
One major issue with that approach is when multiple patches use a shared utils class or something. That class would either have to be loaded individually for each patch class or need its own classloader. Both options don't seem great in terms of memory usage.
Class loading is delegated to the parent, so they should both resolve to a common classloader
Now that I think about it, wouldn't it be enough to simply catch exceptions here instead of propagating them? The caller could handle them through a lambda or something.
This would be much simpler than managing multiple classloaders.
I think that could work. runCatching { loadClass() } an use mapNotNull
Can you PR this? Should be simple
Maybe it should append errors to a list passed to the loader function?
I am going to be busy for a few weeks now. Don't know when I have time to do it.