Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365661 - PDE wizard doesn't properly set the API Tools nature and builder when creating a new plug-in project
Summary: PDE wizard doesn't properly set the API Tools nature and builder when creatin...
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: API Tools (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: 3.8 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 365758
Blocks: 365914
  Show dependency tree
 
Reported: 2011-12-05 15:03 EST by Brian de Alwis CLA
Modified: 2011-12-12 10:34 EST (History)
5 users (show)

See Also:
Michael_Rennie: review+


Attachments
Problem is detected (105.53 KB, image/png)
2011-12-06 09:41 EST, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brian de Alwis CLA 2011-12-05 15:03:19 EST
Build Id: 4.2 I20111205-0805

Apologies if I'm missing something here, but I thought that, providing I had definitions for my various Executable Environments installed (Preferences > Plug-in Development > API Errors/Warnings), that those definitions were used to validate system library usage without needing a corresponding JRE to be installed.  But this does not seem to be the case.

In my situation, I had a plugin with BREE set to J2SE-1.5, but I only had a Java6 JDK.  I was was inadvertently using Java6's String#isEmpty() with no errors, despite that my "Invalid references to execution environments" was set to an error.

My expectation was based on Ankur Sharma's blog [1]

   Another major difference is that API Tooling does not need JRE/JDK.
   It checks the usage against the environment descriptions. The
   descriptions are just the environment API and thus occupy very
   less space. For example, the 1.5 JRE takes close to 50MB while the
   descriptions for the same takes less than 2 MB.

And the brief discussion on bugs 213027 and 253693 makes no mention of requiring a matching JRE to be installed.

Is this a regression?  Or a deliberate change?  I noticed the screenshots have changed since Ankur's blog entry which referenced "Invalid references to system libraries".

I bring this up as although I was able to find and install a J2SE 1.5 JRE to enable the check, it was somewhat difficult to find and install (Apple only supports Java6 JVMs now).  I don't think I could find a working 1.4 JVM, let alone a 1.3 JVM if that was required.  And JDT's Installed JREs dialog is rather unforgiving if the JRE directory layout doesn't meet its expectations.

[1] http://blog.ankursharma.org/2009/07/system-library-validation_17.html
Comment 1 Curtis Windatt CLA 2011-12-05 16:14:39 EST
I can reproduce the behaviour, both 1.5 and 1.6 code is not being reported as an error even when the JDT EE and BREE are set to 1.4 and the various EE fragments are installed.
Comment 2 Olivier Thomann CLA 2011-12-05 18:32:59 EST
I'll try to take a look later today or tomorrow.
Comment 3 Olivier Thomann CLA 2011-12-06 09:38:51 EST
I tried and I don't reproduce. I'll attach a screenshot.
Comment 4 Olivier Thomann CLA 2011-12-06 09:41:28 EST
Created attachment 207993 [details]
Problem is detected

Can you contact me to find out what could be wrong with your environment?
Comment 5 Olivier Thomann CLA 2011-12-06 10:45:25 EST
Brian, how did you set up the api tooling nature of your project ?
Can you check the .project file to make sure it has the right builder and nature?
If not, try to run "Plug-in Tools>API Tools Setup", and run it on your project.
Comment 6 Curtis Windatt CLA 2011-12-06 10:45:50 EST
Trying this on my linux machine and the problems are reported fine.  Brian, can you please check that your project has both the API Tools nature and builder.

We are experiencing a problem on Win7 where the checkbox on the new project creation wizard to enable API tools isn't working.  I will be opening a bug against SWT for it.
Comment 7 Olivier Thomann CLA 2011-12-06 11:14:28 EST
After more investigation, it looks like the problem comes from the way the updateData() is called. The check for isVisible() doesn't work when the wizard is closed on the next page (the one that sets the template).
Comment 8 Olivier Thomann CLA 2011-12-06 11:25:59 EST
The fix is to replace:
data.setEnableAPITooling(fApiAnalysisButton.isVisible() && fApiAnalysisButton.getSelection());
with:
data.setEnableAPITooling(fApiAnalysisButton.isEnabled() && fApiAnalysisButton.getSelection());
Comment 9 Curtis Windatt CLA 2011-12-06 13:01:18 EST
Pushed the fix to master and integration.  Mike, please verify.

http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=eaadd43b9efd004def95375670d746dd90a97401
Comment 10 Michael Rennie CLA 2011-12-06 13:58:22 EST
+1 the fix works as advertised.
Comment 11 Brian de Alwis CLA 2011-12-07 11:34:18 EST
Thanks for the quick resolution!

(In reply to comment #5)
> Brian, how did you set up the api tooling nature of your project ?
> Can you check the .project file to make sure it has the right builder and
> nature?
> If not, try to run "Plug-in Tools>API Tools Setup", and run it on your project.

I wasn't aware that the bundles needed to have the API tooling analysis nature (nor were some other Platform UI developers).  Would it make sense to relax this and simply require the PDE nature for the system-library checking?  So that the API tooling nature would be for the API compat checking?
Comment 12 Curtis Windatt CLA 2011-12-07 11:57:24 EST
(In reply to comment #11)
> I wasn't aware that the bundles needed to have the API tooling analysis nature
> (nor were some other Platform UI developers).  Would it make sense to relax
> this and simply require the PDE nature for the system-library checking?  So
> that the API tooling nature would be for the API compat checking?

Perhaps Olivier can confirm, but I think the builder short circuits if the nature isn't found to improve performance.  The feature is provided by API Tools and the options controlling it are found on the API Errors/Warnings preference page.
Comment 13 Michael Rennie CLA 2011-12-12 10:34:21 EST
(In reply to comment #11)
> Thanks for the quick resolution!
> 
> I wasn't aware that the bundles needed to have the API tooling analysis nature
> (nor were some other Platform UI developers).  

Yes, you must add the nature / build spec to the project, otherwise API tools completely ignores your project. We have a handy setup wizard you can run from the popup menu for a project: Plug-in Tools > API Tools Setup...

> Would it make sense to relax
> this and simply require the PDE nature for the system-library checking?  So
> that the API tooling nature would be for the API compat checking?

The nature and the build spec are tied together - you need a nature to define a build spec (I believe) and since the sys-lib checking is done with the API tools builder, it would be a tonne of work to split it out to only work with the PDE builder.