Bug 285000 - [preferences] Add UI option for unused object allocation problem
Summary: [preferences] Add UI option for unused object allocation problem
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.6 M5   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 236385
Blocks:
  Show dependency tree
 
Reported: 2009-07-29 08:58 EDT by Olivier Thomann CLA
Modified: 2010-01-26 04:15 EST (History)
4 users (show)

See Also:


Attachments
Proposed fix (4.87 KB, patch)
2010-01-13 10:20 EST, Olivier Thomann CLA
no flags Details | Diff
Same patch with copyright updates (6.10 KB, patch)
2010-01-13 11:41 EST, Olivier Thomann CLA
no flags Details | Diff
Patch 3 (16.35 KB, patch)
2010-01-13 14:42 EST, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2009-07-29 08:58:42 EDT
Once bug 236385 is fixed, the new option needs to be exposed in the UI.
Comment 1 Markus Keller CLA 2009-07-29 09:37:55 EDT
Maybe also add a quick fix to insert 'throw' (for Throwables) or 'return' (if the type is compatible with the return type of the enclosing method).
Comment 2 Olivier Thomann CLA 2010-01-13 10:20:00 EST
Created attachment 155984 [details]
Proposed fix

This only adds the corresponding option in the preference page under the right category.
Comment 3 Olivier Thomann CLA 2010-01-13 11:41:27 EST
Created attachment 156003 [details]
Same patch with copyright updates
Comment 4 Markus Keller CLA 2010-01-13 14:42:35 EST
Created attachment 156037 [details]
Patch 3

Adds quick fixes and adjusts layout for bug 236385 comment 39.
Comment 5 Markus Keller CLA 2010-01-13 14:43:36 EST
Released Patch 3 to HEAD.
Comment 6 Deepak Azad CLA 2010-01-26 02:34:48 EST
Verified on I20100125-0800
In the following snipped a warning is shown on both object allocations. Quick fix for the exception object includes 'Throw'. This much works as expected.
       public void foo() {
	   if (bar())
	       new IllegalArgumentException("You must not bar!");
	   
	   new String("Unused allocation");
	}

(In reply to comment #1)
> Maybe also add a quick fix to insert 'throw' (for Throwables) or 'return' (if
> the type is compatible with the return type of the enclosing method).
The quick fix also includes return for both objects, even though the return type is not compatible. Is this expected?
Comment 7 Dani Megert CLA 2010-01-26 04:15:35 EST
Verified in I20100125-1800.

>The quick fix also includes return for both objects, even though the return
>type is not compatible. Is this expected?
Filed bug 300778 to track this: the quick fix should either not be offered or it should also replace 'void' with the correct return type.