Bug 117861

Summary: [1.5][compiler] invalid handling of static import
Product: [Eclipse Project] JDT Reporter: Patrik Beno <patrikbeno>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: sandman
Version: 3.2   
Target Milestone: 3.1.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
test case none

Description Patrik Beno CLA 2005-11-24 04:52:34 EST
we're getting following error:

line 10: The method format(String, Object, Object) in the type Assert is not applicable for the arguments (String)
line 11: The method format(String, Object, Object) from the type Assert is not visible


the test code is as follows:

---code---
package bug;

import static java.lang.String.format;
import junit.framework.TestCase;

public class Bug extends TestCase {
	static public void main(String[] args) {
		String msg = "something's rotten in the state of Denmark";
		// bug
		System.out.println(format(msg));
		System.out.println(format(msg, 1, 2));		
	}
}
---end-of-code---

NOTES: 
1) javac compiles this with no problems
2) inherited Assert.format(...) (which compiler tries to compile against) is package private (therefore not accessible) which means there's no conflict

IMPACT:
since we use static imports a lot, this is a show-stopper for us :-(

WORKAROUND:
- avoid static import and use String.format() explicitly
Comment 1 Patrik Beno CLA 2005-11-24 05:01:38 EST
ok, lowering severity: at first sight, this kind of conflicts is maybe not so frequent... there useability impact might not be so fatal 

however, i guess described behaviour may have other side effects not directly related to static imports. this makes eclipse compiler sort of "unreliable"  :-(
Comment 2 Patrik Beno CLA 2005-11-24 05:15:39 EST
Created attachment 30526 [details]
test case

attaching simple test case
classes:
Bug - primary test case, demonstrates described problem
Base + Xtended - alternate test case: demonstrates scope resolution problem
Comment 3 Kent Johnson CLA 2005-11-24 14:48:39 EST
Added StaticImport test035

Released into HEAD and the 3.1.2 stream
Comment 4 Olivier Thomann CLA 2005-12-13 10:42:16 EST
Verified for 3.2M4 in I20051212-2000
Comment 5 Frederic Fusier CLA 2006-01-10 09:02:59 EST
Verified for 3.1.2 using build M20060109-1200.
Comment 6 Sandeep Tamhankar CLA 2006-02-24 15:17:35 EST
*** Bug 129388 has been marked as a duplicate of this bug. ***