ChaimKut
ChaimKut

Reputation: 2809

How to find in Eclipse which classes implement multiple interfaces?

Using Eclipse, how can I find which Java classes implement interface A AND interface B? Thanks.

Upvotes: 10

Views: 969

Answers (3)

Chris Lercher
Chris Lercher

Reputation: 37778

I just had the same problem, and I'm really missing this feature in the Eclipse search dialog. Going through all classes manually wasn't very pleasant, so I used this nasty workaround. Given this structure:

public interface A {
  public String x();
}
public interface B {
}

public class ImplementsBoth implements A, B {

  @Override
  public String x() {...}

}
public class ImplementsA implements A {

  @Override
  public String x() {...}

}
public class ImplementsB implements B {

}

I changed B into:

public interface B {
  public void x();
}

This results in the following error for ImplementsBoth:

The return type is incompatible with B.x()

Now it's possible to step through all these messages in the Problems view.

Upvotes: 1

Alex Nevsky
Alex Nevsky

Reputation: 900

Search -> File... -> public * implements *,* or another pattern.

Upvotes: 0

ankushb
ankushb

Reputation: 198

Ctrl+H, in file search tab search for "[implements A,B | implements B,A]" while file type is *.java.

Upvotes: 0

Related Questions