Bug 257716 - [compiler] Erroneous blank field may not have been initialized
Summary: [compiler] Erroneous blank field may not have been initialized
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 275246 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-12-05 09:49 EST by Nikolay Metchev CLA
Modified: 2009-05-07 10:03 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (29.36 KB, patch)
2009-01-29 08:33 EST, Philipe Mulet CLA
no flags Details | Diff
Better patch (30.33 KB, patch)
2009-01-29 09:10 EST, Philipe Mulet CLA
no flags Details | Diff
Proposed patch for 3.4 (29.37 KB, patch)
2009-01-29 12:07 EST, Philipe Mulet CLA
no flags Details | Diff
Proposed patch for 3.3 (31.75 KB, patch)
2009-01-30 07:46 EST, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Metchev CLA 2008-12-05 09:49:57 EST
Build ID:  I20080617-2000

Steps To Reproduce:
the following code show an erroneous blank final field may not have been initialized compiler error:
public class AnnonymousInnerComplainsAboutFinalMember
{
  final int hello;

  public AnnonymousInnerComplainsAboutFinalMember()
  {
    hello = 0;

    new Object()
    {
        int i = hello;
    };
  }
}


More information:
Comment 1 Olivier Thomann CLA 2008-12-05 12:18:51 EST
Reproduced with HEAD.
All javac versions seem to compile without an error.
Comment 2 Philipe Mulet CLA 2009-01-23 04:25:16 EST
This is a regression introduced in 3.3.2.
Comment 3 Philipe Mulet CLA 2009-01-23 04:27:39 EST
Bug most likely introduced when fixing bug 203061
Comment 4 Philipe Mulet CLA 2009-01-28 06:01:29 EST
More detailed testcase:

public class X {
	final int hello;
	public X() {
		hello = 0;
		new Object() {
			int i = hello;
		};
	}
	public X(int i) {
		new Object() {
			int j = hello;
		};
	}	
}

1. We should blame 'int j = hello;' but not 'int i = hello;.
2. We should not blame constructor X(int i) for missing init for #hello.

Before 3.3.2, we did behave ok for (1), but not for (2).
Now we are wrong for both (1) and (2).
Comment 5 Philipe Mulet CLA 2009-01-29 08:28:26 EST
Erratum:
Error (2) is legite.

Comment 6 Philipe Mulet CLA 2009-01-29 08:33:07 EST
Added InitializationTest#test196-203
Comment 7 Philipe Mulet CLA 2009-01-29 08:33:55 EST
Created attachment 124145 [details]
Proposed patch
Comment 8 Philipe Mulet CLA 2009-01-29 08:43:39 EST
Fix for bug 203061 did surface this one; as prior to fix for 203061 we wouldn't even check for initialization status within anonymous type. Since 3.3.2 we did, but there was an inconsistency for retrieving the initialization flow info that now became apparent.
i.e. prior to 203061 we would not reject invalid code; after 3.3.2 we were rejecting valid code in certain corner cases.

Comment 9 Philipe Mulet CLA 2009-01-29 09:10:32 EST
Created attachment 124147 [details]
Better patch

Previous patch did not handle presence of generics properly
Comment 10 Philipe Mulet CLA 2009-01-29 11:59:13 EST
Released for 3.5M6.
Fixed
Comment 11 Philipe Mulet CLA 2009-01-29 12:07:34 EST
Created attachment 124163 [details]
Proposed patch for 3.4
Comment 12 Philipe Mulet CLA 2009-01-30 07:46:40 EST
Created attachment 124259 [details]
Proposed patch for 3.3
Comment 13 Philipe Mulet CLA 2009-01-30 09:06:34 EST
Released into 3.3.x branch
Comment 14 Philipe Mulet CLA 2009-02-06 09:48:44 EST
Released into 3.4.x branch (post 3.4.2)
Comment 15 Kent Johnson CLA 2009-03-10 10:19:09 EDT
Verified for 3.5M6 using I20090310-0100
Comment 16 Olivier Thomann CLA 2009-05-07 10:01:38 EDT
*** Bug 275246 has been marked as a duplicate of this bug. ***