Walking around compilation failure on enums implementing interfaces

Walking around compilation failure on enums implementing interfaces

If an enum implements an interface, and methods from the interface are called on an instance of the enum, the enum instance needs to be referenced as the interface, or the interface is somehow referenced in the context where the methods are called; Otherwise, there is possible compilation failure in a Maven build complaining about "cannot find symbol" on the interface methods being called.

The compilation failure is said to be a bug in Java 1.6 which has been fixed in Java 1.7. It is confusing because Eclipse does not have problem with it, but you see it in Maven builds.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

More information about formatting options

To prevent automated spam submissions leave this field empty.