Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending an inner interface?

I got a simple question:

Why does Eclipse scream about implementing these two interfaces?

public abstract class Gateway implements IPlayerity, IItemity {
    public interface IPlayerity { ... }
    public interface IItemity { ... }
    // I...ity
}

I get this error message:

IPlayerity cannot be resolved to a type

like image 646
imacake Avatar asked Jul 15 '11 18:07

imacake


1 Answers

You have a cyclic dependency that can't be resolved given the way the JLS works (although I'm not sure where in the JLS this is documented).

The interfaces IPlayerity and IItemity are not visible to the NestedInterfaces class header definition, since they are inside it. I can fix this by changing your program to

public class NestedInterfaces implements 
      NestedInterfaces.IPlayerity, NestedInterfaces.IItemity 
{
    public interface IPlayerity {}
    public interface IItemity {}
}

but then Eclipse gives me this error, which is much more clear:

 Multiple markers at this line
 - Cycle detected: the type NestedInterfaces cannot extend/implement itself or one of its own member types
 - Cycle detected: the type NestedInterfaces cannot extend/implement itself or one of its own member types
like image 60
Jason S Avatar answered Oct 15 '22 07:10

Jason S