public final class V8Host
extends java.lang.Object
implements java.lang.AutoCloseable
Modifier and Type | Method and Description |
---|---|
void |
clearInternalStatistic()
Clear internal statistic for internal test purpose.
|
void |
close() |
void |
closeV8Runtime(V8Runtime v8Runtime)
Close V8 runtime.
|
<R extends V8Runtime> |
createV8Runtime()
Create V8 runtime.
|
<R extends V8Runtime> |
createV8Runtime(boolean pooled,
RuntimeOptions<?> runtimeOptions)
Create V8 runtime by pooled flag and custom global name.
|
<R extends V8Runtime> |
createV8Runtime(RuntimeOptions<?> runtimeOptions)
Create V8 runtime by custom global name.
|
V8Host |
disableGCNotification()
Disable GC notification.
|
V8Host |
enableGCNotification()
Enable GC notification.
|
static V8Host |
getInstance(JSRuntimeType jsRuntimeType)
Gets instance by JS runtime type.
|
long[] |
getInternalStatistic()
Get internal statistic for test purpose.
|
java.lang.String |
getJavetVersion()
Gets javet version.
|
JSRuntimeType |
getJSRuntimeType()
Gets JS runtime type.
|
JavetException |
getLastException()
Gets last exception.
|
IJavetLogger |
getLogger()
Gets logger.
|
static double |
getMemoryUsageThresholdRatio()
Gets memory usage threshold ratio.
|
static V8Host |
getNodeInstance()
Gets Node instance.
|
static V8Host |
getV8Instance()
Gets V8 instance.
|
int |
getV8RuntimeCount()
Gets V8 runtime count.
|
V8SharedMemoryStatistics |
getV8SharedMemoryStatistics()
Gets V8 shared memory statistics.
|
boolean |
isIsolateCreated()
Is isolate created.
|
boolean |
isLibraryLoaded()
Is library loaded.
|
static boolean |
isLibraryReloadable()
Determines whether the JNI library is reloadable or not.
|
boolean |
loadLibrary()
Load library.
|
static void |
setLibraryReloadable(boolean libraryReloadable)
Sets whether the JNI library is reloadable or not.
|
static void |
setMemoryUsageThresholdRatio(double memoryUsageThresholdRatio)
Sets memory usage threshold ratio.
|
boolean |
unloadLibrary()
Unload library.
|
public static V8Host getInstance(JSRuntimeType jsRuntimeType)
jsRuntimeType
- the JS runtime typepublic static double getMemoryUsageThresholdRatio()
public static V8Host getNodeInstance()
Note: Node runtime library is loaded by a custom class loader.
public static V8Host getV8Instance()
Note: V8 runtime library is loaded by a custom class loader.
public static boolean isLibraryReloadable()
public static void setLibraryReloadable(boolean libraryReloadable)
libraryReloadable
- true: reloadable, false: not reloadablepublic static void setMemoryUsageThresholdRatio(double memoryUsageThresholdRatio)
This manageable usage threshold attribute is designed for monitoring the increasing trend of memory usage with low overhead.
memoryUsageThresholdRatio
- the memory usage threshold ratiopublic void clearInternalStatistic()
public void close() throws JavetException
close
in interface java.lang.AutoCloseable
JavetException
public void closeV8Runtime(V8Runtime v8Runtime)
v8Runtime
- the V8 runtimepublic <R extends V8Runtime> R createV8Runtime() throws JavetException
R
- the type parameterJavetException
- the javet exceptionpublic <R extends V8Runtime> R createV8Runtime(RuntimeOptions<?> runtimeOptions) throws JavetException
R
- the type parameterruntimeOptions
- the runtime optionsJavetException
- the javet exceptionpublic <R extends V8Runtime> R createV8Runtime(boolean pooled, RuntimeOptions<?> runtimeOptions) throws JavetException
R
- the type parameterpooled
- the pooledruntimeOptions
- the runtime optionsJavetException
- the javet exceptionpublic V8Host disableGCNotification()
public V8Host enableGCNotification()
public long[] getInternalStatistic()
public JSRuntimeType getJSRuntimeType()
public java.lang.String getJavetVersion()
public JavetException getLastException()
public IJavetLogger getLogger()
public int getV8RuntimeCount()
public V8SharedMemoryStatistics getV8SharedMemoryStatistics()
public boolean isIsolateCreated()
public boolean isLibraryLoaded()
public boolean loadLibrary()
Note: setLibraryReloadable(true) must be called, otherwise, JVM will crash.
public boolean unloadLibrary()
Note: setLibraryReloadable(true) must be called, otherwise, JVM will crash.