code: @Override
      public <T> T getInterface(Object thiz, Class<T> clasz) {
          if (!(thiz instanceof bsh.This)) {
              throw new IllegalArgumentException("Illegal object type: " + (null == thiz ? "null" : thiz.getClass()));
          }
  
          bsh.This bshThis = (bsh.This) thiz;
          return clasz.cast(bshThis.getInterface(clasz));
      }
docs: Returns an implementation of an interface using member functions of a
  scripting object compiled in the interpreter. The methods of the interface
  may be implemented using invoke(Object, String, Object...) method.
  
  @param thiz  The scripting object whose member functions are used to
  implement the methods of the interface.
  @param clasz The {@code Class} object of the interface to return.
  @return An instance of requested interface - null if the requested
  interface is unavailable, i. e. if compiled methods in the
  {@code ScriptEngine} cannot be found matching the ones in the
  requested interface.
  @throws IllegalArgumentException if the specified {@code Class} object
  does not exist or is not an interface, or if the specified Object is null
  or does not represent a scripting object.