Bug 231333 - If @noinstantiate class comes from the default package, illegal usage are not reported
Summary: If @noinstantiate class comes from the default package, illegal usage are not...
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: API Tools (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 4.4 M6   Edit
Assignee: Vikas Chandra CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-05-09 12:10 EDT by Olivier Thomann CLA
Modified: 2014-03-04 15:57 EST (History)
4 users (show)

See Also:


Attachments
Test case (2.02 KB, application/octet-stream)
2008-05-09 12:10 EDT, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2008-05-09 12:10:48 EDT
Created attachment 99501 [details]
Test case

Consider the attached test case, no error are reported in class Clazz inside test1.
If the class NoInstantiateClazz2 is moved to a named package, the usage warnings are properly reported.
Comment 1 Olivier Thomann CLA 2008-05-09 12:13:50 EDT
This is not considered as critical as there is no types inside the default packages in Eclipse bundles.
Comment 2 Darin Wright CLA 2008-05-13 16:56:43 EDT
Since default packages are not used in SDK plug-ins, this is not an issue for 3.4.
Comment 3 Darin Wright CLA 2008-05-13 16:57:46 EDT
Assigned for future consideration.
Comment 4 Vikas Chandra CLA 2014-01-29 08:24:41 EST
I am looking at it. I have a fix for this one.
Comment 5 Vikas Chandra CLA 2014-01-30 03:51:19 EST
For this case, the class (NoInstantiateClazz2) is not getting resolved because during resolution of default package is Test2, the project component in which NoInstantiateClazz2 resides cannot be retrieved. And hence the class NoInstantiateClazz2 cannot be found ( because that is searched only in Test1 Project Component)  due to which problem detection is skipped. 

But this is a generic problem which will happen for all tags across projects and if the tag reside in default package.

The code fix is at
https://git.eclipse.org/r/#/c/21308/
Comment 6 Vikas Chandra CLA 2014-01-30 03:56:14 EST
There is a mismatch of exported package representation and empty package string.
Once that is set, the project component can be appropriately located and the class is resolved. Thereafter the problem detection is successful.
Comment 7 Curtis Windatt CLA 2014-01-30 15:12:12 EST
Fix works well.  Tried with @noinstantiate @noreference and @noextend tags.

Current patchset doesn't include copyright update.

If possible, please write a few test cases for this fix. In org.eclipse.pde.api.tools.tests all of the usage test (package org.eclipse.pde.api.tools.builder.tests.usage) refer to files inside named packages (test-builder\usageprojects\refproject\src\f\FieldUsageClass.java).  Even having a single file with some different tags in it would be a good regression test.
Comment 8 Michael Rennie CLA 2014-01-30 15:30:09 EST
(In reply to Curtis Windatt from comment #7)
> Fix works well.  Tried with @noinstantiate @noreference and @noextend tags.
> 
> Current patchset doesn't include copyright update.
> 
> If possible, please write a few test cases for this fix. In
> org.eclipse.pde.api.tools.tests all of the usage test (package
> org.eclipse.pde.api.tools.builder.tests.usage) refer to files inside named
> packages (test-builder\usageprojects\refproject\src\f\FieldUsageClass.java).
> Even having a single file with some different tags in it would be a good
> regression test.

It would be good to also make sure there is test coverage using the annotations as well as the Javadoc tags.
Comment 9 Curtis Windatt CLA 2014-01-30 15:34:27 EST
(In reply to Michael Rennie from comment #8)
> It would be good to also make sure there is test coverage using the
> annotations as well as the Javadoc tags.

Note that I tested that the fix handles both javadoc tags and annotations correctly.  Test coverage for both would still be smart.
Comment 10 Curtis Windatt CLA 2014-02-03 13:56:05 EST
http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=758a7aa3ed77ac11688974b5feb9f6a1a80c1464
Merged with master, thank you Vikas.
Comment 11 Vikas Chandra CLA 2014-03-04 12:40:23 EST
Verified for Eclipse(4.4) Luna M6 using build eclipse-SDK-I20140303-2000-win32-x86_64