Bug 190391

Summary: ECJ: Constructors can initialize other instance's final fields instead of their own
Product: [Eclipse Project] JDT Reporter: Adrian Mettler <montypythonite>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2.1   
Target Milestone: 3.3 M7   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
a class that can break DA/DU as implemented in ECJ none

Description Adrian Mettler CLA 2007-05-31 21:54:57 EDT
Build ID: M20060921-0945

Steps To Reproduce:
1. Define a class with a final field
2. Give it a constructor which takes an instance of the same class
3. In the constructor, "initialize" the final field belonging to the passed-in instance instead of this.
Or better, just see the attached file.

More information:
A constructor can "initialize" a final field of another instance instead of the field in the instance being created.  The attached program compiles with Eclipse, and allows a final field to be overwritten; Both Sun's javac and gcj refuse to compile it.
Comment 1 Adrian Mettler CLA 2007-05-31 21:57:55 EDT
Created attachment 69648 [details]
a class that can break DA/DU as implemented in ECJ
Comment 2 Philipe Mulet CLA 2007-06-01 04:20:47 EDT
This is a dup of bug 151787, which was addressed for 3.3M7.

A 3.2 patch was issued, pls find it under:
http://www.eclipse.org/jdt/core/r3.2/index.php#UPDATES

or directly get the patch at:
http://www.eclipse.org/jdt/core/patches/org.eclipse.jdt.core_3.2.3.z20070503-1623.jar


*** This bug has been marked as a duplicate of bug 151787 ***