Bug 80197 - [quick fix] unassigned "final" field error range on constructor
Summary: [quick fix] unassigned "final" field error range on constructor
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 101624 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-12-04 00:08 EST by Alexander Staubo CLA
Modified: 2009-08-30 02:38 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Staubo CLA 2004-12-04 00:08:59 EST
1. Given a class:

class A
{
  private final String a;
  public A(String a)
  {
  }
}

2: Save this class. Eclipse will put an error marker on the ctor's parameter 
list, saying the final field "a" has not been initialized.
3. Put the cursor on the "a" parameter and open the quick fix list; the "Assign 
parameter to new field" quick fix should be available, but isn't.
Comment 1 Olivier Thomann CLA 2004-12-04 10:13:43 EST
Move to JDT/UI
Comment 2 Martin Aeschlimann CLA 2005-02-03 09:38:25 EST
moving to jdt.core

The error range is on the constructor. Coulnd't you put it on the field name?
Otherwise I have to evaluate again where the field is that is not initialized.
I could look at the IProblem arguments to get the field name, but I try to avoid
that to not force the IProblem to exacly spec what is where in the arguments.
Comment 3 Philipe Mulet CLA 2005-04-07 09:58:44 EDT
No, the compiler is analyzing each constructor separately, and blames these
which are not setting the field. 
The fix could be to only assign field in one of the constructors.

So you could propose 2 fixes:
- initialize in declaration
- initialize in constructor

Comment 4 Dirk Baeumer CLA 2005-04-07 10:26:48 EDT
Martin, I opt to defer this for 3.1.
Comment 5 Martin Aeschlimann CLA 2005-04-07 10:32:22 EDT
not for 3.1
Comment 6 Markus Keller CLA 2005-07-05 10:15:27 EDT
*** Bug 101624 has been marked as a duplicate of this bug. ***
Comment 7 Eclipse Webmaster CLA 2009-08-30 02:38:33 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.