title: Checking if instance of private static inner class
body: <p>The title of the question sounds like a good thought experiment. Sadly it isn't. Lets assume the following code structure:</p>
  
  <pre><code>class Outer {
      private static class Inner implements SomeInterface {
          ...
      }
      public static SomeInterface returnInner() {
          return new Inner();
      }
  }
  </code></pre>
  
  <p>Is there a good, clean way of performing the following check:</p>
  
  <pre><code>SomeInterface a  = A.returnInner();
  if (a instanceof Outer.Inner)
      throw new Error("Ooops, something bad happened");
  </code></pre>
  
  <p>You think this isn't a real life example? Check the <code>Arrays</code> class and the method <code>asList(T ...)</code> which returns its own <code>List&lt;T&gt;</code> implementation, which just happens to be an <code>private static class ArrayList&lt;T&gt;</code> (which has nothing to do with the usual <code>ArrayList</code> - 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 <code>add()</code> method (it uses the implementation of <code>AbstractList</code> - it throws an <code>UnsupportedOperationException</code>).</p>