Bug 249107 - [compiler] IllegalAccessError in presence of synthetic field access
Summary: [compiler] IllegalAccessError in presence of synthetic field access
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-30 09:28 EDT by Philipe Mulet CLA
Modified: 2008-10-28 13:11 EDT (History)
0 users

See Also:


Attachments
Proposed patch (12.96 KB, patch)
2008-09-30 12:41 EDT, Philipe Mulet CLA
no flags Details | Diff
Extra patch (23.65 KB, patch)
2008-10-01 12:48 EDT, Philipe Mulet CLA
no flags Details | Diff
More patch (4.92 KB, patch)
2008-10-01 18:26 EDT, 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 Philipe Mulet CLA 2008-09-30 09:28:19 EDT
Build 3.5M2

Follow-up of bug 128563 (comment 10)

[...] Note that similar problem also exists with field access
e.g.
package1/A.java [
package package1;
abstract class A {
    protected int outerField; {
    }
}

]
package1/B.java [
package package1;
public class B extends A {
}

]
package2/C.java [
package package2;
import package1.B;
public class C extends B {
    private final MyInner myInner = new MyInner();
    private class MyInner {
        public void innerMethod() {
            int j = C.this.outerField;
        }
    }
    public static void main(String[] args) {
        final C c = new C();
        c.myInner.innerMethod();
    }
}
Comment 1 Philipe Mulet CLA 2008-09-30 09:30:18 EDT
Added InnerEmulation#test157-160
Comment 2 Philipe Mulet CLA 2008-09-30 12:41:42 EDT
Created attachment 113888 [details]
Proposed patch
Comment 3 Philipe Mulet CLA 2008-09-30 12:42:47 EDT
Added also InnerEmulationTest#test161-164 (for static fields)
Comment 4 Philipe Mulet CLA 2008-09-30 13:30:29 EDT
Released for 3.5M3
Fixed
Comment 5 Philipe Mulet CLA 2008-10-01 12:46:15 EDT
Previous change did break an existing situation like:

class XSuper {
	protected String field;
}
public class X extends XSuper {
	protected String field;
	public static void main(String[] args) {
		new X().foo();
	}
	void foo() {
		new Object() {
			void bar() {
				X.this.field = "[X#field]";
				X.super.field = "[XSuper#field]";
				System.out.print("X.this.field=" + X.this.field);
				System.out.print("X.super.field=" + X.super.field);
			}
		}.bar();
	}
}

which should print:
X.this.field=[X#field]X.super.field=[XSuper#field]
Comment 6 Philipe Mulet CLA 2008-10-01 12:47:02 EDT
Added InnerEmulationTest#test166-168.
Comment 7 Philipe Mulet CLA 2008-10-01 12:48:28 EDT
Created attachment 114016 [details]
Extra patch
Comment 8 Kent Johnson CLA 2008-10-01 16:08:23 EDT
Did the extra patch get released ?
Comment 9 Philipe Mulet CLA 2008-10-01 17:14:34 EDT
Not yet, there is still an issue with it... working on it.
Comment 10 Philipe Mulet CLA 2008-10-01 17:38:29 EDT
Just released the extra patch, but still an issue for:

public class X {
    class Member {
        private String field = "SUCCESS";
    }
    class SubMember extends Member {
    	void foo() {
    		System.out.println(super.field);
    	}
    }	
    public static void main(String argv[]) {
		new X().new SubMember().foo();    	
    }
}

(we didn't have a test for it)
and similar replacing #field with a method:

public class X {
    class Member {
        private String method() { return "SUCCESS";}
    }
    class SubMember extends Member {
    	void foo() {
    		System.out.println(super.method());
    	}
    }	
    public static void main(String argv[]) {
		new X().new SubMember().foo();    	
    }
}
Comment 11 Philipe Mulet CLA 2008-10-01 17:39:43 EDT
Added InnerEmulationTest#test170-171
Comment 12 Philipe Mulet CLA 2008-10-01 18:26:14 EDT
Created attachment 114053 [details]
More patch
Comment 13 Philipe Mulet CLA 2008-10-01 18:28:11 EDT
Released last portion of the patch
Comment 14 Philipe Mulet CLA 2008-10-02 03:12:11 EDT
All patches released for 3.5M3
Fixed
Comment 15 Kent Johnson CLA 2008-10-28 13:11:02 EDT
Verified for 3.5M3 using I20081026-2000 build.