Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334948

Summary: Workspace compile errors in HEAD
Product: [WebTools] WTP Common Tools Reporter: Rob Stryker <stryker>
Component: Faceted Project FrameworkAssignee: Konstantin Komissarchik <konstantin>
Status: RESOLVED FIXED QA Contact: Konstantin Komissarchik <konstantin>
Severity: normal    
Priority: P3 CC: ccc, konstantin
Version: unspecified   
Target Milestone: 3.3 M5   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 335073, 335074, 335075    

Description Rob Stryker CLA 2011-01-20 16:14:12 EST
The following is what I get in an updated cvs tree when imported into a wtp 3.3 m4 environment.  Most of these are in the common module but some are in jeetools. 

Carl has replicated that these *are* coding errors, places that could use the small suggested cleanup below, though we haven't figured out why they show up as errors in my workspace and not his. 

Compiler settings for these projects tend to be overrided on a by-project level, and they do mark these as errors, but for some reason Carl does not get compile errors and I do. 

Either way, the following lines of code could use some cleanup ;) 


Description	Resource	Path	Location	Type
The project was not built since its build path is incomplete. Cannot find the class file for org.eclipse.core.resources.IProject. Fix the build path then try building this project	org.eclipse.jst.server.pde		Unknown	Java Problem
Unnecessary cast from String to String	BundleReference.java	/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/libprov/osgi	line 92	Java Problem
The value of the local variable executionMap is not used	EJBHelper.java	/org.eclipse.jst.j2ee.ejb/ejbvalidator/org/eclipse/jst/j2ee/internal/ejb/workbench/validation	line 332	Java Problem
The field WebServicesNavigatorContentProvider.viewer is hiding a field from type AdapterFactoryContentProvider	WebServicesNavigatorContentProvider.java	/org.eclipse.jst.j2ee.webservice.ui/webservices_ui/org/eclipse/jst/j2ee/internal/webservice	line 59	Java Problem
The field WebAppProvider.children is hiding a field from type AbstractGroupProvider	WebAppProvider.java	/org.eclipse.jst.jee.ui/src/org/eclipse/jst/jee/ui/internal/navigator/web	line 51	Java Problem
The field WebAppProvider.text is hiding a field from type AbstractGroupProvider	WebAppProvider.java	/org.eclipse.jst.jee.ui/src/org/eclipse/jst/jee/ui/internal/navigator/web	line 53	Java Problem
The field JEEDeployableFactory.moduleDelegates is hiding a field from type J2EEDeployableFactory	JEEDeployableFactory.java	/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/internal/deployables	line 30	Java Problem
The type org.eclipse.core.resources.IProject cannot be resolved. It is indirectly referenced from required .class files	GenericServerTemplate.java	/org.eclipse.jst.server.pde/src/org/eclipse/jst/server/generic/pde/internal	line 1	Java Problem
The field AddListenerWizardPage.synchHelper is hiding a field from type DataModelWizardPage	AddListenerWizardPage.java	/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard	line 49	Java Problem
Unsatisfied version constraint: 'org.eclipse.core.runtime: [3.2.0,3.3.0)'	MANIFEST.MF	/org.eclipse.wst.common.explorer/META-INF	line 9	Plug-in Problem
Unsatisfied version constraint: 'org.eclipse.ui: [3.2.0,3.3.0)'	MANIFEST.MF	/org.eclipse.wst.common.explorer/META-INF	line 8	Plug-in Problem
Unsatisfied version constraint: 'org.eclipse.ui.navigator: [3.2.0,3.3.0)'	MANIFEST.MF	/org.eclipse.wst.common.explorer/META-INF	line 10	Plug-in Problem
Unsatisfied version constraint: 'org.eclipse.ui.navigator.resources: [3.2.0,3.3.0)'	MANIFEST.MF	/org.eclipse.wst.common.explorer/META-INF	line 11	Plug-in Problem
AbstractUIPlugin cannot be resolved	Activator.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 54	Java Problem
AbstractUIPlugin cannot be resolved to a type	Activator.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 10	Java Problem
BundleContext cannot be resolved to a type	Activator.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 25	Java Problem
BundleContext cannot be resolved to a type	Activator.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 32	Java Problem
CommonNavigator cannot be resolved to a type	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 18	Java Problem
CommonViewer cannot be resolved to a type	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 38	Java Problem
CommonViewer cannot be resolved to a type	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 39	Java Problem
CommonViewer cannot be resolved to a type	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 39	Java Problem
Composite cannot be resolved to a type	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 38	Java Problem
ImageDescriptor cannot be resolved to a type	Activator.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 53	Java Problem
SWT cannot be resolved to a variable	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 39	Java Problem
SWT cannot be resolved to a variable	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 39	Java Problem
SWT cannot be resolved to a variable	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 39	Java Problem
The import org.eclipse.jface cannot be resolved	Activator.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 4	Java Problem
The import org.eclipse.swt cannot be resolved	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 13	Java Problem
The import org.eclipse.swt cannot be resolved	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 14	Java Problem
The import org.eclipse.ui cannot be resolved	Activator.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 3	Java Problem
The import org.eclipse.ui cannot be resolved	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 15	Java Problem
The import org.eclipse.ui cannot be resolved	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 16	Java Problem
The import org.osgi cannot be resolved	Activator.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 5	Java Problem
The method getViewSite() is undefined for the type CommonProjectExplorer	CommonProjectExplorer.java	/org.eclipse.wst.common.explorer/src/org/eclipse/wst/common/explorer	line 39	Java Problem
The field ErrorDialog.message is hiding a field from type IconAndMessageDialog	ErrorDialog.java	/org.eclipse.wst.common.frameworks.ui/wtp_ui/org/eclipse/wst/common/frameworks/internal/ui	line 46	Java Problem
Potential null pointer access: The variable group1 may be null at this location	AscendingGroupComparator.java	/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement	line 41	Java Problem
Potential null pointer access: The variable group1 may be null at this location	DescendingGroupComparator.java	/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement	line 42	Java Problem
Potential null pointer access: The variable group2 may be null at this location	AscendingGroupComparator.java	/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement	line 41	Java Problem
Potential null pointer access: The variable group2 may be null at this location	DescendingGroupComparator.java	/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/enablement	line 42	Java Problem
Comment 1 Konstantin Komissarchik CLA 2011-01-20 16:20:11 EST
> though we haven't figured out why they show up as errors in my workspace 
> and not his. 

