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

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

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

V8.release介绍

[英]Release native resources associated with this runtime. Once released, a runtime cannot be reused.
[中]释放与此运行时关联的本机资源。一旦发布,运行时就无法重用。

代码示例

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

@Override
public void close() {
  release(true);
}

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

@Override
public void close() {
  v8.checkThread();
  if (!released) {
    try {
      v8.releaseObjRef(this);
    } finally {
      released = true;
      v8.release(v8.getV8RuntimePtr(), objectHandle);
    }
  }
}

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

@Override
@Deprecated
public void release() {
  release(true);
}

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

@Override
public void close() {
  v8.checkThread();
  if (!released) {
    try {
      v8.releaseObjRef(this);
    } finally {
      released = true;
      v8.release(v8.getV8RuntimePtr(), objectHandle);
    }
  }
}

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

@Override
public void close() {
  release(true);
}

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

@Override
@Deprecated
public void release() {
  release(true);
}

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

@SuppressWarnings("resource")
@Test(expected = IllegalStateException.class)
public void testISEThrownOnShutdown() {
  V8 v8_ = V8.createV8Runtime();
  new V8Object(v8_);
  v8_.release(true);
}

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

@SuppressWarnings("resource")
@Test
public void testISENotThrownOnShutdown() {
  V8 v8_ = V8.createV8Runtime();
  new V8Object(v8_);
  v8_.release(false);
}

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

@Test
public void testReleaseAttachedObjects() {
  V8 runtime = V8.createV8Runtime();
  V8Object v8Object = new V8Object(v8);
  runtime.registerResource(v8Object);
  runtime.release(true);
}

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

@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_IntegerFunction() {
  V8 engine = null;
  V8 engine2 = null;
  try {
    engine = V8.createV8Runtime();
    engine2 = V8.createV8Runtime();
    engine.executeScript("b = function(param){return param;}");
    engine2.executeScript("a = [7];");
    V8Array a = (V8Array) engine2.get("a");
    engine.executeIntegerFunction("b", a);
  } finally {
    engine.release(false);
    engine2.release(false);
  }
}

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

@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_DoubleFunction() {
  V8 engine = null;
  V8 engine2 = null;
  try {
    engine = V8.createV8Runtime();
    engine2 = V8.createV8Runtime();
    engine.executeScript("b = function(param){return param;}");
    engine2.executeScript("a = [3.14];");
    V8Array a = (V8Array) engine2.get("a");
    engine.executeDoubleFunction("b", a);
  } finally {
    engine.release(false);
    engine2.release(false);
  }
}

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

@SuppressWarnings("resource")
@Test
public void testReleaseRuntimeReportsMemoryLeaks() {
  V8 localV8 = V8.createV8Runtime();
  new V8Object(localV8);
  try {
    localV8.release(true);
  } catch (IllegalStateException ise) {
    String message = ise.getMessage();
    assertEquals("1 Object(s) still exist in runtime", message);
    return;
  }
  fail("Exception should have been thrown");
}

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

@Test(expected = Error.class)
public void testSharingObjectsAsFunctionCallParameters_ExecuteFunction() {
  V8 engine = null;
  V8 engine2 = null;
  try {
    engine = V8.createV8Runtime();
    engine2 = V8.createV8Runtime();
    engine.executeScript("b = function(param){return param;}");
    engine2.executeScript("a = [{name: 'joe'}];");
    V8Array a = (V8Array) engine2.get("a");
    engine.executeFunction("b", a);
  } finally {
    engine.release(false);
    engine2.release(false);
  }
}

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

@Test
public void testToStringWorksOnReleasedV8Runtime_V8Object() {
  @SuppressWarnings("resource")
  V8Object v8Object = new V8Object(v8);
  v8.release(false);
  assertEquals("[Object released]", v8Object.toString());
  v8 = V8.createV8Runtime();
}

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

@Test
public void testToStringWorksOnReleasedV8Runtime_V8Array() {
  @SuppressWarnings("resource")
  V8Object v8Object = new V8Array(v8);
  v8.release(false);
  assertEquals("[Array released]", v8Object.toString());
  v8 = V8.createV8Runtime();
}

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

@Test
public void testToStringWorksOnReleasedV8Runtime_V8Function() {
  @SuppressWarnings("resource")
  V8Object v8Object = new V8Function(v8);
  v8.release(false);
  assertEquals("[Function released]", v8Object.toString());
  v8 = V8.createV8Runtime();
}

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

@SuppressWarnings("resource")
@Test
public void testReleaseRuntimeWithWeakReferencesReportsCorrectMemoryLeaks() {
  V8 localV8 = V8.createV8Runtime();
  new V8Object(localV8);
  new V8Object(localV8).setWeak();
  try {
    localV8.release(true);
  } catch (IllegalStateException ise) {
    String message = ise.getMessage();
    assertEquals("1 Object(s) still exist in runtime", message);
    return;
  }
  fail("Exception should have been thrown");
}

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

@Test
public void testReleaseAttachedMap() {
  V8 runtime = V8.createV8Runtime();
  V8Map<String> v8Map = new V8Map<String>();
  V8Object v8Object = new V8Object(runtime);
  v8Map.put(v8Object, "foo");
  v8Object.close();
  runtime.registerResource(v8Map);
  runtime.release(true);
}

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

@Test
public void testReleaseSeveralAttachedObjects() {
  V8 runtime = V8.createV8Runtime();
  runtime.registerResource(new V8Object(runtime));
  runtime.registerResource(new V8Object(runtime));
  runtime.registerResource(new V8Object(runtime));
  runtime.release(true);
}

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

@Test
public void testAddItemStoresACopy() {
  V8 v8 = V8.createV8Runtime();
  V8Object v8Object = new V8Object(v8);
  V8Map<String> map = new V8Map<String>();
  map.put(v8Object, "foo");
  v8Object.close();
  try {
    v8.release(true);
    map.close();
  } catch (IllegalStateException e) {
    return;
  }
  fail("Exception expected due to handle leak.");
}

相关文章

V8类方法