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

Bug 347786

Summary: [1.7][quick fix] Quick fixes for new warnings/errors corresponding to @SafeVarargs annotation
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: UIAssignee: Deepak Azad <deepakazad>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: deepakazad, jarthana, markus.kell.r
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
fix + tests
none
rtstubs17.jar - zipped and compressed
none
fix + tests
none
final fix + tests
none
additional fixes
none
Additional tests none

Description Deepak Azad CLA 2011-05-31 10:03:40 EDT
Created attachment 196983 [details]
fix + tests

The patch includes the following 3 quick fixes and tests
- Add @SafeVarargs
- Add @SafeVarargs to method declaration
- Remove @Safevargs

Currently the second quick fix only works when the declaration is in the same file. Not sure if a quick fix should modify another file (when it is invoked from the editor). If yes, should the other file be opened in an editor ?

Changes to test with 1.7 compliance level
- Use rtstubs17.jar in ProjectTestSetup. (ProjectTestSetup still sets the compiler compliance level as 1.5)
- Add helper methods in JavaProjectHelper to set compiler compliance level to 1.7. (These helper methods are then used from individual tests which need 1.7 compiler compliance)
Comment 1 Deepak Azad CLA 2011-05-31 10:12:41 EDT
Created attachment 196985 [details]
rtstubs17.jar - zipped and compressed
Comment 2 Markus Keller CLA 2011-06-01 10:08:58 EDT
> Not sure if a quick fix should modify another file (when it is invoked
> from the editor). If yes, should the other file be opened in an editor ?

Yes, it should open and modify the other file. See other quick fixes that do the same and reuse their implementation (try with e.g. a wrong field type or method return type, modifiers, etc.).
Comment 3 Deepak Azad CLA 2011-06-02 10:44:32 EDT
Created attachment 197232 [details]
fix + tests

(In reply to comment #2)
> Yes, it should open and modify the other file. See other quick fixes that do
> the same and reuse their implementation (try with e.g. a wrong field type or
> method return type, modifiers, etc.).
Thanks! 'Add @SafeVarargs to method declaration' quick assist now works even when the declaration is in a different file.

Markus, if you are ok with the following changes I will release the patch.
> Changes to test with 1.7 compliance level
> - Use rtstubs17.jar in ProjectTestSetup. (ProjectTestSetup still sets the
> compiler compliance level as 1.5)
> - Add helper methods in JavaProjectHelper to set compiler compliance level to
> 1.7. (These helper methods are then used from individual tests which need 1.7
> compiler compliance)
Comment 4 Eclipse Webmaster CLA 2011-06-07 09:05:39 EDT
The content of attachment 196985 [details] has been deleted by
    Eclipse Webmaster <webmaster@eclipse.org>
who provided the following reason:

Request to Webmaster.

The token used to delete this attachment was generated at 2011-06-07 09:05:23 EDT.
Comment 5 Deepak Azad CLA 2011-06-09 00:03:32 EDT
Created attachment 197663 [details]
final fix + tests
Comment 6 Deepak Azad CLA 2011-06-09 00:04:12 EDT
Fixed in BETA_JAVA7
Comment 7 Markus Keller CLA 2011-06-16 11:40:44 EDT
Created attachment 198124 [details]
additional fixes

- added null checks to resolved bindings and calls to ASTResolving.find(..)
- changed quick fix name to "Add @SafeVarargs to ''{0}(..)''". We always mention the other method when the quick fix changes remote methods.

Released to BETA_JAVA7.
Comment 8 Deepak Azad CLA 2011-06-17 00:48:59 EDT
Created attachment 198157 [details]
Additional tests

(In reply to comment #7)
> - added null checks to resolved bindings and calls to ASTResolving.find(..)
> - changed quick fix name to "Add @SafeVarargs to ''{0}(..)''". We always
> mention the other method when the quick fix changes remote methods.

Thanks Markus! I have updated the tests for the change in the quick fix label and also added a couple of new tests.

Released to BETA_JAVA7.
Comment 9 Jay Arthanareeswaran CLA 2011-07-20 04:49:49 EDT
Verified