Bug 266013 - [1.5][compiler] Eclipse compiles code with static import from nested class that javac doesn't
Summary: [1.5][compiler] Eclipse compiles code with static import from nested class th...
Status: VERIFIED NOT_ECLIPSE
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-24 14:35 EST by Eric Jain CLA
Modified: 2009-03-09 13:58 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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