Summary: | [1.5][compiler] Inconsistent error reporting between static import and direct field access | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olivier Thomann <Olivier_Thomann> | ||||
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | kent_johnson, Olivier_Thomann, philippe_mulet | ||||
Version: | 3.2 | ||||||
Target Milestone: | 3.2 M5 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Olivier Thomann
2006-02-06 10:01:07 EST
A.java: package p; public class A implements I { } I.java: package p; interface I { int CONST = 1; } This is a bug with inheriting constants thru a superinterface. Even using jdk1.4, this case should fail for both fields but it doesn't: class X { static int i = p.A.CONSTANT_I; // should report that I is not visible static int j = p.A.CONSTANT_B; // correctly reports that B is not visible } package p; public class A extends B implements I {} interface I { int CONSTANT_I = 1; } class B { int CONSTANT_B = 1; } Added StaticImportTest test36 to catch all the cases Fix is breaking other scenarii, non based on static imports. Added LookupTest#test058 for broken scenario example. Removed entry from buildnotes, and removed fix for bug 126564 from HEAD. Also what about static method invocations ? Javac had same bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6225935 According to JLS all accessible members from supertypes are ok to reach. I don't see any check to be done on declaring class thus. JLS 6.4.3 I believe testcases should be accepted. Static import resolution is wrong. It does check declaringClass visibility which it shouldn't. However, it should instead check visibility of target field against receiver type: import static p.A.CONST; 1. check that p.A is visible from unit scope 2. check that CONST is visible from p.A within unit scope and import reference as invocation site. Created attachment 34569 [details]
Proposed fix
haven't check the story for method imports. Added more tests: StaticImportTest#test037-039, including method scenarii (appears we were fine there). Released patch for M5. Kent - pls double check Verified for 3.2 M5 using build I20060215-0010 |