Static Java import causing a compilation error. Probable compiler error?

This compiles in Eclipse JDT, but not on 1.6.30 or 1.7.25:

package doh; import static doh.Wtf.InnerClass.innerclassMethod; import java.io.Serializable; public class Wtf { static class InnerClass implements Serializable { public static void innerclassMethod() { } } } 

With javac, I get the following compilation error:

 error: cannot find symbol static class InnerClass implements Serializable { symbol: class Serializable location: class Wtf 

Commenting out excess static import, code compilation. So reordering import statements.

+7
java
source share
1 answer

I get the same compilation error with jdk 1.7.25.

It seems that the known error (although the example provided in the error report uses the enumeration as a nested class, but it is conceptually identical) and the proposed workarounds are the same as you describe:

  • swap import statements
  • remove static import and use full name
+7
source share