@Override
  protected Object doTopCall(
      Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
    CustomContext mcx = (CustomContext) cx;
    mcx.startTime = System.currentTimeMillis();

    return super.doTopCall(callable, cx, scope, thisObj, args);
  }
  @Override
  protected Context makeContext() {
    final CustomContext cx = new CustomContext(this);
    // prevent generating of java class files loaded into the JVM, use
    // interpreted mode
    cx.setOptimizationLevel(-1);

    if (Thread.currentThread().equals(PlatformUI.getWorkbench().getDisplay().getThread())) {
      // only observe instructions in UI thread to avoid locking UI
      cx.setInstructionObserverThreshold(5000);
    }
    ClassLoader classLoader =
        AccessController.doPrivileged(
            new PrivilegedAction<ClassLoader>() {
              @Override
              public ClassLoader run() {
                return new ScriptClassLoader(cx.getApplicationClassLoader());
              }
            });

    cx.setApplicationClassLoader(classLoader);
    cx.setLanguageVersion(Context.VERSION_1_8);
    cx.getWrapFactory().setJavaPrimitiveWrap(false);
    return cx;
  }