Community
Participate
Working Groups
Here is the scenario that is causing problems to PDE when self-hosting against OSGi runtime: 1) Take M4 build 2) Download OSGi runtime from Equinox home page (build 1010) and unzip on top of the build 3) Start another Eclipse driver (not this one) with a clean workspace. Configure it so that PDE->Target Platform points at the M4 OSGi build created in 2). 4) Import all the external plug-ins and fragments as binary projects into the workspace. 5) Create 'Hello, World' plug-in using PDE 'New Plug-in project' wizard. Keep all the defaults. Notice that the build fails with the following error in XyzPlugin.java: The type org.osgi.framework.Bundle cannot be resolved. It is indirectly referenced from required .class files. XyzPlugin.java XyzPlugin does not reference Bundle type directly anywhere. However, it does extend AbstractUIPlugin, which in turn extends Plugin (provided by org.eclipse.runtime.compatibility) and this class has 'Bundle getBundle()' method, as well as Bundle private field. As suggested, I went into the workspace from the OS shell and tried to compile XYZPlugin using javac.exe. I managed to get it to compile without having to put org.eclipse.osgi.framework.core plug-in on the classpath (this is where Bundle type is declared). It seems to me that JDT compiler is too eager when resolving Plugin class. It should not need to resolve Bundle reference since it was never used explicitly in XyzPlugin class itself.
We used to be resolving too much, and thus finding inconsistencies which we should have been ignoring. We added more laziness, but apparently we are still unoptimal. Must fix.
Reproduced with command-line: @echo off set CP00=d:\jdk1.4.2\jre\lib\rt.jar set CP01=org.eclipse.core.boot\boot.jar set CP02=org.eclipse.core.resources\resources.jar set CP03=org.eclipse.core.runtime\runtime.jar set CP04=org.eclipse.core.runtime.osgi\runtime.jar set CP05=org.eclipse.core.runtime.compatibility\compatibility.jar set CP06=org.eclipse.update.configurator\configurator.jar set CP07=org.eclipse.core.runtime\runtime.jar set CP08=org.apache.xerces\xmlParserAPIs.jar set CP09=org.apache.xerces\xercesImpl.jar set CP10=org.eclipse.ui\ui.jar set CP11=org.eclipse.update.core\updatecore.jar set CP12=org.eclipse.help\help.jar set CP13=org.eclipse.help.url\url.jar set CP14=org.eclipse.help.appserver\appserver.jar set CP15=org.apache.lucene\parser.jar set CP16=org.apache.lucene\lucene-1.3-rc1.jar set CP17=org.eclipse.swt.win32\ws\win32\swt.jar set CP18=org.eclipse.text\text.jar set CP19=org.eclipse.jface\jface.jar set CP20=org.eclipse.jface.text\jfacetext.jar set CP21=org.eclipse.ui.views\views.jar set CP22=org.eclipse.ui.workbench\workbench.jar set CP23=org.eclipse.ui.win32\workbenchwin32.jar set CP24=org.eclipse.ui.workbench.texteditor\texteditor.jar set CP25=org.eclipse.ui.editors\editors.jar set CP26=org.eclipse.core.filebuffers\filebuffers.jar CD \eclipse\testing\equinox\plugins javac -verbose -classpath %CP00%;%CP01%;%CP02%;%CP03%;%CP04%;%CP05%;%CP06%;% CP07%;%CP08%;%CP09%;%CP10%;%CP11%;%CP12%;%CP13%;%CP14%;%CP15%;%CP16%;%CP17%;% CP18%;%CP19%;%CP20%;%CP21%;%CP22%;%CP23%;%CP24%;%CP25%;%CP26% -d d:\eclipse\workspaces\dev3.0\plugins\Crap\bin\ D:\eclipse\testing\equinox\plugins\HelloWorld\src\HelloWorld\HelloWorldPlugin.ja va CD \
Interestingly, jikes 1.18 will also refuse to compile: Found 6 semantic errors compiling "D:/eclipse/testing/equinox/plugins/HelloWorld/src/HelloWorld/Hell oWorldPlugin.java": 11. public class HelloWorldPlugin extends AbstractUIPlugin { ^--------------^ *** Semantic Error: You need to modify your classpath, sourcepath, bootclasspath, and/or extdirs set up. Package "org/osgi/framework" could not be found in: d:\jdk1.4.2\jre\lib\rt.jar org.eclipse.core.boot\boot.jar org.eclipse.core.resources\resources.jar org.eclipse.core.runtime\runtime.jar org.eclipse.core.runtime.osgi\runtime.jar org.eclipse.core.runtime.compatibility\compatibility.jar org.eclipse.update.configurator\configurator.jar org.apache.xerces\xmlParserAPIs.jar org.apache.xerces\xercesImpl.jar org.eclipse.ui\ui.jar org.eclipse.update.core\updatecore.jar org.eclipse.help\help.jar org.eclipse.help.url\url.jar org.eclipse.help.appserver\appserver.jar org.apache.lucene\parser.jar org.apache.lucene\lucene-1.3-rc1.jar org.eclipse.swt.win32\ws\win32\swt.jar org.eclipse.text\text.jar org.eclipse.jface\jface.jar org.eclipse.jface.text\jfacetext.jar org.eclipse.ui.views\views.jar org.eclipse.ui.workbench\workbench.jar org.eclipse.ui.win32\workbenchwin32.jar org.eclipse.ui.workbench.texteditor\texteditor.jar org.eclipse.ui.editors\editors.jar org.eclipse.core.filebuffers\filebuffers.jar . 11. public class HelloWorldPlugin extends AbstractUIPlugin { ^--------------^ *** Semantic Error: Type org.osgi.framework.BundleActivator was not found. 11. public class HelloWorldPlugin extends AbstractUIPlugin { ^--------------^ *** Semantic Error: You need to modify your classpath, sourcepath, bootclasspath, and/or extdirs set up. Package "org/osgi/framework" could not be found in: d:\jdk1.4.2\jre\lib\rt.jar org.eclipse.core.boot\boot.jar org.eclipse.core.resources\resources.jar org.eclipse.core.runtime\runtime.jar org.eclipse.core.runtime.osgi\runtime.jar org.eclipse.core.runtime.compatibility\compatibility.jar org.eclipse.update.configurator\configurator.jar org.apache.xerces\xmlParserAPIs.jar org.apache.xerces\xercesImpl.jar org.eclipse.ui\ui.jar org.eclipse.update.core\updatecore.jar org.eclipse.help\help.jar org.eclipse.help.url\url.jar org.eclipse.help.appserver\appserver.jar org.apache.lucene\parser.jar org.apache.lucene\lucene-1.3-rc1.jar org.eclipse.swt.win32\ws\win32\swt.jar org.eclipse.text\text.jar org.eclipse.jface\jface.jar org.eclipse.jface.text\jfacetext.jar org.eclipse.ui.views\views.jar org.eclipse.ui.workbench\workbench.jar org.eclipse.ui.win32\workbenchwin32.jar org.eclipse.ui.workbench.texteditor\texteditor.jar org.eclipse.ui.editors\editors.jar org.eclipse.core.filebuffers\filebuffers.jar . 11. public class HelloWorldPlugin extends AbstractUIPlugin { ^--------------^ *** Semantic Error: Type org.osgi.framework.Bundle was not found. 11. public class HelloWorldPlugin extends AbstractUIPlugin { ^--------------^ *** Semantic Error: You need to modify your classpath, sourcepath, bootclasspath, and/or extdirs set up. Package "org/osgi/framework" could not be found in: d:\jdk1.4.2\jre\lib\rt.jar org.eclipse.core.boot\boot.jar org.eclipse.core.resources\resources.jar org.eclipse.core.runtime\runtime.jar org.eclipse.core.runtime.osgi\runtime.jar org.eclipse.core.runtime.compatibility\compatibility.jar org.eclipse.update.configurator\configurator.jar org.apache.xerces\xmlParserAPIs.jar org.apache.xerces\xercesImpl.jar org.eclipse.ui\ui.jar org.eclipse.update.core\updatecore.jar org.eclipse.help\help.jar org.eclipse.help.url\url.jar org.eclipse.help.appserver\appserver.jar org.apache.lucene\parser.jar org.apache.lucene\lucene-1.3-rc1.jar org.eclipse.swt.win32\ws\win32\swt.jar org.eclipse.text\text.jar org.eclipse.jface\jface.jar org.eclipse.jface.text\jfacetext.jar org.eclipse.ui.views\views.jar org.eclipse.ui.workbench\workbench.jar org.eclipse.ui.win32\workbenchwin32.jar org.eclipse.ui.workbench.texteditor\texteditor.jar org.eclipse.ui.editors\editors.jar org.eclipse.core.filebuffers\filebuffers.jar . 11. public class HelloWorldPlugin extends AbstractUIPlugin { ^--------------^ *** Semantic Error: Type org.osgi.framework.BundleContext was not found.
We signal: ---------- 1. ERROR in D:\eclipse\testing\equinox\plugins\HelloWorld\src\HelloWorld\HelloWorldPlugin.ja va (at line 0) package HelloWorld; ^ The type org.osgi.framework.Bundle cannot be resolved. It is indirectly referenced from required .class files. ----------
Reproducing with Java app invoking batch compiler: import org.eclipse.jdt.internal.compiler.batch.Main; public class Compile2 { public static void main(String[] args) { String workspace = "D:/eclipse/testing/equinox/plugins/"; StringBuffer commandLine = new StringBuffer(30); commandLine.append(" -1.4 -preserveAllLocals -proceedOnError -time - verbose "); commandLine.append(workspace).append ("HelloWorld/src/HelloWorld/HelloWorldPlugin.java"); commandLine.append(" -cp ").append(" d:/jdk1.4.2/jre/lib/rt.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.core.boot/boot.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.core.resources/resources.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.core.runtime/runtime.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.core.runtime.osgi/runtime.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.core.runtime.compatibility/compatibility.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.update.configurator/configurator.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.core.runtime/runtime.jar"); commandLine.append(";").append(workspace).append ("org.apache.xerces/xmlParserAPIs.jar"); commandLine.append(";").append(workspace).append ("org.apache.xerces/xercesImpl.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.ui/ui.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.update.core/updatecore.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.help/help.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.help.url/url.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.help.appserver/appserver.jar"); commandLine.append(";").append(workspace).append ("org.apache.lucene/parser.jar"); commandLine.append(";").append(workspace).append ("org.apache.lucene/lucene-1.3-rc1.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.swt.win32/ws/win32/swt.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.text/text.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.jface/jface.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.jface.text/jfacetext.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.ui.views/views.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.ui.workbench/workbench.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.ui.win32/workbenchwin32.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.ui.workbench.texteditor/texteditor.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.ui.editors/editors.jar"); commandLine.append(";").append(workspace).append ("org.eclipse.core.filebuffers/filebuffers.jar"); commandLine.append(" -d d:/eclipse/workspaces/dev3.0/plugins/Crap/bin/"); System.out.println(commandLine.toString()); Main.compile(commandLine.toString()); } }
Problem comes from a compiler check for local variable hiding a field: public static String getResourceString(String key) { >>>>>>>> ResourceBundle bundle = HelloWorldPlugin.getDefault ().getResourceBundle(); try { return (bundle!=null ? bundle.getString(key) : key); } catch (MissingResourceException e) { return key; } } If renaming bundle, into bundle2, then the problem goes away.
The hiding diagnosis finds the inherited Plugin slot: private org.osgi.framework.Bundle bundle;
Changing hiding check to avoid resolving overriden match.
Raising severity because this is blocking further progress on PDE support for pure OSGi bundle development against OSGi builds.
For now, as a simple workaround, you may simply rename the Plugin#bundle slot: private org.osgi.framework.Bundle bundle;
I am testing a fix at the moment, will likely post it as a patch once test runs are ok (our compiler tests, jck1.3a, jck1.4a, jacks). If all goes well, patch should be available within today.
Fixed. Introduced flag to avoid resolving fields in case trying to find pre- existing variable (when checking for hiding scenario).
Patch is available at: http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-core- home/r3.0/main.html#updates
Verified that the patch solves the problem. Thanks!
Glad it works. Thanks for the accurate testcase.