Did you change java validation preferences in your workspace? A lot of these are warning/ignore by default. Many are code style issues that are subjective, like this one:

  line 332    Java Problem
The field WebServicesNavigatorContentProvider.viewer is hiding a field from
type AdapterFactoryContentProvider    WebServicesNavigatorContentProvider.java 
 
/org.eclipse.jst.j2ee.webservice.ui/webservices_ui/org/eclipse/jst/j2ee/internal/webservice
Comment 2 Rob Stryker CLA 2011-01-20 16:38:04 EST
I replaced my cvs tree with what was in HEAD and imported it into a brand new eclipse build (wtp3.3m4) with a brand new workspace ;) 

For the example you cited, you can see in hte org.eclipse.jst.j2ee.webservice.ui/.settings/org.eclipse.jdt.core.prefs file that these *are* marked as errors. Right-clicking on the project clearly says it should use project-specific preferences and those preferences indicate errors. 

So... either the validation preferences inside these projects need to downgrade some of their validation prefs to warnings, or we need to fix the coding "errors" =]
Comment 3 Carl Anderson CLA 2011-01-21 20:35:41 EST
Konstantin,  please use this bug to handle the 

Unnecessary cast from String to String    BundleReference.java   
/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/libprov/osgi
   line 92    Java Problem

(I've seen that error since I first set up a WTP 3.3 dev env.)
I will clone this bug to handle the other problems.

Also to note:  NONE OF THE org.eclipse.wst.common.explorer ERRORS WILL BE FIXED.
That plugin was never shipped as part of WTP, and should not be part of any dev env.
Comment 4 Konstantin Komissarchik CLA 2011-01-23 19:46:04 EST
> Unnecessary cast from String to String    BundleReference.java   
> /org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project
> /facet/core/libprov/osgi
>   line 92    Java Problem

I don't know why or how you go this, but this an invalid problem. The line in question is this:

final String versionString = (String) bundle.getHeaders().get( "Bundle-Version" ); //$NON-NLS-1$

Where "bundle" is OSGi Bundle class. The getHeaders() method of that class returns unparameterized Dictionary class. It is declared as follows:

public Dictionary/* <String,String> */getHeaders();

The cast is necessary.

The evaluation was done using Indigo M4 in dev eclipse and target platform.
Comment 5 Carl Anderson CLA 2011-01-24 09:35:46 EST
(In reply to comment #4)
> > Unnecessary cast from String to String    BundleReference.java   
> > /org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project
> > /facet/core/libprov/osgi
> >   line 92    Java Problem
> 
> I don't know why or how you go this, but this an invalid problem. The line in
> question is this:
> 
> final String versionString = (String) bundle.getHeaders().get( "Bundle-Version"
> ); //$NON-NLS-1$
> 
> Where "bundle" is OSGi Bundle class. The getHeaders() method of that class
> returns unparameterized Dictionary class. It is declared as follows:
> 
> public Dictionary/* <String,String> */getHeaders();
> 
> The cast is necessary.
> 
> The evaluation was done using Indigo M4 in dev eclipse and target platform.

Konstantin, 

In my Helios environment, I see the
public Dictionary/* <String,String> */getHeaders();

In my Indigo environment, I do not see the comments in the 
public Dictionary <String,String> getHeaders();
I have both Indigo M4 for my dev and target platform.  The class Bundle comes from org.eclipse.osgi_3.7.0.v20101207.jar.

Please see bug 322007 for details on this change (which was committed to Bundle on August 6, 2010).

The cast is unnecessary, and shows up as an error in development environments.  (But not during our WTP builds, for some reason.)
Comment 6 Konstantin Komissarchik CLA 2011-01-24 11:56:42 EST
Ok, I had a problem with my target platform, which prevented this problem from showing for me...

> The cast is unnecessary, and shows up as an error in development environments. 
> (But not during our WTP builds, for some reason.)

Well it is and it isn't necessary. If I remove the cast, the code instantly becomes incompatible with Helios. The code is currently compatible with both Helios and Indigo. Now, I know that we don't test for or advertise compatibility of 3.3 with Helios, but I don't remember seeing any statements about this explicitly not being a requirement. I do remember debates about this during past releases.

Instead of removing the cast, I changed the project's compiler properties to flag unnecessary casts as warnings instead of errors.