Bug 266013

Summary: [1.5][compiler] Eclipse compiles code with static import from nested class that javac doesn't
Product: [Eclipse Project] JDT Reporter: Eric Jain <eric.jain>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED NOT_ECLIPSE QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 3.4.1   
Target Milestone: 3.5 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Eric Jain CLA 2009-02-24 14:35:26 EST
Build ID: M20080911-1700

Steps To Reproduce:
=== test/A.java ==
package test;

import static test.A.B.bar;
import other.C;

public class A {
	
	public void foo() {
		bar();
	}
	
	public static class B extends C {
		
		public static void bar() {
			
		}
	}
}

=== other/C.java ==
package other;

public class C {

}


More information:
Eclipse compiles this code whereas Sun's javac (1.6.0_11) fails like so:

test\A.java:12: cannot find symbol
symbol  : class C
location: class test.A
        public static class B extends C {
                                      ^
1 error

In both cases the code compiles fine if the order of the two import statements is switched! Arguably Eclipse is being smarter here, so it may be worth checking if the language specification has anything to say on this matter.
Comment 1 Eric Jain CLA 2009-02-24 14:38:07 EST
Replacing "B extends C" with "B extends other.C" also makes javac happy.
Comment 2 Kent Johnson CLA 2009-02-25 15:05:16 EST
Cannot find anything in the spec that says static import statements are order dependent.

I suggest you enter a bug against javac.
Comment 3 Eric Jain CLA 2009-02-25 15:20:44 EST
Looks like this bug is indeed a problem with Sun's javac (and has been known for 3 years now!): http://bugs.sun.com/view_bug.do?bug_id=6391197
Comment 4 Frederic Fusier CLA 2009-03-09 13:58:33 EDT
Verified for 3.5M6