编辑3: 显然,方法签名不能直接影响此加载顺序。我的错误与这个静态方法强烈耦合到bundle激活器这一事实有关...在最开始的加载阶段放置org.eclipse.core.resources。据我所知,更改方法参数类型强制在Activator的调用方法中强制转换,这引入了之前的加载。为了避免这个问题,我进行了一些重构:bundle activator不再引用任何core.resources类了。
我在Eclipse RCP应用程序中有这个静态getter方法:
public static boolean isTrialDone(IFolder trialFolder) {
...
}
应用程序运行正常。
如果我只将方法参数类型更改为IResource
:
public static boolean isTrialDone(IResource trialFolder) {
...
}
我得到了这个例外:
....
Caused by: java.lang.IllegalStateException: The instance data location has not been specified yet.
....
这意味着在设置工作空间位置之前,资源插件的启动时间已经过早了。
但参数类型如何影响插件加载顺序? 方法签名是否影响Eclipse资源插件加载顺序?
编辑:完整的堆栈跟踪(编辑2:删除 - >太长)
编辑2:我已激活DEBUG_LOADER的调试跟踪
当参数为IFolder类型(应用程序正常运行)时,以下是过滤的(仅与我的包相关)和截断的跟踪:
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(the.bundle.package.BundleApplication)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(the.bundle.package.BundleApplication)
BundleLoader[Bundle_1.0.0.qualifier].findLocalClass(the.bundle.package.BundleApplication)
ModuleClassLoader[Bundle_1.0.0.qualifier - /Path/To/Project/Workspace].findClassImpl(the.bundle.package.BundleApplication)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.equinox.app.IApplication)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.equinox.app.IApplication)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.equinox.app -> [org.eclipse.equinox.app_1.3.400.v20150715-1528]
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.lang.Object)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(the.bundle.package.Activator)
BundleLoader[Bundle_1.0.0.qualifier].findLocalClass(the.bundle.package.Activator)
ModuleClassLoader[Bundle_1.0.0.qualifier - /Path/To/Project/Workspace].findClassImpl(the.bundle.package.Activator)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.ui.plugin.AbstractUIPlugin)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.ui.plugin.AbstractUIPlugin)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.ui.plugin -> [org.eclipse.ui.workbench_3.110.0.v20170612-1255]
BundleLoader[Bundle_1.0.0.qualifier] found local class the.bundle.package.Activator
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.core.runtime.IStatus)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.core.runtime.IStatus)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.core.runtime -> [org.eclipse.equinox.common_3.9.0.v20170207-1454,org.eclipse.equinox.registry_3.7.0.v20170222-1344,org.eclipse.core.runtime_3.13.0.v20170207-1030]
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.lang.Runnable)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.lang.Throwable)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.core.runtime.CoreException)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.core.runtime.CoreException)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.core.runtime -> [org.eclipse.equinox.common_3.9.0.v20170207-1454,org.eclipse.equinox.registry_3.7.0.v20170222-1344,org.eclipse.core.runtime_3.13.0.v20170207-1030]
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.util.Collection)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.lang.Exception)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.util.Comparator)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.ui.PartInitException)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.ui.PartInitException)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.ui -> [org.eclipse.ui.workbench_3.110.0.v20170612-1255]
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.lang.String)
BundleLoader[Bundle_1.0.0.qualifier] found local class the.bundle.package.BundleApplication
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.ui.application.WorkbenchAdvisor)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.ui.application.WorkbenchAdvisor)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.ui.application -> [org.eclipse.ui.workbench_3.110.0.v20170612-1255]
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(the.bundle.package.ApplicationWorkbenchAdvisor)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(the.bundle.package.ApplicationWorkbenchAdvisor)
....
当参数是IResource类型时,这是整个过滤的跟踪(应用程序停止,因为IResource需要加载得太早):
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(the.bundle.package.BundleApplication)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(the.bundle.package.BundleApplication)
BundleLoader[Bundle_1.0.0.qualifier].findLocalClass(the.bundle.package.BundleApplication)
ModuleClassLoader[Bundle_1.0.0.qualifier - /Path/To/Project/Workspace].findClassImpl(the.bundle.package.BundleApplication)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.equinox.app.IApplication)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.equinox.app.IApplication)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.equinox.app -> [org.eclipse.equinox.app_1.3.400.v20150715-1528]
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.lang.Object)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(the.bundle.package.Activator)
BundleLoader[Bundle_1.0.0.qualifier].findLocalClass(the.bundle.package.Activator)
ModuleClassLoader[Bundle_1.0.0.qualifier - /Path/To/Project/Workspace].findClassImpl(the.bundle.package.Activator)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.ui.plugin.AbstractUIPlugin)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.ui.plugin.AbstractUIPlugin)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.ui.plugin -> [org.eclipse.ui.workbench_3.110.0.v20170612-1255]
BundleLoader[Bundle_1.0.0.qualifier] found local class the.bundle.package.Activator
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.core.runtime.IStatus)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.core.runtime.IStatus)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.core.runtime -> [org.eclipse.equinox.common_3.9.0.v20170207-1454,org.eclipse.equinox.registry_3.7.0.v20170222-1344,org.eclipse.core.runtime_3.13.0.v20170207-1030]
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.lang.Runnable)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.lang.Throwable)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.core.runtime.CoreException)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.core.runtime.CoreException)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.core.runtime -> [org.eclipse.equinox.common_3.9.0.v20170207-1454,org.eclipse.equinox.registry_3.7.0.v20170222-1344,org.eclipse.core.runtime_3.13.0.v20170207-1030]
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.util.Collection)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.lang.Exception)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(java.util.Comparator)
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.core.resources.IResource)
BundleLoader[Bundle_1.0.0.qualifier].findClassInternal(org.eclipse.core.resources.IResource)
BundleLoader[Bundle_1.0.0.qualifier] loading from required bundle package: org.eclipse.core.resources -> [org.eclipse.core.resources_3.12.0.v20170417-1558]
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(org.eclipse.core.resources.IResource) failed.
ModuleClassLoader[Bundle_1.0.0.qualifier].loadClass(the.bundle.package.BundleApplication) failed.
跟踪开始与org.eclipse.core.runtime完全相同,需要加载触发org.eclipse.core.resources加载的IResource类。
但是为什么org.eclipse.core.runtime需要在这种情况下加载IResource而不是前一个的IFolder?这是一个非常棘手的行为,我真的很感激任何帮助,以了解我的错误在哪里!