public class V8Runtime extends java.lang.Object implements IJavetClosable, IV8Creatable, IV8Convertible
Javet simplifies the V8 runtime model to 1 runtime - 1 isolate - 1 context, though in V8 1 isolate can host multiple contexts.
V8 runtime exposes many useful methods and callbacks that allow low level interaction with the V8 isolate or context.
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
ERROR_BYTE_BUFFER_MUST_BE_DIRECT
The constant ERROR_BYTE_BUFFER_MUST_BE_DIRECT.
|
protected static java.lang.String |
ERROR_HANDLE_MUST_BE_VALID
The constant ERROR_HANDLE_MUST_BE_VALID.
|
protected static java.lang.String |
ERROR_SYMBOL_DESCRIPTION_CANNOT_BE_EMPTY
The constant ERROR_SYMBOL_DESCRIPTION_CANNOT_BE_EMPTY.
|
protected static java.lang.String |
ERROR_THE_KEY_VALUE_PAIR_MUST_MATCH
The constant ERROR_THE_KEY_VALUE_PAIR_MUST_MATCH.
|
protected static java.lang.String |
ERROR_THE_PROPERTY_NAME_MUST_BE_EITHER_STRING_OR_SYMBOL
The constant ERROR_THE_PROPERTY_NAME_MUST_BE_EITHER_STRING_OR_SYMBOL.
|
protected static java.lang.String |
ERROR_VALUE_CANNOT_BE_A_V_8_CONTEXT
The constant ERROR_VALUE_CANNOT_BE_A_V_8_CONTEXT.
|
protected static java.lang.String |
ERROR_VALUE_CANNOT_BE_A_V_8_MODULE
The constant ERROR_VALUE_CANNOT_BE_A_V_8_MODULE.
|
protected static java.lang.String |
ERROR_VALUE_CANNOT_BE_A_V_8_SCRIPT
The constant ERROR_VALUE_CANNOT_BE_A_V_8_SCRIPT.
|
Modifier and Type | Method and Description |
---|---|
void |
addGCEpilogueCallback(IJavetGCCallback iJavetGCCallback)
Add GC epilogue callback.
|
void |
addGCPrologueCallback(IJavetGCCallback iJavetGCCallback)
Add GC prologue callback.
|
void |
addV8Module(IV8Module iV8Module)
Add V8 module.
|
void |
allowEval(boolean allow)
Allow eval().
|
boolean |
await()
Await tells the V8 runtime to pump the message loop in a non-blocking manner.
|
boolean |
await(V8AwaitMode v8AwaitMode)
Await tells the V8 runtime to pump the message loop in a non-blocking manner.
|
void |
close() |
void |
close(boolean forceClose)
Close by a force close flag.
|
V8Module |
compileV8Module(java.lang.String scriptString,
byte[] cachedData,
V8ScriptOrigin v8ScriptOrigin,
boolean resultRequired)
Compile a V8 module and add that V8 module to the internal V8 module map.
|
V8Script |
compileV8Script(java.lang.String scriptString,
byte[] cachedData,
V8ScriptOrigin v8ScriptOrigin,
boolean resultRequired)
Compile a V8 script.
|
V8ValueFunction |
compileV8ValueFunction(java.lang.String scriptString,
byte[] cachedData,
V8ScriptOrigin v8ScriptOrigin,
java.lang.String[] arguments,
V8ValueObject[] contextExtensions)
Compile V8 value function.
|
boolean |
containsV8Module(java.lang.String resourceName)
Contains a V8 module by resource name.
|
byte[] |
createSnapshot()
Create snapshot in byte array.
|
V8Module |
createV8Module(java.lang.String moduleName,
IV8ValueObject iV8ValueObject)
Create a V8 synthetic module.
|
V8ValueArray |
createV8ValueArray()
Create V8 value array.
|
V8ValueArrayBuffer |
createV8ValueArrayBuffer(java.nio.ByteBuffer byteBuffer)
Create V8 value array buffer from a native byte buffer.
|
V8ValueArrayBuffer |
createV8ValueArrayBuffer(int length)
Create V8 value array buffer from a given length.
|
V8ValueBigInteger |
createV8ValueBigInteger(java.math.BigInteger bigInteger)
Create V8 value big integer.
|
V8ValueBigInteger |
createV8ValueBigInteger(java.lang.String bigIntegerValue)
Create V8 value big integer.
|
V8ValueBoolean |
createV8ValueBoolean(boolean booleanValue)
Create V8 value boolean.
|
V8ValueBooleanObject |
createV8ValueBooleanObject(boolean booleanValue)
Create V8 value boolean object.
|
V8ValueDataView |
createV8ValueDataView(V8ValueArrayBuffer v8ValueArrayBuffer)
Create V8 value data view.
|
V8ValueDouble |
createV8ValueDouble(double doubleValue)
Create V8 value double.
|
V8ValueDoubleObject |
createV8ValueDoubleObject(double doubleValue)
Create V8 value double object.
|
V8ValueError |
createV8ValueError(V8ValueErrorType v8ValueErrorType,
java.lang.String message)
Create V8 value error by type and message.
|
V8ValueFunction |
createV8ValueFunction(JavetCallbackContext javetCallbackContext)
Create V8 value function.
|
V8ValueFunction |
createV8ValueFunction(java.lang.String codeString)
Create V8 value function.
|
V8ValueInteger |
createV8ValueInteger(int integerValue)
Create V8 value integer.
|
V8ValueIntegerObject |
createV8ValueIntegerObject(int intValue)
Create V8 value int object.
|
V8ValueLong |
createV8ValueLong(long longValue)
Create V8 value long.
|
V8ValueLongObject |
createV8ValueLongObject(long longValue)
Create V8 value long object.
|
V8ValueMap |
createV8ValueMap()
Create V8 value map.
|
V8ValueNull |
createV8ValueNull()
Create V8 value null.
|
V8ValueObject |
createV8ValueObject()
Create V8 value object.
|
V8ValuePromise |
createV8ValuePromise()
Create V8 value promise.
|
V8ValueProxy |
createV8ValueProxy(V8Value v8Value)
Create V8 value proxy.
|
V8ValueSet |
createV8ValueSet()
Create V8 value set.
|
V8ValueString |
createV8ValueString(java.lang.String str)
Create V8 value string.
|
V8ValueStringObject |
createV8ValueStringObject(java.lang.String str)
Create V8 value string object from string.
|
V8ValueSymbol |
createV8ValueSymbol(java.lang.String description,
boolean global)
Create V8 value symbol.
|
V8ValueTypedArray |
createV8ValueTypedArray(V8ValueReferenceType type,
int length)
Create V8 value typed array.
|
V8ValueUndefined |
createV8ValueUndefined()
Create V8 value undefined.
|
V8ValueZonedDateTime |
createV8ValueZonedDateTime(long jsTimestamp)
Create V8 value zoned date time.
|
V8ValueZonedDateTime |
createV8ValueZonedDateTime(java.time.ZonedDateTime zonedDateTime)
Create V8 value zoned date time.
|
<T extends V8Value> |
execute(java.lang.String scriptString,
byte[] cachedData,
V8ScriptOrigin v8ScriptOrigin,
boolean resultRequired)
Execute a script or module.
|
JavetCallbackContext |
getCallbackContext(long handle)
Gets a callback context by a handle.
|
int |
getCallbackContextCount()
Gets callback context count.
|
IJavetConverter |
getConverter()
Gets converter.
|
IV8Executor |
getExecutor(java.io.File scriptFile)
Gets an executor by
File . |
IV8Executor |
getExecutor(java.nio.file.Path scriptPath)
Gets an executor by
Path . |
IV8Executor |
getExecutor(java.lang.String scriptString)
Gets an executor by a script string.
|
IV8Executor |
getExecutor(java.lang.String scriptString,
byte[] cachedData)
Gets executor by a script string and cached data.
|
V8ValueGlobalObject |
getGlobalObject()
Gets the global object.
|
V8Guard |
getGuard()
Gets guard.
|
V8Guard |
getGuard(long timoutMillis)
Gets guard.
|
V8Guard |
getGuard(long timoutMillis,
boolean debugModeEnabled)
Gets guard.
|
long |
getHandle()
Gets the internal handle that represents the current V8 runtime in JNI.
|
JSRuntimeType |
getJSRuntimeType()
Gets the JS runtime type.
|
IJavetLogger |
getLogger()
Gets the internal logger.
|
IJavetPromiseRejectCallback |
getPromiseRejectCallback()
Gets promise reject callback.
|
int |
getReferenceCount()
Gets the internal reference count.
|
RuntimeOptions<?> |
getRuntimeOptions()
Gets the runtime options.
|
java.util.concurrent.CompletableFuture<V8HeapSpaceStatistics> |
getV8HeapSpaceStatistics(V8AllocationSpace v8AllocationSpace)
Gets V8 heap space statistics by an allocation space via completable future.
|
java.util.concurrent.CompletableFuture<V8HeapStatistics> |
getV8HeapStatistics()
Gets V8 heap statistics via completable future.
|
V8Inspector |
getV8Inspector()
Gets V8 inspector.
|
V8Inspector |
getV8Inspector(java.lang.String name)
Gets V8 inspector by name.
|
V8Internal |
getV8Internal()
Gets V8 internal.
|
V8Locker |
getV8Locker()
Gets V8 locker.
|
int |
getV8ModuleCount()
Gets V8 module count.
|
IV8ModuleResolver |
getV8ModuleResolver()
Gets V8 module resolver.
|
V8Scope |
getV8Scope()
Gets V8 scope.
|
V8SharedMemoryStatistics |
getV8SharedMemoryStatistics()
Gets V8 shared memory statistics.
|
java.lang.String |
getVersion()
Gets the V8 version.
|
boolean |
hasException()
Has pending exception.
|
boolean |
hasPendingMessage()
Has pending message.
|
boolean |
isClosed()
Is closed.
|
boolean |
isDead()
Returns whether the V8 runtime is dead or not.
|
boolean |
isGCScheduled()
Returns whether the GC is scheduled or not.
|
boolean |
isInUse()
Returns whether the V8 runtime is in use or not.
|
boolean |
isPooled()
Returns whether the V8 runtime is managed by a pool or not.
|
void |
lowMemoryNotification()
Send low memory notification to current V8 isolate.
|
boolean |
objectIsFrozen(IV8ValueObject iV8ValueObject)
Object is frozen.
|
boolean |
objectIsSealed(IV8ValueObject iV8ValueObject)
Object is sealed.
|
void |
removeCallbackContext(long handle)
Remove a callback context by a handle.
|
void |
removeGCEpilogueCallback(IJavetGCCallback iJavetGCCallback)
Remove a GC epilogue callback.
|
void |
removeGCPrologueCallback(IJavetGCCallback iJavetGCCallback)
Remove a GC prologue callback.
|
void |
removeV8Module(IV8Module iV8Module)
Remove a V8 module.
|
void |
removeV8Module(IV8Module iV8Module,
boolean forceClose)
Remove a V8 module by a force close flag.
|
void |
removeV8Module(java.lang.String resourceName)
Remove a V8 module by a resource name.
|
void |
removeV8Module(java.lang.String resourceName,
boolean forceClose)
Remove a V8 module by a resource name and force close flag.
|
void |
removeV8Modules()
Remove all V8 modules.
|
void |
removeV8Modules(boolean forceClose)
Remove all V8 modules by a force close flag.
|
boolean |
reportPendingMessages()
Report pending messages.
|
void |
requestGarbageCollectionForTesting(boolean fullGC)
Requests GC for testing.
|
void |
resetContext()
Resets the V8 context.
|
void |
resetIsolate()
Resets the V8 isolate.
|
void |
setConverter(IJavetConverter converter)
Sets converter.
|
void |
setGCScheduled(boolean gcScheduled)
Sets GC scheduled.
|
void |
setLogger(IJavetLogger logger)
Sets logger.
|
void |
setPromiseRejectCallback(IJavetPromiseRejectCallback promiseRejectCallback)
Sets promise reject callback.
|
void |
setV8ModuleResolver(IV8ModuleResolver v8ModuleResolver)
Sets V8 module resolver.
|
void |
terminateExecution()
Terminate execution.
|
boolean |
throwError(java.lang.Object errorObject)
Throw error.
|
boolean |
throwError(V8Value errorV8Value)
Throw error.
|
boolean |
throwError(V8ValueErrorType v8ValueErrorType,
java.lang.String message)
Throw error.
|
<T,V extends V8Value> |
toObject(V v8Value)
Convert from V8 value to object.
|
<T,V extends V8Value> |
toV8Value(T object)
Convert object to V8 value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createV8ValueProxy, createV8ValueSymbol
toObject
protected static final java.lang.String ERROR_BYTE_BUFFER_MUST_BE_DIRECT
protected static final java.lang.String ERROR_HANDLE_MUST_BE_VALID
protected static final java.lang.String ERROR_SYMBOL_DESCRIPTION_CANNOT_BE_EMPTY
protected static final java.lang.String ERROR_THE_KEY_VALUE_PAIR_MUST_MATCH
protected static final java.lang.String ERROR_THE_PROPERTY_NAME_MUST_BE_EITHER_STRING_OR_SYMBOL
protected static final java.lang.String ERROR_VALUE_CANNOT_BE_A_V_8_CONTEXT
protected static final java.lang.String ERROR_VALUE_CANNOT_BE_A_V_8_MODULE
protected static final java.lang.String ERROR_VALUE_CANNOT_BE_A_V_8_SCRIPT
public void addGCEpilogueCallback(IJavetGCCallback iJavetGCCallback)
iJavetGCCallback
- the javet GC callbackpublic void addGCPrologueCallback(IJavetGCCallback iJavetGCCallback)
iJavetGCCallback
- the javet GC callbackpublic void addV8Module(IV8Module iV8Module) throws JavetException
iV8Module
- the V8 moduleJavetException
- the javet exceptionpublic void allowEval(boolean allow)
allow
- true : allow eval(), false : disallow eval()public boolean await()
public boolean await(V8AwaitMode v8AwaitMode)
In the Node.js mode, the V8 await mode takes effect. In the V8 mode, the V8 await mode takes no effect and the return is always false.
v8AwaitMode
- the V8 await modepublic void close() throws JavetException
close
in interface IJavetClosable
close
in interface java.lang.AutoCloseable
JavetException
public void close(boolean forceClose) throws JavetException
forceClose
- the force closeJavetException
- the javet exception@CheckReturnValue public V8Module compileV8Module(java.lang.String scriptString, byte[] cachedData, V8ScriptOrigin v8ScriptOrigin, boolean resultRequired) throws JavetException
scriptString
- the script stringcachedData
- the cached datav8ScriptOrigin
- the V8 script originresultRequired
- the result requiredJavetException
- the javet exception@CheckReturnValue public V8Script compileV8Script(java.lang.String scriptString, byte[] cachedData, V8ScriptOrigin v8ScriptOrigin, boolean resultRequired) throws JavetException
scriptString
- the script stringcachedData
- the cached datav8ScriptOrigin
- the V8 script originresultRequired
- the result requiredJavetException
- the javet exception@CheckReturnValue public V8ValueFunction compileV8ValueFunction(java.lang.String scriptString, byte[] cachedData, V8ScriptOrigin v8ScriptOrigin, java.lang.String[] arguments, V8ValueObject[] contextExtensions) throws JavetException
scriptString
- the script stringcachedData
- the cached datav8ScriptOrigin
- the V8 script originarguments
- the argumentscontextExtensions
- the context extensionsJavetException
- the javet exceptionpublic boolean containsV8Module(java.lang.String resourceName)
resourceName
- the resource namepublic byte[] createSnapshot() throws JavetException
JavetException
- the javet exception@CheckReturnValue public V8Module createV8Module(java.lang.String moduleName, IV8ValueObject iV8ValueObject) throws JavetException
IV8Creatable
createV8Module
in interface IV8Creatable
moduleName
- the module nameiV8ValueObject
- the V8 value object to be exportedJavetException
- the javet exception@CheckReturnValue public V8ValueArray createV8ValueArray() throws JavetException
IV8Creatable
createV8ValueArray
in interface IV8Creatable
JavetException
- the javet exception@CheckReturnValue public V8ValueArrayBuffer createV8ValueArrayBuffer(int length) throws JavetException
IV8Creatable
createV8ValueArrayBuffer
in interface IV8Creatable
length
- the lengthJavetException
- the javet exception@CheckReturnValue public V8ValueArrayBuffer createV8ValueArrayBuffer(java.nio.ByteBuffer byteBuffer) throws JavetException
IV8Creatable
createV8ValueArrayBuffer
in interface IV8Creatable
byteBuffer
- the byte bufferJavetException
- the javet exceptionpublic V8ValueBigInteger createV8ValueBigInteger(java.math.BigInteger bigInteger) throws JavetException
IV8Creatable
createV8ValueBigInteger
in interface IV8Creatable
bigInteger
- the big integerJavetException
- the javet exceptionpublic V8ValueBigInteger createV8ValueBigInteger(java.lang.String bigIntegerValue) throws JavetException
IV8Creatable
createV8ValueBigInteger
in interface IV8Creatable
bigIntegerValue
- the big integer valueJavetException
- the javet exceptionpublic V8ValueBoolean createV8ValueBoolean(boolean booleanValue) throws JavetException
IV8Creatable
createV8ValueBoolean
in interface IV8Creatable
booleanValue
- the boolean valueJavetException
- the javet exceptionpublic V8ValueBooleanObject createV8ValueBooleanObject(boolean booleanValue) throws JavetException
IV8Creatable
createV8ValueBooleanObject
in interface IV8Creatable
booleanValue
- the boolean valueJavetException
- the javet exception@CheckReturnValue public V8ValueDataView createV8ValueDataView(V8ValueArrayBuffer v8ValueArrayBuffer) throws JavetException
IV8Creatable
createV8ValueDataView
in interface IV8Creatable
v8ValueArrayBuffer
- the V8 value array bufferJavetException
- the javet exceptionpublic V8ValueDouble createV8ValueDouble(double doubleValue) throws JavetException
IV8Creatable
createV8ValueDouble
in interface IV8Creatable
doubleValue
- the double valueJavetException
- the javet exceptionpublic V8ValueDoubleObject createV8ValueDoubleObject(double doubleValue) throws JavetException
IV8Creatable
createV8ValueDoubleObject
in interface IV8Creatable
doubleValue
- the double valueJavetException
- the javet exception@CheckReturnValue public V8ValueError createV8ValueError(V8ValueErrorType v8ValueErrorType, java.lang.String message) throws JavetException
IV8Creatable
createV8ValueError
in interface IV8Creatable
v8ValueErrorType
- the V8 value error typemessage
- the messageJavetException
- the javet exception@CheckReturnValue public V8ValueFunction createV8ValueFunction(JavetCallbackContext javetCallbackContext) throws JavetException
IV8Creatable
createV8ValueFunction
in interface IV8Creatable
javetCallbackContext
- the javet callback contextJavetException
- the javet exception@CheckReturnValue public V8ValueFunction createV8ValueFunction(java.lang.String codeString) throws JavetException
IV8Creatable
createV8ValueFunction
in interface IV8Creatable
codeString
- the code stringJavetException
- the javet exceptionpublic V8ValueInteger createV8ValueInteger(int integerValue) throws JavetException
IV8Creatable
createV8ValueInteger
in interface IV8Creatable
integerValue
- the integer valueJavetException
- the javet exceptionpublic V8ValueIntegerObject createV8ValueIntegerObject(int intValue) throws JavetException
IV8Creatable
createV8ValueIntegerObject
in interface IV8Creatable
intValue
- the int valueJavetException
- the javet exceptionpublic V8ValueLong createV8ValueLong(long longValue) throws JavetException
IV8Creatable
createV8ValueLong
in interface IV8Creatable
longValue
- the long valueJavetException
- the javet exceptionpublic V8ValueLongObject createV8ValueLongObject(long longValue) throws JavetException
IV8Creatable
createV8ValueLongObject
in interface IV8Creatable
longValue
- the long valueJavetException
- the javet exception@CheckReturnValue public V8ValueMap createV8ValueMap() throws JavetException
IV8Creatable
createV8ValueMap
in interface IV8Creatable
JavetException
- the javet exceptionpublic V8ValueNull createV8ValueNull()
IV8Creatable
createV8ValueNull
in interface IV8Creatable
@CheckReturnValue public V8ValueObject createV8ValueObject() throws JavetException
IV8Creatable
createV8ValueObject
in interface IV8Creatable
JavetException
- the javet exception@CheckReturnValue public V8ValuePromise createV8ValuePromise() throws JavetException
IV8Creatable
createV8ValuePromise
in interface IV8Creatable
JavetException
- the javet exception@CheckReturnValue public V8ValueProxy createV8ValueProxy(V8Value v8Value) throws JavetException
IV8Creatable
createV8ValueProxy
in interface IV8Creatable
v8Value
- the V8 valueJavetException
- the javet exception@CheckReturnValue public V8ValueSet createV8ValueSet() throws JavetException
IV8Creatable
createV8ValueSet
in interface IV8Creatable
JavetException
- the javet exceptionpublic V8ValueString createV8ValueString(java.lang.String str) throws JavetException
IV8Creatable
createV8ValueString
in interface IV8Creatable
str
- the strJavetException
- the javet exception@CheckReturnValue public V8ValueStringObject createV8ValueStringObject(java.lang.String str) throws JavetException
IV8Creatable
createV8ValueStringObject
in interface IV8Creatable
str
- the strJavetException
- the javet exception@CheckReturnValue public V8ValueSymbol createV8ValueSymbol(java.lang.String description, boolean global) throws JavetException
IV8Creatable
createV8ValueSymbol
in interface IV8Creatable
description
- the descriptionglobal
- the globalJavetException
- the javet exception@CheckReturnValue public V8ValueTypedArray createV8ValueTypedArray(V8ValueReferenceType type, int length) throws JavetException
IV8Creatable
createV8ValueTypedArray
in interface IV8Creatable
type
- the typelength
- the lengthJavetException
- the javet exceptionpublic V8ValueUndefined createV8ValueUndefined()
IV8Creatable
createV8ValueUndefined
in interface IV8Creatable
public V8ValueZonedDateTime createV8ValueZonedDateTime(long jsTimestamp) throws JavetException
IV8Creatable
createV8ValueZonedDateTime
in interface IV8Creatable
jsTimestamp
- the js timestampJavetException
- the javet exceptionpublic V8ValueZonedDateTime createV8ValueZonedDateTime(java.time.ZonedDateTime zonedDateTime) throws JavetException
IV8Creatable
createV8ValueZonedDateTime
in interface IV8Creatable
zonedDateTime
- the zoned date timeJavetException
- the javet exception@CheckReturnValue public <T extends V8Value> T execute(java.lang.String scriptString, byte[] cachedData, V8ScriptOrigin v8ScriptOrigin, boolean resultRequired) throws JavetException
T
- the type parameterscriptString
- the script stringcachedData
- the cached datav8ScriptOrigin
- the V8 script originresultRequired
- the result requiredJavetException
- the javet exceptionpublic JavetCallbackContext getCallbackContext(long handle)
handle
- the handlepublic int getCallbackContextCount()
public IJavetConverter getConverter()
public IV8Executor getExecutor(java.io.File scriptFile) throws JavetException
File
.scriptFile
- the script fileJavetException
- the javet exceptionpublic IV8Executor getExecutor(java.nio.file.Path scriptPath) throws JavetException
Path
.scriptPath
- the script pathJavetException
- the javet exceptionpublic IV8Executor getExecutor(java.lang.String scriptString)
scriptString
- the script stringpublic IV8Executor getExecutor(java.lang.String scriptString, byte[] cachedData)
scriptString
- the script stringcachedData
- the cached datapublic V8ValueGlobalObject getGlobalObject() throws JavetException
globalThis
.JavetException
- the javet exception@CheckReturnValue public V8Guard getGuard()
@CheckReturnValue public V8Guard getGuard(long timoutMillis)
timoutMillis
- the timout millis@CheckReturnValue public V8Guard getGuard(long timoutMillis, boolean debugModeEnabled)
timoutMillis
- the timout millisdebugModeEnabled
- the debug mode enabledpublic long getHandle()
public JSRuntimeType getJSRuntimeType()
public IJavetLogger getLogger()
public IJavetPromiseRejectCallback getPromiseRejectCallback()
public int getReferenceCount()
public RuntimeOptions<?> getRuntimeOptions()
public java.util.concurrent.CompletableFuture<V8HeapSpaceStatistics> getV8HeapSpaceStatistics(V8AllocationSpace v8AllocationSpace)
v8AllocationSpace
- the V8 allocation spacepublic java.util.concurrent.CompletableFuture<V8HeapStatistics> getV8HeapStatistics()
public V8Inspector getV8Inspector()
public V8Inspector getV8Inspector(java.lang.String name)
name
- the namepublic V8Internal getV8Internal()
@CheckReturnValue public V8Locker getV8Locker() throws JavetException
The V8 locker is for maximizing the performance by explicitly acquire and release the lock. It should not be called in regular case because V8 runtime is thread-safe.
JavetException
- the javet exceptionpublic int getV8ModuleCount()
public IV8ModuleResolver getV8ModuleResolver()
public V8Scope getV8Scope()
public V8SharedMemoryStatistics getV8SharedMemoryStatistics()
public java.lang.String getVersion()
public boolean hasException() throws JavetException
JavetException
- the javet exceptionpublic boolean hasPendingMessage() throws JavetException
JavetException
- the javet exceptionpublic boolean isClosed()
IJavetClosable
isClosed
in interface IJavetClosable
public boolean isDead()
public boolean isGCScheduled()
public boolean isInUse()
public boolean isPooled()
public void lowMemoryNotification()
public boolean objectIsFrozen(IV8ValueObject iV8ValueObject)
iV8ValueObject
- the V8 value objectpublic boolean objectIsSealed(IV8ValueObject iV8ValueObject)
iV8ValueObject
- the V8 value objectpublic void removeCallbackContext(long handle)
handle
- the handlepublic void removeGCEpilogueCallback(IJavetGCCallback iJavetGCCallback)
iJavetGCCallback
- the javet GC callbackpublic void removeGCPrologueCallback(IJavetGCCallback iJavetGCCallback)
iJavetGCCallback
- the javet GC callbackpublic void removeV8Module(java.lang.String resourceName, boolean forceClose) throws JavetException
resourceName
- the resource nameforceClose
- the force closeJavetException
- the javet exceptionpublic void removeV8Module(java.lang.String resourceName) throws JavetException
resourceName
- the resource nameJavetException
- the javet exceptionpublic void removeV8Module(IV8Module iV8Module) throws JavetException
iV8Module
- the V8 moduleJavetException
- the javet exceptionpublic void removeV8Module(IV8Module iV8Module, boolean forceClose) throws JavetException
iV8Module
- the V8 moduleforceClose
- the force closeJavetException
- the javet exceptionpublic void removeV8Modules() throws JavetException
JavetException
- the javet exceptionpublic void removeV8Modules(boolean forceClose) throws JavetException
forceClose
- the force closeJavetException
- the javet exceptionpublic boolean reportPendingMessages() throws JavetException
JavetException
- the javet exceptionpublic void requestGarbageCollectionForTesting(boolean fullGC)
fullGC
- true : Full GC, false : Minor GCpublic void resetContext() throws JavetException
This is a light-weight and recommended reset.
JavetException
- the javet exceptionpublic void resetIsolate() throws JavetException
This is a heavy reset. Please avoid using it in performance sensitive scenario.
JavetException
- the javet exceptionpublic void setConverter(IJavetConverter converter)
converter
- the converterpublic void setGCScheduled(boolean gcScheduled)
gcScheduled
- the GC scheduledpublic void setLogger(IJavetLogger logger)
logger
- the loggerpublic void setPromiseRejectCallback(IJavetPromiseRejectCallback promiseRejectCallback)
promiseRejectCallback
- the promise reject callbackpublic void setV8ModuleResolver(IV8ModuleResolver v8ModuleResolver)
v8ModuleResolver
- the V8 module resolverpublic void terminateExecution()
Forcefully terminate the current thread of JavaScript execution in the given isolate.
This method can be used by any thread even if that thread has not acquired the V8 lock with a Locker object.
public boolean throwError(V8ValueErrorType v8ValueErrorType, java.lang.String message)
v8ValueErrorType
- the V8 value error typemessage
- the messagepublic boolean throwError(java.lang.Object errorObject) throws JavetException
errorObject
- the error objectJavetException
- the javet exceptionpublic boolean throwError(V8Value errorV8Value)
errorV8Value
- the error v 8 valuepublic <T,V extends V8Value> T toObject(V v8Value) throws JavetException
IV8Convertible
toObject
in interface IV8Convertible
T
- the type parameterV
- the type parameterv8Value
- the V8 valueJavetException
- the javet exception@CheckReturnValue public <T,V extends V8Value> V toV8Value(T object) throws JavetException
IV8Convertible
toV8Value
in interface IV8Convertible
T
- the type parameterV
- the type parameterobject
- the objectJavetException
- the javet exception