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

Bug 236296

Summary: "update the classpath settings" feature sets wrong project compiler compliance level
Product: [Eclipse Project] JDT Reporter: Rodrigo Pastrana <rpastran>
Component: DebugAssignee: Darin Wright <darin.eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: aniefer, daniel_megert, darin.eclipse, estradas, markus.kell.r, mpcarl, tjwatson
Version: 3.4   
Target Milestone: 3.5 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 238802    
Bug Blocks: 176516    

Description Rodrigo Pastrana CLA 2008-06-09 14:33:24 EDT
Build ID: I20080409-1425

Steps To Reproduce:
1. Add custom execution environment:
1a. Windows->Preferences->Java->Instaled JREs. 
1b. Add->Execution Environment Description-> Next. 
1c. Specify valid ee file. (File includes: -Dee.language.level=1.5 entry) ->Finish.
2. Create new plug-in project. File->New->Plug-in project.
3. Specify name click Next.
4. In the "Plug-in content" page of the new project wizard make sure new Execution Environmet is selected in "Execution Environment" field. Click Finish.
5. View Project java compilor settings. Highlight project->right click->properties->Java Compiler. 
Compliance level should be set to 1.5. Notice it is set to 1.3.

Other way to recreate issue:
1. Add custom execution environment:
1a. Windows->Preferences->Java->Instaled JREs. 
1b. Add->Execution Environment Description-> Next. 
1c. Specify valid ee file. (File includes: -Dee.language.level=1.5 entry) ->Finish.
2. Create new plug-in project. File->New->Plug-in project.
3. Specify name click Next.
4. In the "Plug-in content" page of the new project wizard make sure the new Execution Environment is NOT selected in "Execution Environment" field. Click Finish.
5. View new project's manifest file. In the overview tab, remove the current EE from the Execution Enviroment field. 6. Add the new EE.
7. click the "Update the classpath settings" link.
8. View Project java compilor settings. Highlight project->right click->properties->Java Compiler. 
Compliance level should be set to 1.5. Notice it is set to 1.3.

More information:
the setClasspath method in org.eclipse.pde.internal.core.ClasspathComputer, attempts to set the current project's compiler level based on the name of the project's execution environment. If the getCompliance method in the class org.eclipse.pde.internal.core.ExecutionEnvironmentAnalyzer doesn't recogine the project's EE, it assumes that the EE is version 1.3. It doesn't seem as though this class considers EE contributed via the extension point org.eclipse.jdt.launching.executionEnvironments.
Comment 1 Andrew Niefer CLA 2008-06-09 14:42:48 EDT
UI? or debug?
Comment 2 Darin Wright CLA 2008-06-09 14:51:42 EDT
Moving to JDT debug for now. I think IExectutionEnvironment needs to be enhanced to provide compiler compliance settings in some fashion.
Comment 3 Darin Wright CLA 2008-08-21 10:34:11 EDT
This needs to addressed in conjuction with PDE and OSGi.
Comment 4 Markus Keller CLA 2008-08-26 12:24:36 EDT
> I think IExecutionEnvironment needs to be
> enhanced to provide compiler compliance settings in some fashion.

This would also be interesting for JDT/UI (bug 176516).
Comment 5 Darin Wright CLA 2008-10-01 16:07:10 EDT
The proposed plan is to enhance the execution environment extension point to allow an OSGi profile properties file to be contributed with an EE. The profile file describes required OSGi system properties (available system packages, source and target compilation settings, etc). 

JDT will provide an API to access these properties so PDE and JDT/UI can create projects with appropriate default compiler settings, and so PDE can export and launch properly with these EEs/profiles.
Comment 6 Darin Wright CLA 2008-10-03 15:16:23 EDT
I've added support to the execution environments extension point to specify an OSGi profile properties file associated an environment. The properties are exposed in the API of IExecutionEnvironment via getProfileProperties(). When provided with an execution environment, default access rules are generated for system packages when bound to a project for that EE. 

For existing OSGi profiles, the getProfileProperties() API returns the associated properties supplied by OSGi. 

Since OSGi plans to add javacSource and javacTarget properties, not sure if we need more API to provide default compliance settings or simply access the relevant properties. 

There also seems to be a slight dicsonnect between OSGi/PDE Build and JUI. JUI uses a top level "compilance" setting (like 1.5, 1.4, etc), where as OSGi and PDE/Build use source and target level compiler settings. I believe we are only going to expose the source/target level settings - does this mean PDE and JUI need to translate this to a "compliance" setting?
Comment 7 Darin Wright CLA 2008-10-31 10:53:15 EDT
to be continued in M4
Comment 8 Darin Wright CLA 2008-11-06 14:25:59 EST
Added #getComplianceOptions() convenience method to IExecutionEnvironment. This returns all Eclipse Java compiler settings present for the profile.
Comment 9 Darin Wright CLA 2008-11-07 16:16:38 EST
I have a patch contributed to PDE to properly set up plug-ins compiler compliance options based on it's EE. I'm thinking we should push the logic, or at least a utility API for this into JDT launching so both PDE and JUI can leverage it - else JUI and PDE will end up with the same code.

Once the patch in bug 238802 is applied, I will refactor this code.
Comment 10 Darin Wright CLA 2008-12-05 15:19:49 EST
Marking fixed. JUI has not asked for additional API.
Comment 11 Darin Wright CLA 2008-12-08 14:58:51 EST
Verified.