[ https://issues.apache.org/jira/browse/FELIX-5913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16629959#comment-16629959 ]
Karl Pauls commented on FELIX-5913: ----------------------------------- Hi Tom, let me try to explain in a little more detail. First of all, your patch (lets call it the delegation approach) is entirely correct in the sense that it is doing the best one can do given the constraint to not introduce a dependency on android (I'd have some nitpicks as I don't think it needs to copy the native libraries but that isn't important). As I was trying to say above, my POC isn't a reaction to me thinking your patch isn't correct but rather the realisation that we might not get away with the "delegation" approach as it isn't giving us exactly what we need. Hence, second, I created my branch which (as you determined correctly), follows a different approach (lets call it the inherit approach) where we subclass PathClassLoader. As you say, unfortunately, there is no way to do that (short of using bytecode engineering) without depending on some dalvik classes. My idea, however, was that I can just create a stub of the one class we need to be able to compile (dalvik.system.PathClassLoader) and just don't package that into the resulting jar. If you look at [0] you can see the stub that is used at compile time (it will not be packaged into the resulting jar). Subsequently, I created a new classloader in [1] that is used if we are on android. I tried to make that switch more clear in [2]. The trick is that we only try to load that class if we are on dalvik (and hence, the PathClassLoader class should be available). If we are not on dalvik, we load the BundleClassLoaderImpl (and hence, don't need the PathClassLoader class which isn't available anyhow). The reason for the inherit approach is mostly that there is a requirement that the classloader of a class loaded from a bundle must implement the BundleReference interface. The delegation approach doesn't allow that because we are not in control of the PathClassLoader which will be the classloader of classes from bundles. Furthermore, we make the assumption that the classloader of a class loaded from a bundle is the BundleClassLoader in a couple of places inside the framework as well (e.g., [3], [4], [5]). Ultimately, the delegation approach suffers too from the fact that there are some classloading cases where we don't want to load a class from a bundle but it is in the bundle - which we can't prevent in the delegation case because even if the parent classloader throws a CNF the child will still look into its own classes i think. I hope this makes things a bit more clear and it would be great if you could try if this works on android (or if not, see if we could make it work). Finally, the inherit approach is just an idea for how we maybe have our cake and eat it too (i.e., don't have a dependency on android while still follow OSGi rules as best as we can). If that isn't working we can still consider going with the delegation approach. I'm very interested in your opinion on what is better in the end but I'd really like us to try both approaches first. [0] [https://github.com/karlpauls/felix/blob/27fa7422f7897a5cf52f79fa1db5a34e780ada0c/framework/src/main/java/dalvik/system/PathClassLoader.java] [1] [https://github.com/karlpauls/felix/blob/27fa7422f7897a5cf52f79fa1db5a34e780ada0c/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java#L1943] [2] [https://github.com/karlpauls/felix/blob/27fa7422f7897a5cf52f79fa1db5a34e780ada0c/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java#L737] [3] [https://github.com/karlpauls/felix/blob/27fa7422f7897a5cf52f79fa1db5a34e780ada0c/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java#L1526] [4] [https://github.com/karlpauls/felix/blob/27fa7422f7897a5cf52f79fa1db5a34e780ada0c/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java#L1852] [5] [https://github.com/karlpauls/felix/blob/27fa7422f7897a5cf52f79fa1db5a34e780ada0c/framework/src/main/java/org/apache/felix/framework/URLHandlers.java#L695] > Support Android > --------------- > > Key: FELIX-5913 > URL: https://issues.apache.org/jira/browse/FELIX-5913 > Project: Felix > Issue Type: Wish > Components: Framework > Affects Versions: framework-6.0.0, framework-6.0.1 > Reporter: Tom Rutchik > Priority: Major > Attachments: BundleWiringImpl.java, > FelixAndroidSupportImplementationNotes.pdf > > Original Estimate: 3h > Remaining Estimate: 3h > > The lastest 6.0.0 and 6.0.1 release no longer works on Android. > The code form the 5.6.10 version necessary to make it work was not ported > into these versions. > Some code needs to be added to the class BundleWiringImpl class to allow for > android support. All of the code necessary to due that can be found in the > 5.6.10 version. > I've added the code and have tested it and it's working fine again. I've > attached an implementation of BundleWiringImpl that works with android. It's > basically the 6.0.1 implementation with the extra code from 5.6.10. You > should be able to do a file diff on the 6.0.1 to see where I had to add the > missing code. -- This message was sent by Atlassian JIRA (v7.6.3#76005)