code: @SuppressWarnings({"unchecked"})
      public static void defineClass(Context cx, Scriptable thisObj,
                                     Object[] args, Function funObj)
          throws IllegalAccessException, InstantiationException,
                 InvocationTargetException
      {
          Class<?> clazz = getClass(args);
          if (!Scriptable.class.isAssignableFrom(clazz)) {
              throw reportRuntimeError("msg.must.implement.Scriptable");
          }
          ScriptableObject.defineClass(thisObj, (Class<? extends Scriptable>)clazz);
      }
docs: Load a Java class that defines a JavaScript object using the
  conventions outlined in ScriptableObject.defineClass.
  <p>
  This method is defined as a JavaScript function.
  @exception IllegalAccessException if access is not available
  to a reflected class member
  @exception InstantiationException if unable to instantiate
  the named class
  @exception InvocationTargetException if an exception is thrown
  during execution of methods of the named class
  @see org.mozilla.javascript.ScriptableObject#defineClass(Scriptable,Class)