Summary: | JDT compiler more restrictive than javac | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Dejan Glozic <dejan> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | major | ||
Priority: | P2 | CC: | jeffmcaffer, pascal |
Version: | 3.0 | ||
Target Milestone: | 3.0 M5 | ||
Hardware: | PC | ||
OS: | All | ||
Whiteboard: |
Description
Dejan Glozic
2003-10-23 13:56:49 EDT
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. |