JDK-7084633 : static import fails to resolve interfaces on nested enums via import statements
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6u26,7
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-08-29
  • Updated: 2013-05-30
  • Resolved: 2013-05-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
javac 1.6.0_27

java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) Client VM (build 20.2-b06, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Windows 7

A DESCRIPTION OF THE PROBLEM :
If a class defines a nested enumeration which implements an interface from another package and you import that interface and also statically import the enumeration, then it will fail to build with an error indicating that it cannot find the symbol of the interface.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create the following interface:

package pkg.subpkg;
public interface ID { }

And the following class:

package pkg;

import static pkg.Demo.DemoID.*;
import pkg.subpkg.ID;

public class Demo {

	public static enum DemoID implements ID { A, B, C }
	
	public static void main( String[] args ) {
		System.out.println( A );
	}
}


Now, try to compile and you will get the following error:
pkg\Demo.java:8: cannot find symbol
symbol: class ID
location: class pkg.Demo
       public static enum DemoID implements ID { A, B, C }
1 error


However, if you don't use the static import and qualify references to the enum with the name of the enum, it will compile:

System.out.println( DemoID.A );

Or, if you fully qualify the name of ID in the enum declaration, it will compile:

public static enum DemoID implements pkg.subpkg.ID { A, B, C }


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect that imported interfaces would work regardless of whether they are applied to statically imported nested interface...

I would expect that the example code I provided would compile.
ACTUAL -
pkg\Demo.java:8: cannot find symbol
symbol: class ID
location: class pkg.Demo
       public static enum DemoID implements ID { A, B, C }
1 error

ERROR MESSAGES/STACK TRACES THAT OCCUR :
pkg\Demo.java:8: cannot find symbol
symbol: class ID
location: class pkg.Demo
       public static enum DemoID implements ID { A, B, C }
1 error

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package pkg.subpkg;

public interface ID { }

--------------------------------------------------------

package pkg;

import static pkg.Demo.DemoID.*;
import pkg.subpkg.ID;

public class Demo {

	public static enum DemoID implements ID { A, B, C }
	
	public static void main( String[] args ) {
		System.out.println( A );
	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
list the fully qualified class name for the interfaces you apply to nested enums which are statically imported.

Comments
EVALUATION This looks like a dup of 6391197. Eager member enter of A.Outer causes attribution of Sup when the import statement has not been seen yet - thus the resolution error.
30-08-2011