我在 OSGi 中安装了 bundle A.jar
,我可以使用 BundleContext 获取该 bundle
bundle bundleA = context.getBundle()
以及特定的类加载器 B
如何将 bundleA
中的所有类添加到我的类加载器 B
最佳答案
您不能在运行时执行此操作。您可以将 Require-Bundle header 添加到 bundle B。然后 bundle B 的类加载器将知道 bundle A 的所有类。但这并不是真正推荐的。
所以我更想问你想通过这个实现什么目的?也许您的问题还有另一种解决方案。
关于java - OSGi - 将 bundle 的类添加到特定的类加载器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25178843/