com.eclipsesource.v8.V8.close()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中com.eclipsesource.v8.V8.close()方法的一些代码示例,展示了V8.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。V8.close()方法的具体详情如下:
包路径:com.eclipsesource.v8.V8
类名称:V8
方法名:close

V8.close介绍

暂无

代码示例

代码示例来源:origin: eclipsesource/J2V8

/**
 * Releases the NodeJS runtime.
 */
public void release() {
  v8.checkThread();
  if (!require.isReleased()) {
    require.close();
  }
  if (!v8.isReleased()) {
    v8.close();
  }
}

代码示例来源:origin: eclipsesource/J2V8

@Override
public void run() {
  runtime = V8.createV8Runtime();
  try {
    target.run(runtime);
  } finally {
    synchronized (this) {
      if (runtime.getLocker().hasLock()) {
        runtime.close();
        runtime = null;
      }
    }
  }
}

代码示例来源:origin: eclipsesource/J2V8

synchronized (this) {
  if (runtime.getLocker().hasLock()) {
    runtime.close();
    runtime = null;

代码示例来源:origin: eclipsesource/J2V8

@After
public void tearDown() {
  try {
    v8.close();
    if (V8.getActiveRuntimes() != 0) {
      throw new IllegalStateException("V8Runtimes not properly released");
    }
  } catch (IllegalStateException e) {
    System.out.println(e.getMessage());
  }
}

代码示例来源:origin: eclipsesource/J2V8

@After
public void tearDown() {
  if (v8 != null) {
    v8.close();
  }
  if (V8.getActiveRuntimes() != 0) {
    throw new IllegalStateException("V8Runtimes not properly released");
  }
}

代码示例来源:origin: eclipsesource/J2V8

@After
public void tearDown() {
  if (v8 != null) {
    v8.close();
  }
  if (V8.getActiveRuntimes() != 0) {
    throw new IllegalStateException("V8Runtimes not properly released");
  }
}

代码示例来源:origin: eclipsesource/J2V8

@After
public void tearDown() {
  try {
    debugHandler.close();
    v8.close();
    if (V8.getActiveRuntimes() != 0) {
      throw new IllegalStateException("V8Runtimes not properly released");
    }
  } catch (IllegalStateException e) {
    System.out.println(e.getMessage());
  }
}

代码示例来源:origin: eclipsesource/J2V8

@After
public void tearDown() {
  handler.close();
  try {
    v8.close();
    if (V8.getActiveRuntimes() != 0) {
      throw new IllegalStateException("V8Runtimes not properly released");
    }
  } catch (IllegalStateException e) {
    System.out.println(e.getMessage());
  }
}

代码示例来源:origin: eclipsesource/J2V8

@After
public void tearDown() {
  try {
    debugHandler.close();
    v8.close();
    if (V8.getActiveRuntimes() != 0) {
      throw new IllegalStateException("V8Runtimes not properly released");
    }
  } catch (IllegalStateException e) {
    System.out.println(e.getMessage());
  }
}

代码示例来源:origin: eclipsesource/J2V8

@After
public void tearDown() {
  try {
    debugHandler.close();
    v8.close();
    if (V8.getActiveRuntimes() != 0) {
      throw new IllegalStateException("V8Runtimes not properly released");
    }
  } catch (IllegalStateException e) {
    System.out.println(e.getMessage());
  }
}

代码示例来源:origin: eclipsesource/J2V8

@Test(expected = Error.class)
public void testCannotAccessDisposedIsolateString() {
  v8.close();
  v8.executeStringScript("'foo'");
}

代码示例来源:origin: eclipsesource/J2V8

@Test
public void testV8MultipleReleaseHandlers() {
  V8 testV8 = V8.createV8Runtime();
  V8Runnable releaseHandler1 = mock(V8Runnable.class);
  V8Runnable releaseHandler2 = mock(V8Runnable.class);
  testV8.addReleaseHandler(releaseHandler1);
  testV8.addReleaseHandler(releaseHandler2);
  testV8.close();
  verify(releaseHandler1, times(1)).run(any(V8.class)); // cannot check against the real v8 because it's released.
  verify(releaseHandler2, times(1)).run(any(V8.class)); // cannot check against the real v8 because it's released.
}

代码示例来源:origin: eclipsesource/J2V8

@Test
public void testV8UnknownReleaseHandleRemoved() {
  V8 testV8 = V8.createV8Runtime();
  V8Runnable releaseHandler1 = mock(V8Runnable.class);
  V8Runnable releaseHandler2 = mock(V8Runnable.class);
  testV8.addReleaseHandler(releaseHandler1);
  testV8.removeReleaseHandler(releaseHandler2);
  testV8.close();
  verify(releaseHandler1, times(1)).run(any(V8.class)); // cannot check against the real v8 because it's released.
}

代码示例来源:origin: eclipsesource/J2V8

@Test
public void testV8ReleaseHandleRemoved() {
  V8 testV8 = V8.createV8Runtime();
  V8Runnable releaseHandler = mock(V8Runnable.class);
  testV8.addReleaseHandler(releaseHandler);
  testV8.removeReleaseHandler(releaseHandler);
  testV8.close();
  verify(releaseHandler, never()).run(testV8);
}

代码示例来源:origin: eclipsesource/J2V8

@SuppressWarnings("resource")
@Test(expected = IllegalStateException.class)
public void testDoNotReleaseArrayReference() {
  V8 _v8 = V8.createV8Runtime();
  new V8Array(_v8);
  _v8.close();
}

代码示例来源:origin: eclipsesource/J2V8

@SuppressWarnings("resource")
@Test
public void testReleaseRuntimeDoesNotReleaseObject() {
  try {
    new V8Object(v8);
    v8.close();
  } catch (IllegalStateException e) {
    v8 = V8.createV8Runtime();
    return;
  }
  fail("Illegal State Exception not thrown.");
}

代码示例来源:origin: eclipsesource/J2V8

@Test
public void testAlternateGlobalAlias() {
  v8.close();
  v8 = V8.createV8Runtime("document");
  v8.executeVoidScript("var global = Function('return this')();");
  assertTrue(v8.executeBooleanScript("global === document"));
}

代码示例来源:origin: eclipsesource/J2V8

@Test
public void testNestedExecutorExecution() throws InterruptedException {
  V8 runtime = V8.createV8Runtime();
  runtime.terminateExecution();
  V8Executor executor = new V8Executor("");
  executor.start();
  V8Object key = new V8Object(runtime);
  runtime.registerV8Executor(key, executor);
  key.close();
  runtime.close();
  executor.join();
}

代码示例来源:origin: eclipsesource/J2V8

@Test
public void testGetNestedExecutor() {
  V8 runtime = V8.createV8Runtime();
  runtime.terminateExecution();
  V8Executor executor = new V8Executor("");
  V8Object key = new V8Object(runtime);
  runtime.registerV8Executor(key, executor);
  assertEquals(executor, runtime.getExecutor(key));
  key.close();
  runtime.close();
}

代码示例来源:origin: eclipsesource/J2V8

@Test
public void testTerminateNestedExecutors() {
  V8 runtime = V8.createV8Runtime();
  runtime.terminateExecution();
  V8Executor executor = new V8Executor("while (true){}");
  V8Object key = new V8Object(runtime);
  runtime.registerV8Executor(key, executor);
  runtime.shutdownExecutors(false);
  assertTrue(runtime.getExecutor(key).isShuttingDown());
  key.close();
  runtime.close();
}

相关文章

V8类方法