private void releaseNow(Object value) { if (value instanceof V8Value) { V8Value ref = (V8Value) value; if (!ref.isReleased()) { ref.release(); } } } }
private Object checkResult(final Object result) { if (result == null) { return result; } if (result instanceof Float) { return ((Float) result).doubleValue(); } if ((result instanceof Integer) || (result instanceof Double) || (result instanceof Boolean) || (result instanceof String)) { return result; } if (result instanceof V8Value) { if (((V8Value) result).isReleased()) { throw new V8RuntimeException("V8Value already released"); } return result; } throw new V8RuntimeException("Unknown return type: " + result.getClass()); }
private Object checkResult(final Object result) { if (result == null) { return result; } if (result instanceof Float) { return ((Float) result).doubleValue(); } if ((result instanceof Integer) || (result instanceof Double) || (result instanceof Boolean) || (result instanceof String)) { return result; } if (result instanceof V8Value) { if (((V8Value) result).isReleased()) { throw new V8RuntimeException("V8Value already released"); } return result; } throw new V8RuntimeException("Unknown return type: " + result.getClass()); }
@Test public void testKeysetNotReleased() { V8Map<String> map = new V8Map<String>(); V8Object v1 = new V8Object(v8); map.put(v1, "foo"); v1.close(); Set<V8Value> keySet = map.keySet(); assertEquals(1, keySet.size()); assertFalse(keySet.iterator().next().isReleased()); map.close(); }
@Test public void testReleaseObjectDoesNotReleaseTwin() { V8Object v8Object = new V8Object(v8); V8Value twin = v8Object.twin(); v8Object.close(); assertFalse(twin.isReleased()); twin.close(); }
private Object checkResult(final Object result) { if (result == null) { return result; } if (result instanceof Float) { return ((Float) result).doubleValue(); } if ((result instanceof Integer) || (result instanceof Double) || (result instanceof Boolean) || (result instanceof String)) { return result; } if (result instanceof V8Value) { if (((V8Value) result).isReleased()) { throw new V8RuntimeException("V8Value already released"); } return result; } throw new V8RuntimeException("Unknown return type: " + result.getClass()); }
private Object checkResult(final Object result) { if (result == null) { return result; } if (result instanceof Float) { return ((Float) result).doubleValue(); } if ((result instanceof Integer) || (result instanceof Double) || (result instanceof Boolean) || (result instanceof String)) { return result; } if (result instanceof V8Value) { if (((V8Value) result).isReleased()) { throw new V8RuntimeException("V8Value already released"); } return result; } throw new V8RuntimeException("Unknown return type: " + result.getClass()); }