| Summary: | Initialize Final field in constructor proposals initializes the filed in all constructors incorrectly | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Kalyan Prasad Tatavarthi <kalyan_prasad> | ||||
| Component: | UI | Assignee: | Kenneth Styrberg <kenneth> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | kenneth, noopur_gupta | ||||
| Version: | 4.13 | ||||||
| Target Milestone: | 4.16 M3 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 10 | ||||||
| See Also: |
https://bugs.eclipse.org/bugs/show_bug.cgi?id=83544 https://git.eclipse.org/r/#/c/160732/ |
||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 282514 [details]
Screenshot - multi fix
You can create a multi-fix (e.g. see screenshot) to fix a problem at multiple locations.
Also, please remove the full stop from the quick fix text.
As I'm working with Bug 37872 - [quick fix] add a constructor parameter, I can implement a fix for this as I'm touching that exact code right now. https://git.eclipse.org/r/#/c/160732/ should fix this also. Fixed by fix for Bug 37872 with the gerrit https://git.eclipse.org/r/#/c/160732/ Verified in eclipse-SDK-4.16M3-win32-x86_64 |
Create a class by name Cls1 and paste the below code in the file public class Cls1 { final int c; public Cls1(int a) { } public Cls1() { c=10; } } An error is reported on constructor "public Cla1(int a)" with a quick fix "initialize final field 'c' in constructor and upon applying the fix changes the code to below public class Cls1 { final int c; public Cls1(int a) { this.c = 0; } public Cls1() { this.c = 0; c=10; } } which is incorrect because the field is already initialized in constructor "Cls1()"