The title of the question sounds like a good thought experiment. Sadly it isn't. Lets assume the following code structure:

```
class Outer {
    private static class Inner implements SomeInterface {
        ...
    }
    public static SomeInterface returnInner() {
        return new Inner();
    }
}

```

Is there a good, clean way of performing the following check:

```
SomeInterface a  = A.returnInner();
if (a instanceof Outer.Inner)
    throw new Error("Ooops, something bad happened");

```

You think this isn't a real life example? Check the `Arrays` class and the method `asList(T ...)` which returns its own `List<T>` implementation, which just happens to be an `private static class ArrayList<T>` (which has nothing to do with the usual `ArrayList` - thanks Sun and Oracle what would I do without you). I need to check whether the object passed to my method isn't an instance of this wrapper class, because it does not implement the `add()` method (it uses the implementation of `AbstractList` - it throws an `UnsupportedOperationException`).