Program: 82345
Project: 82345
Buggy source:
/** 
 * @param ccl
 * @param jsthis
 * @param methodName
 * @param args
 * @param returnJsValue
 * @throws Throwable
 */
public void invokeJavascript(CompilingClassLoader ccl,JsValueOOPHM jsthis,String methodName,JsValueOOPHM[] args,JsValueOOPHM returnJsValue) throws Throwable {
  final ServerObjectsTable remoteObjects=getJavaObjectsExposedInBrowser();
  Value vthis=convertFromJsValue(remoteObjects,jsthis);
  Value[] vargs=new Value[args.length];
  for (int i=0; i < args.length; ++i) {
    vargs[i]=convertFromJsValue(remoteObjects,args[i]);
  }
  try {
    InvokeOnClientMessage invokeMessage=new InvokeOnClientMessage(this,methodName,vthis,vargs);
    invokeMessage.send();
    final ReturnMessage msg=reactToMessagesWhileWaitingForReturn(handler);
    Value returnValue=msg.getReturnValue();
    convertToJsValue(ccl,remoteObjects,returnValue,returnJsValue);
    if (msg.isException()) {
      if (returnValue.isNull() || returnValue.isUndefined()) {
        throw ModuleSpace.createJavaScriptException(ccl,null);
      }
 else       if (returnValue.isString()) {
        throw ModuleSpace.createJavaScriptException(ccl,returnValue.getString());
      }
 else       if (returnValue.isJsObject()) {
        Object jso=JsValueGlue.createJavaScriptObject(returnJsValue,ccl);
        throw ModuleSpace.createJavaScriptException(ccl,jso);
      }
 else       if (returnValue.isJavaObject()) {
        Object object=remoteObjects.get(returnValue.getJavaObject().getRefid());
        Object target=((JsValueOOPHM.DispatchObjectOOPHM)object).getTarget();
        if (target instanceof Throwable) {
          throw (Throwable)(target);
        }
 else {
          throw ModuleSpace.createJavaScriptException(ccl,target);
        }
      }
      throw ModuleSpace.createJavaScriptException(ccl,returnValue.getValue().toString());
    }
  }
 catch (  IOException e) {
    throw new RemoteDeathError(e);
  }
catch (  BrowserChannelException e) {
    throw new RemoteDeathError(e);
  }
}

Fixed version (ground truth):
/** 
 * @param ccl
 * @param jsthis
 * @param methodName
 * @param args
 * @param returnJsValue
 * @throws Throwable
 */
public void invokeJavascript(CompilingClassLoader ccl,JsValueOOPHM jsthis,String methodName,JsValueOOPHM[] args,JsValueOOPHM returnJsValue) throws Throwable {
  final ServerObjectsTable remoteObjects=getJavaObjectsExposedInBrowser();
  Value vthis=convertFromJsValue(remoteObjects,jsthis);
  Value[] vargs=new Value[args.length];
  for (int i=0; i < args.length; ++i) {
    vargs[i]=convertFromJsValue(remoteObjects,args[i]);
  }
  try {
    InvokeOnClientMessage invokeMessage=new InvokeOnClientMessage(this,methodName,vthis,vargs);
    invokeMessage.send();
    final ReturnMessage msg=reactToMessagesWhileWaitingForReturn(handler);
    Value returnValue=msg.getReturnValue();
    convertToJsValue(ccl,remoteObjects,returnValue,returnJsValue);
    if (msg.isException()) {
      Object exceptionValue;
      if (returnValue.isNull() || returnValue.isUndefined()) {
        exceptionValue=null;
      }
 else       if (returnValue.isString()) {
        exceptionValue=returnValue.getString();
      }
 else       if (returnValue.isJsObject()) {
        exceptionValue=JsValueGlue.createJavaScriptObject(returnJsValue,ccl);
      }
 else       if (returnValue.isJavaObject()) {
        Object object=remoteObjects.get(returnValue.getJavaObject().getRefid());
        Object target=((JsValueOOPHM.DispatchObjectOOPHM)object).getTarget();
        if (target instanceof Throwable) {
          throw (Throwable)(target);
        }
 else {
          exceptionValue=target;
        }
      }
 else {
        exceptionValue=returnValue.getValue().toString();
      }
      RuntimeException exception=ModuleSpace.createJavaScriptException(ccl,exceptionValue);
      exception.fillInStackTrace();
      throw exception;
    }
  }
 catch (  IOException e) {
    throw new RemoteDeathError(e);
  }
catch (  BrowserChannelException e) {
    throw new RemoteDeathError(e);
  }
}