【问题标题】:Eclipse 3.8 to 4.6 Migration Platform.getPlugin() returns nullEclipse 3.8 到 4.6 迁移 Platform.getPlugin() 返回 null
【发布时间】:2017-01-19 16:56:48
【问题描述】:

我必须从 Eclipse 3.8 迁移到 4.6。 我的问题是,在 4.6(或更早版本)中,Platform.getPlugin() 已被弃用,并且将始终返回 null。 使用捆绑包代替插件对我没有帮助,因为在这种情况下,我们将不得不破坏我们的公共 API。 你知道是否有办法从捆绑包中获取插件?

/**
 * As the org.eclipse.core.runtime.compatibility plug-in has been removed in
 * Eclipse 4.6 this method is not supported anymore.
 *
 */
@Deprecated
public static Plugin getPlugin(String id) {
    return null;
}

【问题讨论】:

  • 好吧Plugin 扩展BundleActivator。捆绑包的 BundleContext 确实包含对 BundleActivator 的引用,但似乎没有任何接口可以访问它。

标签: java eclipse eclipse-neon


【解决方案1】:

我要问的问题是你用它做什么,然后指出虽然Platform#getPlugin(String) 已被弃用,Plugin 本身不是。如果您的 Bundle-Activator 类扩展了Plugin,只需让它在其构造函数中保存对自身的引用,也就是http://git.eclipse.org/c/sourceediting/webtools.sourceediting.git/tree/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/JSPCorePlugin.java#n54。然后,只需在需要时访问它即可。

【讨论】:

    猜你喜欢
    • 2013-01-15
    • 2019-06-29
    • 2018-10-20
    • 1970-01-01
    • 1970-01-01
    • 2014-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多