diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml index d058fad20..64b16b804 100644 --- a/.github/workflows/android_build.yml +++ b/.github/workflows/android_build.yml @@ -8,9 +8,9 @@ on: workflow_dispatch: env: - JAVET_NODE_VERSION: 20.10.0 - JAVET_V8_VERSION: 12.0.267.8 - JAVET_VERSION: 3.0.2 + JAVET_NODE_VERSION: 20.11.0 + JAVET_V8_VERSION: 12.1.285.26 + JAVET_VERSION: 3.0.3 ROOT: /home/runner/work/Javet jobs: @@ -61,6 +61,8 @@ jobs: gclient sync -D cd v8 python3 tools/dev/v8gen.py arm.release -- 'target_os="android"' 'target_cpu="arm"' 'v8_target_cpu="arm"' v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + sed -i 's/char\[\]/char/g' src/wasm/wasm-engine.cc + sed -i 's/source_url_ = String::cast(script->name())->ToCString();/std::unique_ptr source_url = String::cast(script->name())->ToCString(); source_url_ = {source_url.release(), source_url.get_deleter()};/' src/wasm/wasm-engine.cc ninja -C out.gn/arm.release v8_monolith || python3 ${{ env.ROOT }}/Javet/scripts/python/patch_v8_build.py -p ./ ninja -C out.gn/arm.release v8_monolith @@ -133,6 +135,8 @@ jobs: gclient sync -D cd v8 python3 tools/dev/v8gen.py arm64.release -- 'target_os="android"' 'target_cpu="arm64"' 'v8_target_cpu="arm64"' v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + sed -i 's/char\[\]/char/g' src/wasm/wasm-engine.cc + sed -i 's/source_url_ = String::cast(script->name())->ToCString();/std::unique_ptr source_url = String::cast(script->name())->ToCString(); source_url_ = {source_url.release(), source_url.get_deleter()};/' src/wasm/wasm-engine.cc ninja -C out.gn/arm64.release v8_monolith || python3 ${{ env.ROOT }}/Javet/scripts/python/patch_v8_build.py -p ./ ninja -C out.gn/arm64.release v8_monolith @@ -205,6 +209,8 @@ jobs: gclient sync -D cd v8 python3 tools/dev/v8gen.py ia32.release -- 'target_os="android"' 'target_cpu="x86"' 'v8_target_cpu="x86"' v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + sed -i 's/char\[\]/char/g' src/wasm/wasm-engine.cc + sed -i 's/source_url_ = String::cast(script->name())->ToCString();/std::unique_ptr source_url = String::cast(script->name())->ToCString(); source_url_ = {source_url.release(), source_url.get_deleter()};/' src/wasm/wasm-engine.cc ninja -C out.gn/ia32.release v8_monolith || python3 ${{ env.ROOT }}/Javet/scripts/python/patch_v8_build.py -p ./ ninja -C out.gn/ia32.release v8_monolith @@ -277,6 +283,8 @@ jobs: gclient sync -D cd v8 python3 tools/dev/v8gen.py x64.release -- 'target_os="android"' 'target_cpu="x64"' 'v8_target_cpu="x64"' v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + sed -i 's/char\[\]/char/g' src/wasm/wasm-engine.cc + sed -i 's/source_url_ = String::cast(script->name())->ToCString();/std::unique_ptr source_url = String::cast(script->name())->ToCString(); source_url_ = {source_url.release(), source_url.get_deleter()};/' src/wasm/wasm-engine.cc ninja -C out.gn/x64.release v8_monolith || python3 ${{ env.ROOT }}/Javet/scripts/python/patch_v8_build.py -p ./ ninja -C out.gn/x64.release v8_monolith diff --git a/.github/workflows/linux_build_artifact.yml b/.github/workflows/linux_build_artifact.yml index dbfba65fd..03e7480e4 100644 --- a/.github/workflows/linux_build_artifact.yml +++ b/.github/workflows/linux_build_artifact.yml @@ -17,9 +17,9 @@ on: env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_REPO_JAVET: ${{ secrets.DOCKERHUB_REPO_JAVET }} - JAVET_NODE_VERSION: 20.10.0 - JAVET_V8_VERSION: 12.0.267.8 - JAVET_VERSION: 3.0.2 + JAVET_NODE_VERSION: 20.11.0 + JAVET_V8_VERSION: 12.1.285.26 + JAVET_VERSION: 3.0.3 jobs: javet_linux_x86_64: diff --git a/.github/workflows/linux_build_node_v8_image.yml b/.github/workflows/linux_build_node_v8_image.yml index a96709b29..0c0f8c2b0 100644 --- a/.github/workflows/linux_build_node_v8_image.yml +++ b/.github/workflows/linux_build_node_v8_image.yml @@ -21,9 +21,9 @@ on: env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_REPO_JAVET: ${{ secrets.DOCKERHUB_REPO_JAVET }} - JAVET_NODE_VERSION: 20.10.0 - JAVET_V8_VERSION: 12.0.267.8 - JAVET_VERSION: 3.0.2 + JAVET_NODE_VERSION: 20.11.0 + JAVET_V8_VERSION: 12.1.285.26 + JAVET_VERSION: 3.0.3 # if we skip a job using a job level `if` condition, then any dependent jobs also don't run. # we can skip a step of the job, using a step level `if` condition. diff --git a/.github/workflows/linux_x86_64_build.yml b/.github/workflows/linux_x86_64_build.yml index cb1b50802..cc87aabb1 100644 --- a/.github/workflows/linux_x86_64_build.yml +++ b/.github/workflows/linux_x86_64_build.yml @@ -7,9 +7,9 @@ on: workflow_dispatch: env: - JAVET_NODE_VERSION: 20.10.0 - JAVET_V8_VERSION: 12.0.267.8 - JAVET_VERSION: 3.0.2 + JAVET_NODE_VERSION: 20.11.0 + JAVET_V8_VERSION: 12.1.285.26 + JAVET_VERSION: 3.0.3 ROOT: /home/runner/work/Javet jobs: @@ -52,6 +52,8 @@ jobs: gclient sync -D cd v8 python3 tools/dev/v8gen.py x64.release -- v8_monolithic=true v8_use_external_startup_data=false is_component_build=false v8_enable_i18n_support=false v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + sed -i '/#include "src\/libplatform\//a #include ' src/libplatform/default-thread-isolated-allocator.cc + sed -i '/bool KernelHasPkruFix()/a const char* env = std::getenv("JAVET_DISABLE_PKU"); if (env && std::strlen(env) > 0) { return false; }' src/libplatform/default-thread-isolated-allocator.cc ninja -C out.gn/x64.release v8_monolith || python3 ${{ env.ROOT }}/Javet/scripts/python/patch_v8_build.py -p ./ ninja -C out.gn/x64.release v8_monolith @@ -168,12 +170,20 @@ jobs: gradle build test --rerun-tasks --debug touch src/main/resources/libjavet-node* gradle test --rerun-tasks --debug + gradle build generatePomFileForGeneratePomPublication + + - name: Clear up Source Jar + uses: edgarrc/action-7z@v1 + with: + args: 7z d build/libs/javet-${{ env.JAVET_VERSION }}-sources.jar *.so - name: Upload the Artifact uses: actions/upload-artifact@v3 with: name: javet-linux-x86_64-${{ env.JAVET_VERSION }} - path: build/libs/*.jar + path: | + build/libs/*.jar + build/libs/*.pom - name: Delete Javet V8 uses: geekyeggo/delete-artifact@v2 diff --git a/.github/workflows/macos_arm64_build.yml b/.github/workflows/macos_arm64_build.yml index 0b4ac4a8f..9bd4f0a9d 100644 --- a/.github/workflows/macos_arm64_build.yml +++ b/.github/workflows/macos_arm64_build.yml @@ -9,7 +9,7 @@ on: env: JAVET_NODE_VERSION: 11.8.172.15 JAVET_V8_VERSION: 11.8.172.15 - JAVET_VERSION: 3.0.2 + JAVET_VERSION: 3.0.3 ROOT: /Users/runner/work/Javet jobs: @@ -163,12 +163,16 @@ jobs: gradle build test --rerun-tasks --debug touch src/main/resources/libjavet-node* gradle test --rerun-tasks --debug + gradle build generatePomFileForGeneratePomPublication + zip -d build/libs/javet-${{ env.JAVET_VERSION }}-sources.jar *.dylib - name: Upload the Artifact uses: actions/upload-artifact@v3 with: name: javet-macos-arm64-${{ env.JAVET_VERSION }} - path: build/libs/*.jar + path: | + build/libs/*.jar + build/libs/*.pom - name: Delete Javet V8 uses: geekyeggo/delete-artifact@v2 diff --git a/.github/workflows/macos_x86_64_build.yml b/.github/workflows/macos_x86_64_build.yml index ef4d35f40..1c2164217 100644 --- a/.github/workflows/macos_x86_64_build.yml +++ b/.github/workflows/macos_x86_64_build.yml @@ -7,9 +7,9 @@ on: workflow_dispatch: env: - JAVET_NODE_VERSION: 20.10.0 - JAVET_V8_VERSION: 12.0.267.8 - JAVET_VERSION: 3.0.2 + JAVET_NODE_VERSION: 20.11.0 + JAVET_V8_VERSION: 12.1.285.26 + JAVET_VERSION: 3.0.3 ROOT: /Users/runner/work/Javet jobs: @@ -163,12 +163,16 @@ jobs: gradle build test --rerun-tasks --debug touch src/main/resources/libjavet-node* gradle test --rerun-tasks --debug + gradle build generatePomFileForGeneratePomPublication + zip -d build/libs/javet-${{ env.JAVET_VERSION }}-sources.jar *.dylib - name: Upload the Artifact uses: actions/upload-artifact@v3 with: name: javet-macos-x86_64-${{ env.JAVET_VERSION }} - path: build/libs/*.jar + path: | + build/libs/*.jar + build/libs/*.pom - name: Delete Javet V8 uses: geekyeggo/delete-artifact@v2 diff --git a/README.rst b/README.rst index 51f213c29..d67694efb 100644 --- a/README.rst +++ b/README.rst @@ -41,7 +41,7 @@ arm ✔️ ❌ ❌ ❌ arm64 ✔️ ✔️ ✔️ ❌ =========== ======= ======= ======= ======= -* Node.js ``v20.10.0`` + V8 ``v12.0.267.8`` +* Node.js ``v20.11.0`` + V8 ``v12.1.285.26`` * Dynamic switch between Node.js and V8 mode (`Which mode do you prefer? `_) * Polyfill V8 mode with `Javenode `_ * V8 API exposure in JVM @@ -50,7 +50,8 @@ arm64 ✔️ ✔️ ✔️ ❌ * Javet engine pool * Easy spring integration * Live debug with Chrome DevTools -* AST Analysis with `JavetSanitizer `_ +* AST analysis with `JavetSanitizer `_ +* Live interaction with `JavetShell `_ Quick Start =========== @@ -67,21 +68,21 @@ Maven com.caoccao.javet javet - 3.0.2 + 3.0.3 com.caoccao.javet javet-linux-arm64 - 3.0.2 + 3.0.3 com.caoccao.javet javet-macos - 3.0.2 + 3.0.3 Gradle Kotlin DSL @@ -89,20 +90,20 @@ Gradle Kotlin DSL .. code-block:: kotlin - implementation("com.caoccao.javet:javet:3.0.2") // Linux and Windows (x86_64) - implementation("com.caoccao.javet:javet-linux-arm64:3.0.2") // Linux (arm64) - implementation("com.caoccao.javet:javet-macos:3.0.2") // Mac OS (x86_64 and arm64) - implementation("com.caoccao.javet:javet-android:3.0.2") // Android (arm, arm64, x86 and x86_64) + implementation("com.caoccao.javet:javet:3.0.3") // Linux and Windows (x86_64) + implementation("com.caoccao.javet:javet-linux-arm64:3.0.3") // Linux (arm64) + implementation("com.caoccao.javet:javet-macos:3.0.3") // Mac OS (x86_64 and arm64) + implementation("com.caoccao.javet:javet-android:3.0.3") // Android (arm, arm64, x86 and x86_64) Gradle Groovy DSL ^^^^^^^^^^^^^^^^^ .. code-block:: groovy - implementation 'com.caoccao.javet:javet:3.0.2' // Linux and Windows (x86_64) - implementation 'com.caoccao.javet:javet-linux-arm64:3.0.2' // Linux (arm64) - implementation 'com.caoccao.javet:javet-macos:3.0.2' // Mac OS (x86_64 and arm64) - implementation 'com.caoccao.javet:javet-android:3.0.2' // Android (arm, arm64, x86 and x86_64) + implementation 'com.caoccao.javet:javet:3.0.3' // Linux and Windows (x86_64) + implementation 'com.caoccao.javet:javet-linux-arm64:3.0.3' // Linux (arm64) + implementation 'com.caoccao.javet:javet-macos:3.0.3' // Mac OS (x86_64 and arm64) + implementation 'com.caoccao.javet:javet-android:3.0.3' // Android (arm, arm64, x86 and x86_64) Hello Javet ----------- diff --git a/android/build.gradle.kts b/android/build.gradle.kts index 0dccbae8e..d8babea5e 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2021. caoccao.com Sam Cao + * Copyright 2021-2023. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,8 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:8.0.0") + // https://developer.android.com/build/releases/gradle-plugin + classpath("com.android.tools.build:gradle:8.1.0") } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index ce9b32bfb..bb94f7641 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Oct 21 08:49:28 CST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/android/javet-android/build.gradle.kts b/android/javet-android/build.gradle.kts index 54680df69..82624f537 100644 --- a/android/javet-android/build.gradle.kts +++ b/android/javet-android/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2021. caoccao.com Sam Cao + * Copyright 2021-2023. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,19 +17,80 @@ import org.apache.tools.ant.taskdefs.condition.Os +object Config { + const val GROUP_ID = "com.caoccao.javet" + const val NAME = "Javet Android" + const val VERSION = Versions.JAVET + const val URL = "https://github.com/caoccao/Javet" + + object Pom { + const val ARTIFACT_ID = "javet-android" + const val DESCRIPTION = + "Javet is Java + V8 (JAVa + V + EighT). It is an awesome way of embedding Node.js and V8 in Java." + + object Developer { + const val ID = "caoccao" + const val EMAIL = "sjtucaocao@gmail.com" + const val NAME = "Sam Cao" + const val ORGANIZATION = "caoccao.com" + const val ORGANIZATION_URL = "https://www.caoccao.com" + } + + object License { + const val NAME = "APACHE LICENSE, VERSION 2.0" + const val URL = "https://github.com/caoccao/Javet/blob/main/LICENSE" + } + + object Scm { + const val CONNECTION = "scm:git:git://github.com/Javet.git" + const val DEVELOPER_CONNECTION = "scm:git:ssh://github.com/Javet.git" + } + } + + object Projects { + // https://androidx.tech/artifacts/test.ext/junit + const val ANDROIDX_ESPRESSO_CORE = "androidx.test.espresso:espresso-core:${Versions.ANDROIDX_ESPRESSO_CORE}" + + // https://androidx.tech/artifacts/test.espresso/espresso-core/ + const val ANDROIDX_TEST = "androidx.test.ext:junit:${Versions.ANDROIDX_TEST}" + + // https://mvnrepository.com/artifact/androidx.appcompat/appcompat + const val APPCOMPAT = "androidx.appcompat:appcompat:${Versions.APPCOMPAT}" + + // https://developer.android.com/studio/write/java8-support + // https://mvnrepository.com/artifact/com.android.tools/desugar_jdk_libs + const val DESUGAR_JDK_LIBS = "com.android.tools:desugar_jdk_libs:${Versions.DESUGAR_JDK_LIBS}" + + // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api + const val JUNIT_JUPITER_API = "org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}" + + // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine + const val JUNIT_JUPITER_ENGINE = "org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}" + } + + object Versions { + const val ANDROIDX_ESPRESSO_CORE = "3.5.1" + const val ANDROIDX_TEST = "1.1.5" + const val APPCOMPAT = "1.3.1" + const val DESUGAR_JDK_LIBS = "2.0.4" + const val JAVET = "3.0.3" + const val JUNIT = "5.10.1" + } +} + plugins { id("com.android.library") } -version = "3.0.2" +group = Config.GROUP_ID +version = Config.VERSION android { compileSdk = 30 - namespace = "com.caoccao.javet" + namespace = Config.GROUP_ID defaultConfig { minSdk = 24 - targetSdk = 30 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") @@ -47,7 +108,7 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } - lintOptions.isAbortOnError = false + lint.abortOnError = false sourceSets { getByName("main") { @@ -58,12 +119,12 @@ android { } dependencies { - // https://developer.android.com/studio/write/java8-support - coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5") - implementation("androidx.appcompat:appcompat:1.3.1") - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + coreLibraryDesugaring(Config.Projects.DESUGAR_JDK_LIBS) + implementation(Config.Projects.APPCOMPAT) + testImplementation(Config.Projects.JUNIT_JUPITER_API) + testRuntimeOnly(Config.Projects.JUNIT_JUPITER_ENGINE) + androidTestImplementation(Config.Projects.ANDROIDX_ESPRESSO_CORE) + androidTestImplementation(Config.Projects.ANDROIDX_TEST) } tasks.register(name = "sourceJar") { @@ -71,7 +132,6 @@ tasks.register(name = "sourceJar") { archiveClassifier.set("sources") } - task("syncSourceCode") { project.exec { workingDir("$projectDir/../../scripts/python") diff --git a/android/javet-android/src/main/AndroidManifest.xml b/android/javet-android/src/main/AndroidManifest.xml index 540cbd958..e1281197c 100644 --- a/android/javet-android/src/main/AndroidManifest.xml +++ b/android/javet-android/src/main/AndroidManifest.xml @@ -1,8 +1,7 @@ \ No newline at end of file diff --git a/android/javet-android/src/test/java/com/caoccao/javet/TestDummy.java b/android/javet-android/src/test/java/com/caoccao/javet/TestDummy.java index 3dc3d05f7..014fd63e7 100644 --- a/android/javet-android/src/test/java/com/caoccao/javet/TestDummy.java +++ b/android/javet-android/src/test/java/com/caoccao/javet/TestDummy.java @@ -17,9 +17,9 @@ package com.caoccao.javet; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * Example local unit test, which will execute on the development machine (host). diff --git a/android/pom.xml b/android/pom.xml index 0b26e0648..c5131f544 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -3,7 +3,7 @@ com.caoccao.javet javet-android - 3.0.2 + 3.0.3 javet aar Javet is Java + V8 (JAVa + V + EighT). It is an awesome way of embedding V8 in Java. @@ -29,7 +29,7 @@ scm:git:git://github.com/caoccao/Javet.git scm:git:git@github.com:caoccao/caoccao.git https://github.com/caoccao/Javet - 3.0.2 + 3.0.3 diff --git a/build.gradle.kts b/build.gradle.kts index 57963576f..20789868f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,37 +14,100 @@ * limitations under the License. */ +object Config { + const val GROUP_ID = "com.caoccao.javet" + const val NAME = "Javet" + const val VERSION = Versions.JAVET + const val URL = "https://github.com/caoccao/Javet" + + object Pom { + const val ARTIFACT_ID = "javet" + const val DESCRIPTION = + "Javet is Java + V8 (JAVa + V + EighT). It is an awesome way of embedding Node.js and V8 in Java." + + object Developer { + const val ID = "caoccao" + const val EMAIL = "sjtucaocao@gmail.com" + const val NAME = "Sam Cao" + const val ORGANIZATION = "caoccao.com" + const val ORGANIZATION_URL = "https://www.caoccao.com" + } + + object License { + const val NAME = "APACHE LICENSE, VERSION 2.0" + const val URL = "https://github.com/caoccao/Javet/blob/main/LICENSE" + } + + object Scm { + const val CONNECTION = "scm:git:git://github.com/Javet.git" + const val DEVELOPER_CONNECTION = "scm:git:ssh://github.com/Javet.git" + } + } + + object Projects { + // https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy + const val BYTE_BUDDY = "net.bytebuddy:byte-buddy:${Versions.BYTE_BUDDY}" + + // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind + const val JACKSON_DATABIND = "com.fasterxml.jackson.core:jackson-databind:${Versions.JACKSON_DATABIND}" + + // https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/javax-websocket-server-impl + const val JETTY_JAVAX_WEBSOCKET_SERVER_IMPL = + "org.eclipse.jetty.websocket:javax-websocket-server-impl:${Versions.JETTY_WEBSOCKET}" + + // https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-server + const val JETTY_WEBSOCKET_SERVER = "org.eclipse.jetty.websocket:websocket-server:${Versions.JETTY_WEBSOCKET}" + + // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api + const val JUNIT_JUPITER_API = "org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}" + + // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine + const val JUNIT_JUPITER_ENGINE = "org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}" + + // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params + const val JUNIT_JUPITER_PARAMS = "org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}" + } + + object Versions { + const val BYTE_BUDDY = "1.14.10" + const val JACKSON_DATABIND = "2.16.0" + const val JAVA_VERSION = "1.8" + const val JAVET = "3.0.3" + const val JETTY_WEBSOCKET = "9.4.53.v20231009" + const val JUNIT = "5.10.1" + } +} + +val buildDir = layout.buildDirectory.get().toString() + plugins { java `java-library` `maven-publish` } +group = Config.GROUP_ID +version = Config.VERSION + repositories { mavenCentral() } -group = "com.caoccao.javet" -version = "3.0.2" +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + withSourcesJar() + withJavadocJar() +} dependencies { - testImplementation("org.eclipse.jetty.websocket:websocket-server:9.4.51.v20230217") - testImplementation("org.eclipse.jetty.websocket:javax-websocket-server-impl:9.4.51.v20230217") - - // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind - testImplementation("com.fasterxml.jackson.core:jackson-databind:2.15.3") - - // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api - testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") - - // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params - testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.0") - - // https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy - testImplementation("net.bytebuddy:byte-buddy:1.14.9") - - // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0") + testImplementation(Config.Projects.BYTE_BUDDY) + testImplementation(Config.Projects.JACKSON_DATABIND) + testImplementation(Config.Projects.JETTY_JAVAX_WEBSOCKET_SERVER_IMPL) + testImplementation(Config.Projects.JETTY_WEBSOCKET_SERVER) + testImplementation(Config.Projects.JUNIT_JUPITER_API) + testImplementation(Config.Projects.JUNIT_JUPITER_PARAMS) + testRuntimeOnly(Config.Projects.JUNIT_JUPITER_ENGINE) } afterEvaluate { @@ -74,7 +137,7 @@ task("buildJNIHeaders") { tasks.jar { manifest { - attributes["Automatic-Module-Name"] = "com.caoccao.javet" + attributes["Automatic-Module-Name"] = Config.GROUP_ID } } @@ -90,23 +153,60 @@ tasks.register("performanceTest") { } } -tasks.withType { - options.encoding = "UTF-8" -} - -tasks.withType { - systemProperty("file.encoding", "UTF-8") -} - -tasks.withType { - options.encoding = "UTF-8" +tasks { + withType { + options.encoding = "UTF-8" + } + withType { + options.encoding = "UTF-8" + } + withType { + systemProperty("file.encoding", "UTF-8") + } + withType { + destination = file("$buildDir/libs/${Config.Pom.ARTIFACT_ID}-${Config.VERSION}.pom") + } } -// Allow for publishing to maven local publishing { publications { - create("maven") { + create("generatePom") { from(components["java"]) + pom { + artifactId = Config.Pom.ARTIFACT_ID + description.set(Config.Pom.DESCRIPTION) + groupId = Config.GROUP_ID + name.set(Config.NAME) + url.set(Config.URL) + version = Config.VERSION + licenses { + license { + name.set(Config.Pom.License.NAME) + url.set(Config.Pom.License.URL) + } + } + developers { + developer { + id.set(Config.Pom.Developer.ID) + email.set(Config.Pom.Developer.EMAIL) + name.set(Config.Pom.Developer.NAME) + organization.set(Config.Pom.Developer.ORGANIZATION) + organizationUrl.set(Config.Pom.Developer.ORGANIZATION_URL) + } + } + scm { + connection.set(Config.Pom.Scm.CONNECTION) + developerConnection.set(Config.Pom.Scm.DEVELOPER_CONNECTION) + tag.set(Config.Versions.JAVET) + url.set(Config.URL) + } + properties.set( + mapOf( + "maven.compiler.source" to Config.Versions.JAVA_VERSION, + "maven.compiler.target" to Config.Versions.JAVA_VERSION, + ) + ) + } } } } diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9dcef6ec3..be0d59c73 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -98,6 +98,7 @@ if(DEFINED V8_DIR) list(APPEND includeDirs ${V8_DIR} ${V8_DIR}/include + ${V8_DIR}/third_party/abseil-cpp ${V8_RELEASE_DIR}/gen) if(DEFINED ENABLE_I18N) add_definitions(-DENABLE_I18N -DV8_INTL_SUPPORT) @@ -120,7 +121,7 @@ if(DEFINED NODE_DIR) if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "(arm64|aarch64)") list(APPEND importLibraries base64_neon64) else() - list(APPEND importLibraries base64_avx base64_avx2 base64_sse41 base64_sse42 base64_ssse3) + list(APPEND importLibraries base64_avx base64_avx2 base64_avx512 base64_sse41 base64_sse42 base64_ssse3) endif() if(CMAKE_SYSTEM_NAME STREQUAL "Windows") list(APPEND importLibraries libnode libuv) @@ -203,6 +204,10 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android add_definitions(-D__linux__) list(APPEND includeDirs $ENV{JAVA_HOME}/include/linux) if(DEFINED V8_DIR) + if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "(arm64|aarch64)") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flax-vector-conversions ") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flax-vector-conversions ") + endif() foreach(importLibrary ${importLibraries}) set_target_properties(${importLibrary} PROPERTIES IMPORTED_LOCATION ${V8_RELEASE_DIR}/obj/lib${importLibrary}.a) endforeach(importLibrary) diff --git a/cpp/build-android.sh b/cpp/build-android.sh index ba32b7372..8bc841751 100755 --- a/cpp/build-android.sh +++ b/cpp/build-android.sh @@ -2,13 +2,13 @@ # Usage for V8: sh build-android.sh -DV8_DIR=${HOME}/v8 -DCMAKE_ANDROID_NDK=${HOME}/android -DCMAKE_ANDROID_ARCH=arm64 # Usage for Node: sh build-android.sh -DNODE_DIR=${HOME}/node -DCMAKE_ANDROID_NDK=${HOME}/android -DCMAKE_ANDROID_ARCH=arm64 -JAVET_VERSION=3.0.2 +JAVET_VERSION=3.0.3 rm -rf build_android mkdir build_android cd build_android mkdir -p ../../build/libs cmake ../ -DCMAKE_SYSTEM_NAME=Android -DJAVET_VERSION=${JAVET_VERSION} "$@" \ - && make -j$(nproc) + && make -j `nproc` if [ $? -eq 0 ]; then cp -f *.a ../../build/libs echo Build Completed diff --git a/cpp/build-linux-arm64.sh b/cpp/build-linux-arm64.sh index db6f3f3d1..17cba4d85 100644 --- a/cpp/build-linux-arm64.sh +++ b/cpp/build-linux-arm64.sh @@ -2,13 +2,13 @@ # Usage for V8: sh build-linux-arm64.sh -DV8_DIR=${HOME}/v8 # Usage for Node: sh build-linux-arm64.sh -DNODE_DIR=${HOME}/node -JAVET_VERSION=3.0.2 +JAVET_VERSION=3.0.3 rm -rf build_linux_arm64 mkdir build_linux_arm64 cd build_linux_arm64 mkdir -p ../../build/libs cmake ../ -DJAVET_VERSION=${JAVET_VERSION} "$@" \ - && make -j$(proc) \ + && make -j `nproc` \ && strip --strip-unneeded -R .note -R .comment ../../src/main/resources/libjavet-*-linux-arm64.v.${JAVET_VERSION}.so if [ $? -eq 0 ]; then cp -f *.a ../../build/libs diff --git a/cpp/build-linux-x86_64.sh b/cpp/build-linux-x86_64.sh index ed4050162..ac5ea546c 100644 --- a/cpp/build-linux-x86_64.sh +++ b/cpp/build-linux-x86_64.sh @@ -2,13 +2,13 @@ # Usage for V8: sh build-linux-x86_64.sh -DV8_DIR=${HOME}/v8 # Usage for Node: sh build-linux-x86_64.sh -DNODE_DIR=${HOME}/node -JAVET_VERSION=3.0.2 +JAVET_VERSION=3.0.3 rm -rf build_linux_x86_64 mkdir build_linux_x86_64 cd build_linux_x86_64 mkdir -p ../../build/libs cmake ../ -DJAVET_VERSION=${JAVET_VERSION} "$@" \ - && make -j$(nproc) \ + && make -j `nproc` \ && execstack -c ../../src/main/resources/libjavet-*-linux-x86_64.v.${JAVET_VERSION}.so \ && strip --strip-unneeded -R .note -R .comment ../../src/main/resources/libjavet-*-linux-x86_64.v.${JAVET_VERSION}.so if [ $? -eq 0 ]; then diff --git a/cpp/build-macos.sh b/cpp/build-macos.sh index fcd081958..ff05c4203 100755 --- a/cpp/build-macos.sh +++ b/cpp/build-macos.sh @@ -2,13 +2,13 @@ # Usage for V8: sh build-macos.sh -DV8_DIR=${HOME}/v8 # Usage for Node: sh build-macos.sh -DNODE_DIR=${HOME}/node -JAVET_VERSION=3.0.2 +JAVET_VERSION=3.0.3 rm -rf build_macos mkdir build_macos cd build_macos mkdir -p ../../build/libs cmake ../ -DJAVET_VERSION=${JAVET_VERSION} "$@" \ - && make -j$(nproc) + && make -j `nproc` if [ $? -eq 0 ]; then cp -f *.a ../../build/libs echo Build Completed diff --git a/cpp/build-windows.cmd b/cpp/build-windows.cmd index c06f70fd7..c182d9c0f 100644 --- a/cpp/build-windows.cmd +++ b/cpp/build-windows.cmd @@ -1,7 +1,7 @@ @echo off REM Usage for V8: build -DV8_DIR=C:\v8 REM Usage for Node: build -DNODE_DIR=C:\node -SET JAVET_VERSION=3.0.2 +SET JAVET_VERSION=3.0.3 rd /s/q build_windows mkdir build_windows cd build_windows diff --git a/cpp/jni/com_caoccao_javet_interop_V8Native.h b/cpp/jni/com_caoccao_javet_interop_V8Native.h index 044693ee1..5fae83b54 100644 --- a/cpp/jni/com_caoccao_javet_interop_V8Native.h +++ b/cpp/jni/com_caoccao_javet_interop_V8Native.h @@ -1239,6 +1239,14 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_setHas JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_setWeak (JNIEnv *, jobject, jlong, jlong, jint, jobject); +/* + * Class: com_caoccao_javet_interop_V8Native + * Method: snapshotCreate + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_com_caoccao_javet_interop_V8Native_snapshotCreate + (JNIEnv *, jobject, jlong); + /* * Class: com_caoccao_javet_interop_V8Native * Method: strictEquals diff --git a/cpp/jni/exported_symbols_list.txt b/cpp/jni/exported_symbols_list.txt index 48798a26f..2474be391 100644 --- a/cpp/jni/exported_symbols_list.txt +++ b/cpp/jni/exported_symbols_list.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_callbacks.cpp b/cpp/jni/javet_callbacks.cpp index 25bc727c1..261e69738 100644 --- a/cpp/jni/javet_callbacks.cpp +++ b/cpp/jni/javet_callbacks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_callbacks.h b/cpp/jni/javet_callbacks.h index de9ebefd0..5310d4c11 100644 --- a/cpp/jni/javet_callbacks.h +++ b/cpp/jni/javet_callbacks.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_constants.h b/cpp/jni/javet_constants.h index ce8ec6ce9..0d19ce88e 100644 --- a/cpp/jni/javet_constants.h +++ b/cpp/jni/javet_constants.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_converter.cpp b/cpp/jni/javet_converter.cpp index 83c5fa144..d84c28621 100644 --- a/cpp/jni/javet_converter.cpp +++ b/cpp/jni/javet_converter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_converter.h b/cpp/jni/javet_converter.h index 38e03420d..233d059e7 100644 --- a/cpp/jni/javet_converter.h +++ b/cpp/jni/javet_converter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_enums.h b/cpp/jni/javet_enums.h index e68842061..857b8db6e 100644 --- a/cpp/jni/javet_enums.h +++ b/cpp/jni/javet_enums.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"), diff --git a/cpp/jni/javet_exceptions.cpp b/cpp/jni/javet_exceptions.cpp index 307811f82..826e29966 100644 --- a/cpp/jni/javet_exceptions.cpp +++ b/cpp/jni/javet_exceptions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -52,7 +52,7 @@ namespace Javet { const V8LocalContext& v8Context, const char* message) noexcept { auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); - if (v8InternalIsolate->has_pending_exception()) { + if (HAS_PENDING_EXCEPTION(v8InternalIsolate)) { V8TryCatch v8TryCatch(v8Context->GetIsolate()); v8InternalIsolate->ReportPendingMessages(); if (v8TryCatch.HasCaught()) { @@ -60,6 +60,7 @@ namespace Javet { return true; } } +#ifdef ENABLE_NODE else if (v8InternalIsolate->has_scheduled_exception()) { V8TryCatch v8TryCatch(v8Context->GetIsolate()); v8InternalIsolate->PromoteScheduledException(); @@ -70,6 +71,7 @@ namespace Javet { } } } +#endif if (message != nullptr) { ThrowJavetOutOfMemoryException(jniEnv, v8Context, message); return true; diff --git a/cpp/jni/javet_exceptions.h b/cpp/jni/javet_exceptions.h index b4407e066..281ab5f77 100644 --- a/cpp/jni/javet_exceptions.h +++ b/cpp/jni/javet_exceptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_inspector.cpp b/cpp/jni/javet_inspector.cpp index 6c53d6323..6b768441c 100644 --- a/cpp/jni/javet_inspector.cpp +++ b/cpp/jni/javet_inspector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_inspector.h b/cpp/jni/javet_inspector.h index fdd3e4e54..c51b075b5 100644 --- a/cpp/jni/javet_inspector.h +++ b/cpp/jni/javet_inspector.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni.h b/cpp/jni/javet_jni.h index f4109545d..fe17371e6 100644 --- a/cpp/jni/javet_jni.h +++ b/cpp/jni/javet_jni.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_array.cpp b/cpp/jni/javet_jni_array.cpp index b6d7572c4..deab17523 100644 --- a/cpp/jni/javet_jni_array.cpp +++ b/cpp/jni/javet_jni_array.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_array_buffer.cpp b/cpp/jni/javet_jni_array_buffer.cpp index 521af2a83..003fddd4c 100644 --- a/cpp/jni/javet_jni_array_buffer.cpp +++ b/cpp/jni/javet_jni_array_buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_context.cpp b/cpp/jni/javet_jni_context.cpp index 9ceb55371..27f21f9d6 100644 --- a/cpp/jni/javet_jni_context.cpp +++ b/cpp/jni/javet_jni_context.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_core_node.cpp b/cpp/jni/javet_jni_core_node.cpp index 193d4f470..4733d2ed8 100644 --- a/cpp/jni/javet_jni_core_node.cpp +++ b/cpp/jni/javet_jni_core_node.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_core_v8.cpp b/cpp/jni/javet_jni_core_v8.cpp index d638eedc7..0b6b714d2 100644 --- a/cpp/jni/javet_jni_core_v8.cpp +++ b/cpp/jni/javet_jni_core_v8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -104,12 +104,16 @@ Creating multiple isolates allows running JavaScript code in multiple threads, t JNIEXPORT jlong JNICALL Java_com_caoccao_javet_interop_V8Native_createV8Runtime (JNIEnv* jniEnv, jobject caller, jobject mRuntimeOptions) { #ifdef ENABLE_NODE - auto v8Runtime = new Javet::V8Runtime(Javet::V8Native::GlobalV8Platform.get(), Javet::NodeNative::GlobalNodeArrayBufferAllocator); + auto v8Runtime = new Javet::V8Runtime( + Javet::V8Native::GlobalV8Platform.get(), + Javet::NodeNative::GlobalNodeArrayBufferAllocator); #else - auto v8Runtime = new Javet::V8Runtime(Javet::V8Native::GlobalV8Platform.get()); + auto v8Runtime = new Javet::V8Runtime( + Javet::V8Native::GlobalV8Platform.get(), + Javet::V8Native::GlobalV8ArrayBufferAllocator); #endif INCREASE_COUNTER(Javet::Monitor::CounterType::NewV8Runtime); - v8Runtime->CreateV8Isolate(); + v8Runtime->CreateV8Isolate(jniEnv, mRuntimeOptions); v8Runtime->CreateV8Context(jniEnv, mRuntimeOptions); return TO_JAVA_LONG(v8Runtime); } @@ -232,7 +236,7 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_hasPendingExc (JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle) { RUNTIME_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle); auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); - return v8InternalIsolate->has_pending_exception(); + return HAS_PENDING_EXCEPTION(v8InternalIsolate); } JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_hasPendingMessage @@ -244,9 +248,13 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_hasPendingMes JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_hasScheduledException (JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle) { +#ifdef ENABLE_NODE RUNTIME_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle); auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); return v8InternalIsolate->has_scheduled_exception(); +#else + return false; +#endif } JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_idleNotificationDeadline @@ -296,12 +304,14 @@ JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_lowMemoryNotifica JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_promoteScheduledException (JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle) { +#ifdef ENABLE_NODE RUNTIME_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle); auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); if (v8InternalIsolate->has_scheduled_exception()) { v8InternalIsolate->PromoteScheduledException(); return true; } +#endif return false; } @@ -368,7 +378,7 @@ JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_resetV8Isolate auto v8Runtime = Javet::V8Runtime::FromHandle(v8RuntimeHandle); v8Runtime->CloseV8Context(); v8Runtime->CloseV8Isolate(); - v8Runtime->CreateV8Isolate(); + v8Runtime->CreateV8Isolate(jniEnv, mRuntimeOptions); v8Runtime->CreateV8Context(jniEnv, mRuntimeOptions); } @@ -389,6 +399,17 @@ JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_setWeak } } +JNIEXPORT jbyteArray JNICALL Java_com_caoccao_javet_interop_V8Native_snapshotCreate +(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle) { +#ifdef ENABLE_NODE + auto v8Runtime = Javet::V8Runtime::FromHandle(v8RuntimeHandle); + auto v8Locker = v8Runtime->GetSharedV8Locker(); +#else + RUNTIME_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle); +#endif + return v8Runtime->CreateSnapshot(jniEnv); +} + JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_strictEquals (JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle1, jlong v8ValueHandle2) { RUNTIME_AND_2_VALUES_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle1, v8ValueHandle2); diff --git a/cpp/jni/javet_jni_function.cpp b/cpp/jni/javet_jni_function.cpp index e541fc95e..efebb9c35 100644 --- a/cpp/jni/javet_jni_function.cpp +++ b/cpp/jni/javet_jni_function.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_map.cpp b/cpp/jni/javet_jni_map.cpp index 5b01cd751..b85c1bf8a 100644 --- a/cpp/jni/javet_jni_map.cpp +++ b/cpp/jni/javet_jni_map.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_module.cpp b/cpp/jni/javet_jni_module.cpp index 18e2a0a95..83b5917f2 100644 --- a/cpp/jni/javet_jni_module.cpp +++ b/cpp/jni/javet_jni_module.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_object.cpp b/cpp/jni/javet_jni_object.cpp index f970e752e..c4784f032 100644 --- a/cpp/jni/javet_jni_object.cpp +++ b/cpp/jni/javet_jni_object.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_promise.cpp b/cpp/jni/javet_jni_promise.cpp index 394e12278..b424e6fb0 100644 --- a/cpp/jni/javet_jni_promise.cpp +++ b/cpp/jni/javet_jni_promise.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_proxy.cpp b/cpp/jni/javet_jni_proxy.cpp index 970cd1ed9..3c1a022f2 100644 --- a/cpp/jni/javet_jni_proxy.cpp +++ b/cpp/jni/javet_jni_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_script.cpp b/cpp/jni/javet_jni_script.cpp index a28f23e78..59865f2dc 100644 --- a/cpp/jni/javet_jni_script.cpp +++ b/cpp/jni/javet_jni_script.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_set.cpp b/cpp/jni/javet_jni_set.cpp index b04df2b33..43e9f592c 100644 --- a/cpp/jni/javet_jni_set.cpp +++ b/cpp/jni/javet_jni_set.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_jni_symbol.cpp b/cpp/jni/javet_jni_symbol.cpp index a496eae04..1a6384a91 100644 --- a/cpp/jni/javet_jni_symbol.cpp +++ b/cpp/jni/javet_jni_symbol.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_logging.h b/cpp/jni/javet_logging.h index 7a2c3ad65..d9a703548 100644 --- a/cpp/jni/javet_logging.h +++ b/cpp/jni/javet_logging.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_monitor.cpp b/cpp/jni/javet_monitor.cpp index 3213baaa1..b9920dd9d 100644 --- a/cpp/jni/javet_monitor.cpp +++ b/cpp/jni/javet_monitor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_monitor.h b/cpp/jni/javet_monitor.h index ea34781ce..f6d190382 100644 --- a/cpp/jni/javet_monitor.h +++ b/cpp/jni/javet_monitor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_native.cpp b/cpp/jni/javet_native.cpp index 4fde233b0..659b44d1a 100644 --- a/cpp/jni/javet_native.cpp +++ b/cpp/jni/javet_native.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -101,6 +101,7 @@ namespace Javet { std::unique_ptr GlobalV8Platform; #else std::unique_ptr GlobalV8Platform; + std::shared_ptr GlobalV8ArrayBufferAllocator; #endif jclass jclassV8Host; @@ -115,6 +116,9 @@ namespace Javet { v8::V8::Dispose(); v8::V8::DisposePlatform(); GlobalV8Platform.reset(); +#ifndef ENABLE_NODE + GlobalV8ArrayBufferAllocator.reset(); +#endif } } @@ -143,6 +147,8 @@ namespace Javet { std::vector errors; auto flags = static_cast( node::ProcessInitializationFlags::kNoFlags + | node::ProcessInitializationFlags::kNoStdioInitialization + | node::ProcessInitializationFlags::kNoDefaultSignalHandling | node::ProcessInitializationFlags::kNoInitializeV8 | node::ProcessInitializationFlags::kNoInitializeNodeV8Platform | node::ProcessInitializationFlags::kNoInitializeCppgc); @@ -161,6 +167,11 @@ namespace Javet { auto pageAllocator = Javet::V8Native::GlobalV8Platform->GetPageAllocator(); LOG_INFO("Calling cppgc::InitializeProcess()."); cppgc::InitializeProcess(pageAllocator); +#else + if (!GlobalV8ArrayBufferAllocator) { + GlobalV8ArrayBufferAllocator = std::shared_ptr(); + GlobalV8ArrayBufferAllocator.reset(V8ArrayBufferAllocator::NewDefaultAllocator()); + } #endif LOG_INFO("V8::Initialize() ends."); } diff --git a/cpp/jni/javet_native.h b/cpp/jni/javet_native.h index 89d7d9984..8f6058810 100644 --- a/cpp/jni/javet_native.h +++ b/cpp/jni/javet_native.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -122,6 +122,7 @@ namespace Javet { extern std::unique_ptr GlobalV8Platform; #else extern std::unique_ptr GlobalV8Platform; + extern std::shared_ptr GlobalV8ArrayBufferAllocator; #endif void Dispose(JNIEnv* jniEnv) noexcept; diff --git a/cpp/jni/javet_node.cpp b/cpp/jni/javet_node.cpp index 3489c3c71..64444a7e3 100644 --- a/cpp/jni/javet_node.cpp +++ b/cpp/jni/javet_node.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/jni/javet_node.h b/cpp/jni/javet_node.h index ddde35db5..afaf46de1 100644 --- a/cpp/jni/javet_node.h +++ b/cpp/jni/javet_node.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,6 +28,7 @@ #include #include #include +#include // Hack Begins (The hack is for resolving the conflicts between Node.js and V8) #define BASE_TRACE_EVENT_COMMON_TRACE_EVENT_COMMON_H_ #define V8_TRACING_TRACE_EVENT_H_ diff --git a/cpp/jni/javet_resource_node.rc b/cpp/jni/javet_resource_node.rc index 1639b2871..d1474528f 100644 --- a/cpp/jni/javet_resource_node.rc +++ b/cpp/jni/javet_resource_node.rc @@ -61,8 +61,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,0,2,0 - PRODUCTVERSION 3,0,2,0 + FILEVERSION 3,0,3,0 + PRODUCTVERSION 3,0,3,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -79,12 +79,12 @@ BEGIN BEGIN VALUE "CompanyName", "caoccao.com" VALUE "FileDescription", "caoccao.com" - VALUE "FileVersion", "3.0.2.0" - VALUE "InternalName", "libjavet-node-windows-x86_64.v.3.0.2.dll" - VALUE "LegalCopyright", "Copyright (C) 2021-2023" - VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.3.0.2.dll" + VALUE "FileVersion", "3.0.3.0" + VALUE "InternalName", "libjavet-node-windows-x86_64.v.3.0.3.dll" + VALUE "LegalCopyright", "Copyright (c) 2021-2024." + VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.3.0.3.dll" VALUE "ProductName", "Javet Windows" - VALUE "ProductVersion", "3.0.2.0" + VALUE "ProductVersion", "3.0.3.0" END END BLOCK "VarFileInfo" diff --git a/cpp/jni/javet_resource_v8.rc b/cpp/jni/javet_resource_v8.rc index 27cb1742a..c2105864b 100644 --- a/cpp/jni/javet_resource_v8.rc +++ b/cpp/jni/javet_resource_v8.rc @@ -61,8 +61,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,0,2,0 - PRODUCTVERSION 3,0,2,0 + FILEVERSION 3,0,3,0 + PRODUCTVERSION 3,0,3,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -79,12 +79,12 @@ BEGIN BEGIN VALUE "CompanyName", "caoccao.com" VALUE "FileDescription", "caoccao.com" - VALUE "FileVersion", "3.0.2.0" - VALUE "InternalName", "libjavet-v8-windows-x86_64.v.3.0.2.dll" - VALUE "LegalCopyright", "Copyright (C) 2021-2023" - VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.3.0.2.dll" + VALUE "FileVersion", "3.0.3.0" + VALUE "InternalName", "libjavet-v8-windows-x86_64.v.3.0.3.dll" + VALUE "LegalCopyright", "Copyright (c) 2021-2024." + VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.3.0.3.dll" VALUE "ProductName", "Javet Windows" - VALUE "ProductVersion", "3.0.2.0" + VALUE "ProductVersion", "3.0.3.0" END END BLOCK "VarFileInfo" diff --git a/cpp/jni/javet_v8.h b/cpp/jni/javet_v8.h index ea74a7ce4..ea726fcaf 100644 --- a/cpp/jni/javet_v8.h +++ b/cpp/jni/javet_v8.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -98,6 +98,7 @@ using V8PersistentSymbol = v8::Persistent; using V8PersistentSymbolObject = v8::Persistent; using V8PersistentValue = v8::Persistent; +using V8ArrayBufferAllocator = v8::ArrayBuffer::Allocator; using V8Platform = v8::Platform; using V8StringUtf8Value = v8::String::Utf8Value; using V8StringValue = v8::String::Value; diff --git a/cpp/jni/javet_v8_internal.h b/cpp/jni/javet_v8_internal.h index 1a81a7e17..7dea27b46 100644 --- a/cpp/jni/javet_v8_internal.h +++ b/cpp/jni/javet_v8_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -83,6 +83,15 @@ constexpr auto CONVERT_OFFSET_FOR_SCOPE_INFO(T offset) { return (offset - V8InternalHeapObject::kHeaderSize) / v8::internal::kTaggedSize; } +template +constexpr auto HAS_PENDING_EXCEPTION(T v8InternalIsolate) { +#ifdef ENABLE_NODE + return v8InternalIsolate->has_pending_exception(); +#else + return v8InternalIsolate->has_exception(); +#endif +} + template constexpr auto IS_USER_DEFINED_FUNCTION(T v8InternalShared) { #ifdef ENABLE_NODE diff --git a/cpp/jni/javet_v8_runtime.cpp b/cpp/jni/javet_v8_runtime.cpp index 094c26c55..ff21f5eb8 100644 --- a/cpp/jni/javet_v8_runtime.cpp +++ b/cpp/jni/javet_v8_runtime.cpp @@ -1,5 +1,5 @@ -/* - * Copyright (c) 2021-2023 caoccao.com Sam Cao +/* + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,6 +26,8 @@ namespace Javet { jclass jclassRuntimeOptions; + jmethodID jmethodRuntimeOptionsIsCreateSnapshotEnabled; + jmethodID jmethodRuntimeOptionsGetSnapshotBlob; #ifdef ENABLE_NODE jmethodID jmethodNodeRuntimeOptionsGetConsoleArguments; std::mutex mutexForNodeResetEnvrironment; @@ -38,13 +40,14 @@ namespace Javet { #ifdef ENABLE_NODE jclassRuntimeOptions = FIND_CLASS(jniEnv, "com/caoccao/javet/interop/options/NodeRuntimeOptions"); jmethodNodeRuntimeOptionsGetConsoleArguments = jniEnv->GetMethodID(jclassRuntimeOptions, "getConsoleArguments", "()[Ljava/lang/String;"); - bool isFrozen = false; #else jclassRuntimeOptions = FIND_CLASS(jniEnv, "com/caoccao/javet/interop/options/V8RuntimeOptions"); jmethodV8RuntimeOptionsGetGlobalName = jniEnv->GetMethodID(jclassRuntimeOptions, "getGlobalName", "()Ljava/lang/String;"); - bool isFrozen = V8InternalFlagList::IsFrozen(); // Since V8 v10.5 #endif + jmethodRuntimeOptionsIsCreateSnapshotEnabled = jniEnv->GetMethodID(jclassRuntimeOptions, "isCreateSnapshotEnabled", "()Z"); + jmethodRuntimeOptionsGetSnapshotBlob = jniEnv->GetMethodID(jclassRuntimeOptions, "getSnapshotBlob", "()[B"); // Set V8 flags + bool isFrozen = V8InternalFlagList::IsFrozen(); // Since V8 v10.5 if (!isFrozen) { jclass jclassV8Flags = jniEnv->FindClass("com/caoccao/javet/interop/options/V8Flags"); jmethodID jmethodIDV8FlagsToString = jniEnv->GetMethodID(jclassV8Flags, "toString", "()Ljava/lang/String;"); @@ -72,12 +75,19 @@ namespace Javet { V8Runtime::V8Runtime( node::MultiIsolatePlatform* v8PlatformPointer, std::shared_ptr nodeArrayBufferAllocator) noexcept - : nodeEnvironment(nullptr, node::FreeEnvironment), nodeIsolateData(nullptr, node::FreeIsolateData), v8Locker(nullptr), uvLoop() { + : nodeEnvironment(nullptr, node::FreeEnvironment), nodeIsolateData(nullptr, node::FreeIsolateData), uvLoop(), +#else + V8Runtime::V8Runtime( + V8Platform* v8PlatformPointer, + std::shared_ptr v8ArrayBufferAllocator) noexcept + : +#endif + v8SnapshotCreator(nullptr), v8StartupData(nullptr, [](v8::StartupData* x) { if (x->raw_size > 0) { delete[] x->data; } }), v8Locker(nullptr) { +#ifdef ENABLE_NODE purgeEventLoopBeforeClose = false; this->nodeArrayBufferAllocator = nodeArrayBufferAllocator; #else - V8Runtime::V8Runtime(V8Platform * v8PlatformPointer) noexcept - : v8Locker(nullptr) { + this->v8ArrayBufferAllocator = v8ArrayBufferAllocator; #endif externalV8Runtime = nullptr; externalException = nullptr; @@ -207,7 +217,13 @@ namespace Javet { // UnregisterIsolate is thread-safe. v8PlatformPointer->UnregisterIsolate(v8Isolate); #endif - v8Isolate->Dispose(); + if (v8SnapshotCreator) { + v8SnapshotCreator.reset(); + } + else { + v8Isolate->Dispose(); + } + v8StartupData.reset(); #ifdef ENABLE_NODE while (!isIsolateFinished) { uv_run(&uvLoop, UV_RUN_ONCE); @@ -221,16 +237,82 @@ namespace Javet { } } - void V8Runtime::CreateV8Context(JNIEnv * jniEnv, const jobject mRuntimeOptions) noexcept { + jbyteArray V8Runtime::CreateSnapshot(JNIEnv* jniEnv) noexcept { + jbyteArray jbytes = nullptr; + if (v8SnapshotCreator) { +#ifdef ENABLE_NODE + v8::MaybeLocal v8MaybeLocalContext; + { + auto v8IsolateScope = GetV8IsolateScope(); + V8HandleScope v8HandleScope(v8Isolate); + auto v8LocalContext = GetV8LocalContext(); + auto v8ContextScope = GetV8ContextScope(v8LocalContext); + // Backup context and global object (Begin) + v8PersistentContext.Reset(); + v8GlobalObject.Reset(); + // Backup context and global object (End) + nodeIsolateData->Serialize(v8SnapshotCreator.get()); + nodeEnvironment->Serialize(v8SnapshotCreator.get()); + v8SnapshotCreator->SetDefaultContext(v8LocalContext, { node::SerializeNodeContextInternalFields, nodeEnvironment.get() }); + v8MaybeLocalContext = v8::MaybeLocal(v8LocalContext); + } + // TODO: Unknown external reference + v8::StartupData newV8StartupData = v8SnapshotCreator->CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep); + if (newV8StartupData.IsValid()) { + jbytes = jniEnv->NewByteArray(newV8StartupData.raw_size); + jboolean isCopy; + void* data = jniEnv->GetPrimitiveArrayCritical(jbytes, &isCopy); + memcpy(data, newV8StartupData.data, newV8StartupData.raw_size); + jniEnv->ReleasePrimitiveArrayCritical(jbytes, data, JNI_ABORT); + delete[] newV8StartupData.data; + } + { + auto v8IsolateScope = GetV8IsolateScope(); + V8HandleScope v8HandleScope(v8Isolate); + auto v8LocalContext = v8MaybeLocalContext.ToLocalChecked(); + auto v8ContextScope = GetV8ContextScope(v8LocalContext); + // Restore context and global object (Begin) + v8PersistentContext.Reset(v8Isolate, v8LocalContext); + v8GlobalObject.Reset( + v8Isolate, v8LocalContext->Global()->GetPrototype()->ToObject(v8LocalContext).ToLocalChecked()); + // Restore context and global object (End) + } +#else + // Backup context and global object (Begin) + auto v8LocalContext = GetV8LocalContext(); + v8PersistentContext.Reset(); + v8GlobalObject.Reset(); + // Backup context and global object (End) + v8SnapshotCreator->SetDefaultContext(v8LocalContext); + v8::StartupData newV8StartupData = v8SnapshotCreator->CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep); + if (newV8StartupData.IsValid()) { + jbytes = jniEnv->NewByteArray(newV8StartupData.raw_size); + jboolean isCopy; + void* data = jniEnv->GetPrimitiveArrayCritical(jbytes, &isCopy); + memcpy(data, newV8StartupData.data, newV8StartupData.raw_size); + jniEnv->ReleasePrimitiveArrayCritical(jbytes, data, JNI_ABORT); + delete[] newV8StartupData.data; + } + // Restore context and global object (Begin) + v8PersistentContext.Reset(v8Isolate, v8LocalContext); + v8GlobalObject.Reset( + v8Isolate, v8LocalContext->Global()->GetPrototype()->ToObject(v8LocalContext).ToLocalChecked()); + // Restore context and global object (End) +#endif + } + return jbytes; + } + + void V8Runtime::CreateV8Context(JNIEnv* jniEnv, const jobject mRuntimeOptions) noexcept { auto internalV8Locker = GetSharedV8Locker(); auto v8IsolateScope = GetV8IsolateScope(); V8HandleScope v8HandleScope(v8Isolate); #ifdef ENABLE_NODE // node::NewContext is thread-safe. - V8LocalContext v8LocalContext = node::NewContext(v8Isolate); + auto v8LocalContext = node::NewContext(v8Isolate); auto v8ContextScope = GetV8ContextScope(v8LocalContext); // Create and load the environment only once per isolate. - if (nodeEnvironment.get() == nullptr) { + if (!nodeEnvironment) { std::vector args{ DEFAULT_SCRIPT_NAME }; std::vector execArgs; if (mRuntimeOptions != nullptr) { @@ -276,6 +358,7 @@ namespace Javet { } } auto v8LocalContext = v8::Context::New(v8Isolate, nullptr, v8ObjectTemplate); + auto v8ContextScope = GetV8ContextScope(v8LocalContext); #endif Register(v8LocalContext); v8PersistentContext.Reset(v8Isolate, v8LocalContext); @@ -283,36 +366,70 @@ namespace Javet { v8Isolate, v8LocalContext->Global()->GetPrototype()->ToObject(v8LocalContext).ToLocalChecked()); } - void V8Runtime::CreateV8Isolate() noexcept { + void V8Runtime::CreateV8Isolate(JNIEnv* jniEnv, const jobject mRuntimeOptions) noexcept { + bool createSnapshotEnabled = false; + jbyteArray snapshotBlob = nullptr; + if (mRuntimeOptions != nullptr) { + createSnapshotEnabled = jniEnv->CallBooleanMethod(mRuntimeOptions, jmethodRuntimeOptionsIsCreateSnapshotEnabled); + snapshotBlob = (jbyteArray)jniEnv->CallObjectMethod(mRuntimeOptions, jmethodRuntimeOptionsGetSnapshotBlob); + if (snapshotBlob) { + jsize snapshotBlobSize = jniEnv->GetArrayLength(snapshotBlob); + jboolean isCopy; + jbyte* snapshotBlobElements = jniEnv->GetByteArrayElements(snapshotBlob, &isCopy); + v8StartupData.reset(new v8::StartupData()); + v8StartupData->data = new char[snapshotBlobSize]; + v8StartupData->raw_size = snapshotBlobSize; + memcpy((void*)v8StartupData->data, (void*)snapshotBlobElements, snapshotBlobSize); + jniEnv->ReleaseByteArrayElements(snapshotBlob, snapshotBlobElements, JNI_ABORT); + } + } #ifdef ENABLE_NODE int errorCode = uv_loop_init(&uvLoop); if (errorCode != 0) { LOG_ERROR("Failed to init uv loop. Reason: " << uv_err_name(errorCode)); } - // node::NewIsolate is thread-safe. - v8Isolate = node::NewIsolate(nodeArrayBufferAllocator, &uvLoop, v8PlatformPointer); + if (createSnapshotEnabled) { + const std::vector& externalReferences = node::SnapshotBuilder::CollectExternalReferences(); + v8Isolate = v8::Isolate::Allocate(); + v8PlatformPointer->RegisterIsolate(v8Isolate, &uvLoop); + v8SnapshotCreator.reset(new v8::SnapshotCreator(v8Isolate, externalReferences.data(), v8StartupData.get())); + v8Isolate->SetCaptureStackTraceForUncaughtExceptions(true, 10, v8::StackTrace::StackTraceOptions::kDetailed); + v8Isolate->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit); + } + else { + // node::NewIsolate is thread-safe. + v8Isolate = node::NewIsolate(nodeArrayBufferAllocator, &uvLoop, v8PlatformPointer); + } { auto internalV8Locker = GetUniqueV8Locker(); auto v8IsolateScope = GetV8IsolateScope(); V8HandleScope v8HandleScope(v8Isolate); // node::CreateIsolateData is thread-safe. nodeIsolateData.reset(node::CreateIsolateData(v8Isolate, &uvLoop, v8PlatformPointer, nodeArrayBufferAllocator.get())); + // nodeIsolateData->set_is_building_snapshot(createSnapshotEnabled); } v8Isolate->SetModifyCodeGenerationFromStringsCallback(nullptr); #else - v8::Isolate::CreateParams createParams; - createParams.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); - createParams.oom_error_callback = Javet::Callback::OOMErrorCallback; - v8Isolate = v8::Isolate::New(createParams); + if (createSnapshotEnabled) { + v8Isolate = v8::Isolate::Allocate(); + v8SnapshotCreator.reset(new v8::SnapshotCreator(v8Isolate, nullptr, v8StartupData.get(), true)); + } + else { + v8::Isolate::CreateParams createParams; + createParams.array_buffer_allocator = v8ArrayBufferAllocator.get(); + createParams.oom_error_callback = Javet::Callback::OOMErrorCallback; + createParams.snapshot_blob = v8StartupData.get(); + v8Isolate = v8::Isolate::New(createParams); + } v8Isolate->SetPromiseRejectCallback(Javet::Callback::JavetPromiseRejectCallback); #endif } jobject V8Runtime::SafeToExternalV8Value( - JNIEnv * jniEnv, - const V8LocalContext & v8Context, + JNIEnv* jniEnv, + const V8LocalContext& v8Context, #ifdef ENABLE_NODE - const V8InternalObject & v8InternalObject) noexcept { + const V8InternalObject& v8InternalObject) noexcept { #else const v8::internal::Tagged& v8InternalObject) noexcept { #endif diff --git a/cpp/jni/javet_v8_runtime.h b/cpp/jni/javet_v8_runtime.h index 1f03dd2d5..e0916dd7d 100644 --- a/cpp/jni/javet_v8_runtime.h +++ b/cpp/jni/javet_v8_runtime.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -51,7 +51,9 @@ namespace Javet { node::MultiIsolatePlatform* v8PlatformPointer, std::shared_ptr nodeArrayBufferAllocator) noexcept; #else - V8Runtime(V8Platform* v8PlatformPointer) noexcept; + V8Runtime( + V8Platform* v8PlatformPointer, + std::shared_ptr v8ArrayBufferAllocator) noexcept; #endif bool Await(const Javet::Enums::V8AwaitMode::V8AwaitMode awaitMode) noexcept; @@ -79,8 +81,10 @@ namespace Javet { void CloseV8Context() noexcept; void CloseV8Isolate() noexcept; + jbyteArray CreateSnapshot(JNIEnv* jniEnv) noexcept; + void CreateV8Context(JNIEnv* jniEnv, const jobject mRuntimeOptions) noexcept; - void CreateV8Isolate() noexcept; + void CreateV8Isolate(JNIEnv* jniEnv, const jobject mRuntimeOptions) noexcept; static inline V8Runtime* FromHandle(jlong handle) noexcept { return reinterpret_cast(handle); @@ -165,6 +169,8 @@ namespace Javet { virtual ~V8Runtime(); private: + std::unique_ptr v8SnapshotCreator; + std::unique_ptr> v8StartupData; std::shared_ptr v8Locker; V8PersistentContext v8PersistentContext; #ifdef ENABLE_NODE @@ -173,6 +179,8 @@ namespace Javet { std::unique_ptr nodeEnvironment; std::unique_ptr nodeIsolateData; uv_loop_t uvLoop; +#else + std::shared_ptr v8ArrayBufferAllocator; #endif }; } diff --git a/cpp/jni/resource.h b/cpp/jni/resource.h index d5986eb1c..eace9cd48 100644 --- a/cpp/jni/resource.h +++ b/cpp/jni/resource.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/docker/android/base.Dockerfile b/docker/android/base.Dockerfile index 205f599e3..85a3fe186 100644 --- a/docker/android/base.Dockerfile +++ b/docker/android/base.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Usage: docker build -t sjtucaocao/javet-android:3.0.2 -f docker/android/base.Dockerfile . +# Usage: docker build -t sjtucaocao/javet-android:3.0.3 -f docker/android/base.Dockerfile . -ARG JAVET_V8_VERSION=12.0.267.8 +ARG JAVET_V8_VERSION=12.1.285.26 FROM ubuntu:20.04 WORKDIR / diff --git a/docker/android/build.Dockerfile b/docker/android/build.Dockerfile index c91ff2595..c377bd945 100644 --- a/docker/android/build.Dockerfile +++ b/docker/android/build.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +15,7 @@ # Usage: docker build -t javet-android:local -f docker/android/build.Dockerfile . -FROM sjtucaocao/javet-android:3.0.2 +FROM sjtucaocao/javet-android:3.0.3 WORKDIR / # Copy Javet diff --git a/docker/linux-arm64/base_all_in_one.Dockerfile b/docker/linux-arm64/base_all_in_one.Dockerfile index 0d1c1021e..35d419ba1 100644 --- a/docker/linux-arm64/base_all_in_one.Dockerfile +++ b/docker/linux-arm64/base_all_in_one.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,10 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Usage: docker build -t sjtucaocao/javet-arm64:3.0.2 -f docker/linux-arm64/base_all_in_one.Dockerfile . +# Usage: docker build -t sjtucaocao/javet-arm64:3.0.3 -f docker/linux-arm64/base_all_in_one.Dockerfile . ARG JAVET_NODE_VERSION=18.15.0 -ARG JAVET_V8_VERSION=12.0.267.8 +ARG JAVET_V8_VERSION=12.1.285.26 FROM ubuntu:20.04 WORKDIR / diff --git a/docker/linux-arm64/base_gradle.Dockerfile b/docker/linux-arm64/base_gradle.Dockerfile index 0a5584155..cf8bba975 100644 --- a/docker/linux-arm64/base_gradle.Dockerfile +++ b/docker/linux-arm64/base_gradle.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +14,7 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:arm64-3.0.2 \ +# -t sjtucaocao/javet:arm64-3.0.3 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ # -f docker/linux-arm64/base_gradle.Dockerfile . diff --git a/docker/linux-arm64/base_jvm.Dockerfile b/docker/linux-arm64/base_jvm.Dockerfile index f82e77963..2118858ff 100644 --- a/docker/linux-arm64/base_jvm.Dockerfile +++ b/docker/linux-arm64/base_jvm.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/docker/linux-arm64/base_node.Dockerfile b/docker/linux-arm64/base_node.Dockerfile index c3e1b1d65..de0625edb 100644 --- a/docker/linux-arm64/base_node.Dockerfile +++ b/docker/linux-arm64/base_node.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/docker/linux-arm64/base_v8.Dockerfile b/docker/linux-arm64/base_v8.Dockerfile index d05e52a44..739514bd6 100644 --- a/docker/linux-arm64/base_v8.Dockerfile +++ b/docker/linux-arm64/base_v8.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +14,13 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:arm64-base-v8_12.0.267.8 \ +# -t sjtucaocao/javet:arm64-base-v8_12.1.285.26 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ -# --build-arg JAVET_V8_VERSION=12.0.267.8 \ +# --build-arg JAVET_V8_VERSION=12.1.285.26 \ # -f docker/linux-arm64/base_v8.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet -ARG JAVET_V8_VERSION=12.0.267.8 +ARG JAVET_V8_VERSION=12.1.285.26 FROM ${JAVET_REPO}:arm64-base-jvm diff --git a/docker/linux-arm64/build_all_in_one.Dockerfile b/docker/linux-arm64/build_all_in_one.Dockerfile index eefe59a30..459a53d93 100644 --- a/docker/linux-arm64/build_all_in_one.Dockerfile +++ b/docker/linux-arm64/build_all_in_one.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/docker/linux-arm64/build_artifact.Dockerfile b/docker/linux-arm64/build_artifact.Dockerfile index eab701780..0aca526da 100644 --- a/docker/linux-arm64/build_artifact.Dockerfile +++ b/docker/linux-arm64/build_artifact.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,13 +18,13 @@ # --build-arg JAVET_REPO=sjtucaocao/javet \ # --build-arg JAVET_NODE_VERSION=18.12.1 \ # --build-arg JAVET_V8_VERSION=10.8.168.20 \ -# --build-arg JAVET_VERSION=3.0.2 \ +# --build-arg JAVET_VERSION=3.0.3 \ # -f docker/linux-arm64/build_artifact.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet ARG JAVET_NODE_VERSION=18.12.1 ARG JAVET_V8_VERSION=10.8.168.20 -ARG JAVET_VERSION=3.0.2 +ARG JAVET_VERSION=3.0.3 FROM ${JAVET_REPO}:arm64-base-node_${JAVET_NODE_VERSION} as base-node diff --git a/docker/linux-x86_64/base_all_in_one.Dockerfile b/docker/linux-x86_64/base_all_in_one.Dockerfile index 748d22871..3f0cd33b7 100644 --- a/docker/linux-x86_64/base_all_in_one.Dockerfile +++ b/docker/linux-x86_64/base_all_in_one.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,10 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Usage: docker build -t sjtucaocao/javet:3.0.2 -f docker/linux-x86_64/base_all_in_one.Dockerfile . +# Usage: docker build -t sjtucaocao/javet:3.0.3 -f docker/linux-x86_64/base_all_in_one.Dockerfile . -ARG JAVET_NODE_VERSION=20.10.0 -ARG JAVET_V8_VERSION=12.0.267.8 +ARG JAVET_NODE_VERSION=20.11.0 +ARG JAVET_V8_VERSION=12.1.285.26 FROM ubuntu:20.04 WORKDIR / diff --git a/docker/linux-x86_64/base_gradle.Dockerfile b/docker/linux-x86_64/base_gradle.Dockerfile index c7fb3bb76..c69f62292 100644 --- a/docker/linux-x86_64/base_gradle.Dockerfile +++ b/docker/linux-x86_64/base_gradle.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +14,7 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:x86_64-3.0.2 \ +# -t sjtucaocao/javet:x86_64-3.0.3 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ # -f docker/linux-x86_64/base_gradle.Dockerfile . diff --git a/docker/linux-x86_64/base_jvm.Dockerfile b/docker/linux-x86_64/base_jvm.Dockerfile index 54170f93b..3baf03627 100644 --- a/docker/linux-x86_64/base_jvm.Dockerfile +++ b/docker/linux-x86_64/base_jvm.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/docker/linux-x86_64/base_node.Dockerfile b/docker/linux-x86_64/base_node.Dockerfile index f00dd65da..6ca5adf76 100644 --- a/docker/linux-x86_64/base_node.Dockerfile +++ b/docker/linux-x86_64/base_node.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +14,13 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:x86_64-base-node_20.10.0 \ +# -t sjtucaocao/javet:x86_64-base-node_20.11.0 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ -# --build-arg JAVET_NODE_VERSION=20.10.0 \ +# --build-arg JAVET_NODE_VERSION=20.11.0 \ # -f docker/linux-x86_64/base_node.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet -ARG JAVET_NODE_VERSION=20.10.0 +ARG JAVET_NODE_VERSION=20.11.0 FROM ${JAVET_REPO}:x86_64-base-jvm diff --git a/docker/linux-x86_64/base_v8.Dockerfile b/docker/linux-x86_64/base_v8.Dockerfile index e60f1f33d..0eefd401a 100644 --- a/docker/linux-x86_64/base_v8.Dockerfile +++ b/docker/linux-x86_64/base_v8.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +14,13 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:x86_64-base-v8_12.0.267.8 \ +# -t sjtucaocao/javet:x86_64-base-v8_12.1.285.26 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ -# --build-arg JAVET_V8_VERSION=12.0.267.8 \ +# --build-arg JAVET_V8_VERSION=12.1.285.26 \ # -f docker/linux-x86_64/base_v8.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet -ARG JAVET_V8_VERSION=12.0.267.8 +ARG JAVET_V8_VERSION=12.1.285.26 FROM ${JAVET_REPO}:x86_64-base-jvm diff --git a/docker/linux-x86_64/build_all_in_one.Dockerfile b/docker/linux-x86_64/build_all_in_one.Dockerfile index f5c5757ed..a2e64e26d 100644 --- a/docker/linux-x86_64/build_all_in_one.Dockerfile +++ b/docker/linux-x86_64/build_all_in_one.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +15,7 @@ # Usage: docker build -t javet:local -f docker/linux-x86_64/build_all_in_one.Dockerfile . -FROM sjtucaocao/javet:3.0.2 +FROM sjtucaocao/javet:3.0.3 WORKDIR / # Copy Javet diff --git a/docker/linux-x86_64/build_artifact.Dockerfile b/docker/linux-x86_64/build_artifact.Dockerfile index 5b312acc0..f6fda09a9 100644 --- a/docker/linux-x86_64/build_artifact.Dockerfile +++ b/docker/linux-x86_64/build_artifact.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,13 +18,13 @@ # --build-arg JAVET_REPO=sjtucaocao/javet \ # --build-arg JAVET_NODE_VERSION=18.12.1 \ # --build-arg JAVET_V8_VERSION=10.8.168.20 \ -# --build-arg JAVET_VERSION=3.0.2 \ +# --build-arg JAVET_VERSION=3.0.3 \ # -f docker/linux-x86_64/build_artifact.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet ARG JAVET_NODE_VERSION=18.12.1 ARG JAVET_V8_VERSION=10.8.168.20 -ARG JAVET_VERSION=3.0.2 +ARG JAVET_VERSION=3.0.3 FROM ${JAVET_REPO}:x86_64-base-node_${JAVET_NODE_VERSION} as base-v8 diff --git a/docker/windows-x86_64/base.Dockerfile b/docker/windows-x86_64/base.Dockerfile index d8b8b9e18..825f0b7f0 100644 --- a/docker/windows-x86_64/base.Dockerfile +++ b/docker/windows-x86_64/base.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,10 +29,10 @@ # The following dockerfile has been out of date because it still uses # Visual Studio 2019 Community. Please contact the maintainer if you want an upgrade. -# Usage: docker build -t sjtucaocao/javet-windows:3.0.2 -m 4G -f docker/windows-x86_64/base.Dockerfile . +# Usage: docker build -t sjtucaocao/javet-windows:3.0.3 -m 4G -f docker/windows-x86_64/base.Dockerfile . -ARG JAVET_NODE_VERSION=20.10.0 -ARG JAVET_V8_VERSION=12.0.267.8 +ARG JAVET_NODE_VERSION=20.11.0 +ARG JAVET_V8_VERSION=12.1.285.26 # https://hub.docker.com/_/microsoft-windows FROM mcr.microsoft.com/windows:20H2-amd64 diff --git a/docker/windows-x86_64/build.Dockerfile b/docker/windows-x86_64/build.Dockerfile index b2b10339c..39750a99c 100644 --- a/docker/windows-x86_64/build.Dockerfile +++ b/docker/windows-x86_64/build.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (c) 2021 caoccao.com Sam Cao +# Copyright (c) 2021-2024. caoccao.com Sam Cao # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +15,7 @@ # Usage: docker build -t javet:local -f docker/windows-x86_64/build.Dockerfile . -FROM sjtucaocao/javet-windows:3.0.2 +FROM sjtucaocao/javet-windows:3.0.3 SHELL ["cmd", "/S", "/C"] WORKDIR / diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js index 4e63c50e6..5bacd0f41 100644 --- a/docs/_static/documentation_options.js +++ b/docs/_static/documentation_options.js @@ -1,5 +1,5 @@ const DOCUMENTATION_OPTIONS = { - VERSION: '3.0.2', + VERSION: '3.0.3', LANGUAGE: 'en, zh-CN', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/docs/conf.py b/docs/conf.py index 294e652f9..5f7f532cf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ author = 'Sam Cao' # The full version, including alpha/beta/rc tags -release = '3.0.2' +release = '3.0.3' # -- General configuration --------------------------------------------------- diff --git a/docs/development/build.html b/docs/development/build.html index acacb1a47..1c26a0d53 100644 --- a/docs/development/build.html +++ b/docs/development/build.html @@ -6,7 +6,7 @@ - Build Javet - Javet 3.0.2 documentation + Build Javet - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
@@ -151,7 +151,7 @@
- Javet 3.0.2 documentation + Javet 3.0.3 documentation
diff --git a/docs/development/build.rst b/docs/development/build.rst index 98f2b1ad2..32769049a 100644 --- a/docs/development/build.rst +++ b/docs/development/build.rst @@ -24,7 +24,7 @@ Build Environment Linux Environment ----------------- -* Ubuntu 22.04+ +* Ubuntu 20.04+ * CMake 3.25.1+ * JDK 8 * Gradle 8.2+ @@ -56,7 +56,7 @@ Windows Environment Android Environment ------------------- -* Ubuntu 22.04+ or Ubuntu 22.04+ in the WSL2 on the Latest Windows 10 +* Ubuntu 20.04+ or Ubuntu 20.04+ in the WSL2 on the Latest Windows 10 * CMake 3.25.1+ * JDK 8 * Gradle 8.2+ diff --git a/docs/development/build_javet_from_scratch.html b/docs/development/build_javet_from_scratch.html index 43eb9219d..245060609 100644 --- a/docs/development/build_javet_from_scratch.html +++ b/docs/development/build_javet_from_scratch.html @@ -6,7 +6,7 @@ - Build Javet from Scratch - Javet 3.0.2 documentation + Build Javet from Scratch - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/development/build_javet_with_docker.html b/docs/development/build_javet_with_docker.html index b2eb5b779..b40ca5b79 100644 --- a/docs/development/build_javet_with_docker.html +++ b/docs/development/build_javet_with_docker.html @@ -6,7 +6,7 @@ - Build Javet with Docker - Javet 3.0.2 documentation + Build Javet with Docker - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/development/debug_with_chrome_developer_tools.html b/docs/development/debug_with_chrome_developer_tools.html index 7156438d4..35a835ea2 100644 --- a/docs/development/debug_with_chrome_developer_tools.html +++ b/docs/development/debug_with_chrome_developer_tools.html @@ -6,7 +6,7 @@ - Debug with Chrome Developer Tools - Javet 3.0.2 documentation + Debug with Chrome Developer Tools - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
@@ -151,7 +151,7 @@
- Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -322,7 +325,7 @@

    2. Run Script in CDT Shell

    3. Open CDT#

    -

    Open chrome://inspect/ in Chrome, wait few seconds and Javet will appear as a remote target.

    +

    Open chrome://inspect/ in Chrome, wait a few seconds and Javet will appear as a remote target.

    Remote Target Javet
    @@ -336,10 +339,10 @@

    Chrome Developer Tools Internals

    Handshake#

    Chrome: {"id":1,"method":"Runtime.enable","params":{}}
     Javet Notification: {"method":"Runtime.executionContextCreated","params":{"context":{"id":1,"origin":"","name":"Javet Inspector 00000000","uniqueId":"00000000.00000000"}}}
    @@ -379,12 +382,23 @@ 

    Customization +

    FAQs#

    +
    +

    Does it Support Node.js Mode?#

    +

    Yes, Javet V8 inspector supports the Node.js Mode as well as the V8 mode though the built-in Node.js inspector is disabled because of some other issues. Please visit Why is the Inspector Disabled in Node.js Mode? for more details.

    +
    +
    +

    Is There a Live Demo?#

    +

    Yes, JavetShell provides a live demo via either a jar file or a docker image.

    +
    +

    @@ -446,6 +460,11 @@

    CustomizationCustomization +
  • FAQs +
  • @@ -457,7 +476,7 @@

    Customization +

    diff --git a/docs/development/debug_with_chrome_developer_tools.rst b/docs/development/debug_with_chrome_developer_tools.rst index d6c41c08c..5c8bef837 100644 --- a/docs/development/debug_with_chrome_developer_tools.rst +++ b/docs/development/debug_with_chrome_developer_tools.rst @@ -1,96 +1,109 @@ -================================= -Debug with Chrome Developer Tools -================================= - -`Chrome DevTools `_ (aka. CDT) is a set of web developer tools built directly into the Google Chrome browser. DevTools can help you edit pages on-the-fly and diagnose problems quickly, which ultimately helps you build better websites, faster. - -CDT Shell -========= - -Javet ships a demo :extsource2:`CDT Shell <../../src/test/java/com/caoccao/javet/tutorial/cdt/TestCDT.java>` application to demonstrate how to work with CDT to perform a live debugging. - -1. Run CDT Shell ----------------- - -Run CDT Shell as a normal Java console application and an interactive console will appear working just like a node console does. - -2. Run Script in CDT Shell --------------------------- - -Run arbitrary code in the console just like what can be done in a node console. - -.. code-block:: js - - > let a = 3 - undefined - > let b = 4 - undefined - > a + b - 7 - -3. Open CDT ------------ - -Open chrome://inspect/ in Chrome, wait few seconds and Javet will appear as a remote target. - -.. image:: ../resources/images/chome_developer_tools_devices_remote_target_javet.png - :alt: Remote Target Javet - -4. Debug as Usual ------------------ - -Click ``inspect``. Voilà, DevTools is up. As the screenshot shows, live evaluation and auto-completion work successfully. Enjoy the live debugging. - -.. image:: ../resources/images/chome_developer_tools_console.png - :alt: Remote Target Javet - -Chrome Developer Tools Internals -================================ - -Handshake ---------- - -* CDT Shell listens to port 9229 by default because CDT constantly queries http://127.0.0.1:9229/json for remote target. CDT Shell tells CDT that it is a node flavored remote target via http://127.0.0.1:9229/json and the websocket address is http://127.0.0.1:9229/javet. -* CDT queries http://127.0.0.1:9229/json/version for protocol version. CDT Shell currently uses v1.3. The complete protocol API docs are available at https://chromedevtools.github.io/devtools-protocol/. -* CDT queries http://127.0.0.1:9229/javet with a websocket upgrade request. CDT Shell responses with websocket upgrade accepted. -* CDT switches to ws://127.0.0.1:9229/javet and sends the following 8 messages to perform a handshake with a node flavored remote target. - -.. code-block:: js - - Chrome: {"id":1,"method":"Runtime.enable","params":{}} - Javet Notification: {"method":"Runtime.executionContextCreated","params":{"context":{"id":1,"origin":"","name":"Javet Inspector 00000000","uniqueId":"00000000.00000000"}}} - Javet Response: {"id":1,"result":{}} - Chrome: {"id":2,"method":"Debugger.enable","params":{"maxScriptsCacheSize":100000000}} - Javet Response: {"id":2,"result":{"debuggerId":"00000000.00000000"}} - Chrome: {"id":3,"method":"Debugger.setPauseOnExceptions","params":{"state":"none"}} - Javet Response: {"id":3,"result":{}} - Chrome: {"id":4,"method":"Debugger.setAsyncCallStackDepth","params":{"maxDepth":32}} - Javet Response: {"id":4,"result":{}} - Chrome: {"id":5,"method":"Profiler.enable","params":{}} - Javet Response: {"id":5,"result":{}} - Chrome: {"id":6,"method":"Runtime.getIsolateId","params":{}} - Javet Response: {"id":6,"result":{"id":"00000000"}} - Chrome: {"id":7,"method":"Debugger.setBlackboxPatterns","params":{"patterns":[]}} - Javet Response: {"id":7,"result":{}} - Chrome: {"id":8,"method":"Runtime.runIfWaitingForDebugger","params":{}} - Javet Response: {"id":8,"result":{}} - -.. note:: - - Method ``Runtime.runIfWaitingForDebugger`` can be regarded as the handshake completion and there is no need to parse this message because it is exposed as a callback in ``IV8InspectorListener``. - -Actually, inside V8, the first message can enable the debugging without the rest of them. Please refer to the :extsource2:`source code <../../src/test/java/com/caoccao/javet/interop/TestV8Inspector.java>` for details. - -Customization -============= - -Yes, please feel free to customize the debugging server in your environment. CDT Shell is created as a showcase for further customization. Here are some tips. - -* Integrate with your HTTP and WebSocket servers. CDT Shell currently uses embedded Jetty. Be careful, HTTP and WebSocket servers need to be hosted together, otherwise, CDT refuses to communicate with the WebSocket server. -* Add your ``IV8InspectorListener`` to intercept all the event messages. In practice, a decent JSON library like JackSon, GSon may help interpret those messages. As a demo, CDT Shell doesn't process those messages. Why intercept those messages? Because: - - * To set up breakpoints before script is executed. - * To send messages to CDT right after CDT is connected. - * To turn on / off certain features. - * To enforce authentication and authorization. - * To change V8 runtime. +================================= +Debug with Chrome Developer Tools +================================= + +`Chrome DevTools `_ (aka. CDT) is a set of web developer tools built directly into the Google Chrome browser. DevTools can help you edit pages on-the-fly and diagnose problems quickly, which ultimately helps you build better websites, faster. + +CDT Shell +========= + +Javet ships a demo :extsource2:`CDT Shell <../../src/test/java/com/caoccao/javet/tutorial/cdt/TestCDT.java>` application to demonstrate how to work with CDT to perform a live debugging. + +1. Run CDT Shell +---------------- + +Run CDT Shell as a normal Java console application and an interactive console will appear working just like a node console does. + +2. Run Script in CDT Shell +-------------------------- + +Run arbitrary code in the console just like what can be done in a node console. + +.. code-block:: js + + > let a = 3 + undefined + > let b = 4 + undefined + > a + b + 7 + +3. Open CDT +----------- + +Open `chrome://inspect/ `_ in Chrome, wait a few seconds and Javet will appear as a remote target. + +.. image:: ../resources/images/chome_developer_tools_devices_remote_target_javet.png + :alt: Remote Target Javet + +4. Debug as Usual +----------------- + +Click ``inspect``. Voilà, DevTools is up. As the screenshot shows, live evaluation and auto-completion work successfully. Enjoy the live debugging. + +.. image:: ../resources/images/chome_developer_tools_console.png + :alt: Remote Target Javet + +Chrome Developer Tools Internals +================================ + +Handshake +--------- + +* CDT Shell listens to port 9229 by default because CDT constantly queries http://127.0.0.1:9229/json/list for a list of remote targets. CDT Shell tells CDT that it is a node flavored remote target via http://127.0.0.1:9229/json/list and the websocket address is ``ws://127.0.0.1:9229/javet``. +* CDT queries http://127.0.0.1:9229/json/version for protocol version. CDT Shell currently uses v1.3. The complete protocol API docs are available at https://chromedevtools.github.io/devtools-protocol/. +* CDT queries http://127.0.0.1:9229/javet/list with a websocket upgrade request. CDT Shell responses with websocket upgrade accepted. +* CDT switches to ``ws://127.0.0.1:9229/javet`` and sends the following 8 messages to perform a handshake with a node flavored remote target. + +.. code-block:: js + + Chrome: {"id":1,"method":"Runtime.enable","params":{}} + Javet Notification: {"method":"Runtime.executionContextCreated","params":{"context":{"id":1,"origin":"","name":"Javet Inspector 00000000","uniqueId":"00000000.00000000"}}} + Javet Response: {"id":1,"result":{}} + Chrome: {"id":2,"method":"Debugger.enable","params":{"maxScriptsCacheSize":100000000}} + Javet Response: {"id":2,"result":{"debuggerId":"00000000.00000000"}} + Chrome: {"id":3,"method":"Debugger.setPauseOnExceptions","params":{"state":"none"}} + Javet Response: {"id":3,"result":{}} + Chrome: {"id":4,"method":"Debugger.setAsyncCallStackDepth","params":{"maxDepth":32}} + Javet Response: {"id":4,"result":{}} + Chrome: {"id":5,"method":"Profiler.enable","params":{}} + Javet Response: {"id":5,"result":{}} + Chrome: {"id":6,"method":"Runtime.getIsolateId","params":{}} + Javet Response: {"id":6,"result":{"id":"00000000"}} + Chrome: {"id":7,"method":"Debugger.setBlackboxPatterns","params":{"patterns":[]}} + Javet Response: {"id":7,"result":{}} + Chrome: {"id":8,"method":"Runtime.runIfWaitingForDebugger","params":{}} + Javet Response: {"id":8,"result":{}} + +.. note:: + + Method ``Runtime.runIfWaitingForDebugger`` can be regarded as the handshake completion and there is no need to parse this message because it is exposed as a callback in ``IV8InspectorListener``. + +Actually, inside V8, the first message can enable the debugging without the rest of them. Please refer to the :extsource2:`source code <../../src/test/java/com/caoccao/javet/interop/TestV8Inspector.java>` for details. + +Customization +============= + +Yes, please feel free to customize the debugging server in your environment. CDT Shell is created as a showcase for further customization. Here are some tips. + +* Integrate with your HTTP and WebSocket servers. CDT Shell currently uses embedded Jetty. Be careful, HTTP and WebSocket servers need to be hosted together, otherwise, CDT refuses to communicate with the WebSocket server. +* Add your ``IV8InspectorListener`` to intercept all the event messages. In practice, a decent JSON library like JackSon, GSon may help interpret those messages. As a demo, CDT Shell doesn't process those messages. Why intercept those messages? Because: + + * To set up breakpoints before script is executed. + * To send messages to CDT right after CDT is connected. + * To turn on / off certain features. + * To enforce authentication and authorization. + * To switch among V8 runtimes. + +FAQs +==== + +Does it Support Node.js Mode? +----------------------------- + +Yes, Javet V8 inspector supports the Node.js Mode as well as the V8 mode though the built-in Node.js inspector is disabled because of some other issues. Please visit :doc:`../faq/development/why_is_the_inspector_disabled_in_node_js_mode` for more details. + +Is There a Live Demo? +--------------------- + +Yes, `JavetShell `_ provides a live demo via either a jar file or a docker image. diff --git a/docs/development/design.html b/docs/development/design.html index cce1359e0..9d642f799 100644 --- a/docs/development/design.html +++ b/docs/development/design.html @@ -6,7 +6,7 @@ - Javet Design - Javet 3.0.2 documentation + Javet Design - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/development/index.html b/docs/development/index.html index dd92e315f..0a58ad1c4 100644 --- a/docs/development/index.html +++ b/docs/development/index.html @@ -6,7 +6,7 @@ - Development - Javet 3.0.2 documentation + Development - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/development/performance.html b/docs/development/performance.html index 5d9c5e9f5..6f8cefe13 100644 --- a/docs/development/performance.html +++ b/docs/development/performance.html @@ -6,7 +6,7 @@ - Javet Performance - Javet 3.0.2 documentation + Javet Performance - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/development/test.html b/docs/development/test.html index 89880fb0d..55616f0e9 100644 --- a/docs/development/test.html +++ b/docs/development/test.html @@ -6,7 +6,7 @@ - Test Javet - Javet 3.0.2 documentation + Test Javet - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/development/tools.html b/docs/development/tools.html index 36a29b17d..8f245b052 100644 --- a/docs/development/tools.html +++ b/docs/development/tools.html @@ -6,7 +6,7 @@ - Development Tools - Javet 3.0.2 documentation + Development Tools - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/faq/background/history_with_j2v8.html b/docs/faq/background/history_with_j2v8.html index 710c17de4..b2e943e0c 100644 --- a/docs/faq/background/history_with_j2v8.html +++ b/docs/faq/background/history_with_j2v8.html @@ -6,7 +6,7 @@ - History with J2V8 - Javet 3.0.2 documentation + History with J2V8 - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -448,7 +451,7 @@

    Why not Deploy J2V8 to Maven Repository? +

    diff --git a/docs/faq/background/index.html b/docs/faq/background/index.html index cb65743a9..d893fe543 100644 --- a/docs/faq/background/index.html +++ b/docs/faq/background/index.html @@ -6,7 +6,7 @@ - Background - Javet 3.0.2 documentation + Background - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/faq/background/what_is_the_motivation.html b/docs/faq/background/what_is_the_motivation.html index e7b45c140..11b524789 100644 --- a/docs/faq/background/what_is_the_motivation.html +++ b/docs/faq/background/what_is_the_motivation.html @@ -6,7 +6,7 @@ - What is the Motivation? - Javet 3.0.2 documentation + What is the Motivation? - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/faq/development/how_to_think_in_javet.html b/docs/faq/development/how_to_think_in_javet.html index 75d9bfa82..948064928 100644 --- a/docs/faq/development/how_to_think_in_javet.html +++ b/docs/faq/development/how_to_think_in_javet.html @@ -6,7 +6,7 @@ - How to Think in Javet? - Javet 3.0.2 documentation + How to Think in Javet? - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/faq/development/index.html b/docs/faq/development/index.html index 8d328e68d..2c6300601 100644 --- a/docs/faq/development/index.html +++ b/docs/faq/development/index.html @@ -6,7 +6,7 @@ - Development - Javet 3.0.2 documentation + Development - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/faq/development/where_are_es6_api_in_v8_mode.html b/docs/faq/development/where_are_es6_api_in_v8_mode.html index 880a44150..fb603f0cd 100644 --- a/docs/faq/development/where_are_es6_api_in_v8_mode.html +++ b/docs/faq/development/where_are_es6_api_in_v8_mode.html @@ -6,7 +6,7 @@ - Where are ES6 API in V8 Mode? - Javet 3.0.2 documentation + Where are ES6 API in V8 Mode? - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/faq/development/where_are_the_examples.html b/docs/faq/development/where_are_the_examples.html index 25ea9ed3b..895f4c6f7 100644 --- a/docs/faq/development/where_are_the_examples.html +++ b/docs/faq/development/where_are_the_examples.html @@ -6,7 +6,7 @@ - Where are the Examples? - Javet 3.0.2 documentation + Where are the Examples? - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/faq/development/why_is_the_inspector_disabled_in_node_js_mode.html b/docs/faq/development/why_is_the_inspector_disabled_in_node_js_mode.html index 9b1e35b42..1f813c7ad 100644 --- a/docs/faq/development/why_is_the_inspector_disabled_in_node_js_mode.html +++ b/docs/faq/development/why_is_the_inspector_disabled_in_node_js_mode.html @@ -6,7 +6,7 @@ - Why is the Inspector Disabled in Node.js Mode? - Javet 3.0.2 documentation + Why is the Inspector Disabled in Node.js Mode? - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -304,7 +307,12 @@

    Why is the Inspector Disabled in Node.js Mode?Agent::Start(...), CHECK_EQ(start_io_thread_async_initialized.exchange(true), false); makes sure that static std::atomic_bool start_io_thread_async_initialized; is flipped from false to true, then crashes if Agent::Start(...) is called again. Creating a NodeRuntime instance triggers that call and there is no workaround. The crash is inevitable.

    The hacky option is to change the Node.js source code. But that scope would be too large because that implies changing the fundamental design of the inspector. I don't think the Node.js community would accept that.

    -

    So, please debug the JavaScript applications in Node.js with the inspector. Or... contact the maintainer for a private build with the inspector enabled.

    +

    Here are 3 options.

    +
      +
    1. Debug the JavaScript applications in Node.js with the inspector.

    2. +
    3. Use the Javet V8 inspector instead. Please visit Debug with Chrome Developer Tools for more details.

    4. +
    5. Contact the maintainer for a private build with the inspector enabled.

    6. +
    @@ -355,7 +363,7 @@

    Why is the Inspector Disabled in Node.js Mode? +

    diff --git a/docs/faq/development/why_is_the_inspector_disabled_in_node_js_mode.rst b/docs/faq/development/why_is_the_inspector_disabled_in_node_js_mode.rst index 545e8e749..930b00b44 100644 --- a/docs/faq/development/why_is_the_inspector_disabled_in_node_js_mode.rst +++ b/docs/faq/development/why_is_the_inspector_disabled_in_node_js_mode.rst @@ -10,4 +10,8 @@ Node.js has only one IO thread serving the inspector agent. In side the function The hacky option is to change the Node.js source code. But that scope would be too large because that implies changing the fundamental design of the inspector. I don't think the Node.js community would accept that. -So, please debug the JavaScript applications in Node.js with the inspector. Or... contact the maintainer for a private build with the inspector enabled. +Here are 3 options. + +1. Debug the JavaScript applications in Node.js with the inspector. +2. Use the Javet V8 inspector instead. Please visit :doc:`../../development/debug_with_chrome_developer_tools` for more details. +3. Contact the maintainer for a private build with the inspector enabled. diff --git a/docs/faq/environment/can_javet_support_legacy_linux.html b/docs/faq/environment/can_javet_support_legacy_linux.html index 026225152..26e8ec389 100644 --- a/docs/faq/environment/can_javet_support_legacy_linux.html +++ b/docs/faq/environment/can_javet_support_legacy_linux.html @@ -6,7 +6,7 @@ - Can Javet Support Legacy Linux? - Javet 3.0.2 documentation + Can Javet Support Legacy Linux? - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/faq/environment/index.html b/docs/faq/environment/index.html index 692e4a841..b528cf9d9 100644 --- a/docs/faq/environment/index.html +++ b/docs/faq/environment/index.html @@ -6,7 +6,7 @@ - Environment - Javet 3.0.2 documentation + Environment - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/faq/index.html b/docs/faq/index.html index c85e37e07..d6d09b0cc 100644 --- a/docs/faq/index.html +++ b/docs/faq/index.html @@ -6,7 +6,7 @@ - FAQ - Javet 3.0.2 documentation + FAQ - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/faq/troubleshooting/a_dynamic_link_library_dll_initialization_routine_failed.html b/docs/faq/troubleshooting/a_dynamic_link_library_dll_initialization_routine_failed.html index 55ec35a70..14df9d388 100644 --- a/docs/faq/troubleshooting/a_dynamic_link_library_dll_initialization_routine_failed.html +++ b/docs/faq/troubleshooting/a_dynamic_link_library_dll_initialization_routine_failed.html @@ -6,7 +6,7 @@ - A dynamic link library (DLL) initialization routine failed - Javet 3.0.2 documentation + A dynamic link library (DLL) initialization routine failed - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -351,7 +354,7 @@

    A dynamic link library (DLL) initialization routine failed +

    diff --git a/docs/faq/troubleshooting/can_i18n_be_supported.html b/docs/faq/troubleshooting/can_i18n_be_supported.html index d258fcad3..761553368 100644 --- a/docs/faq/troubleshooting/can_i18n_be_supported.html +++ b/docs/faq/troubleshooting/can_i18n_be_supported.html @@ -6,7 +6,7 @@ - Can i18n be Supported? - Javet 3.0.2 documentation + Can i18n be Supported? - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/faq/troubleshooting/can_i_debug_javet_in_chrome_dev_tools.html b/docs/faq/troubleshooting/can_i_debug_javet_in_chrome_dev_tools.html index 3365e680e..92ffd7d86 100644 --- a/docs/faq/troubleshooting/can_i_debug_javet_in_chrome_dev_tools.html +++ b/docs/faq/troubleshooting/can_i_debug_javet_in_chrome_dev_tools.html @@ -3,10 +3,10 @@ - + - Can I Debug Javet in Chrome DevTools? - Javet 3.0.2 documentation + Can I Debug Javet in Chrome DevTools? - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/faq/troubleshooting/index.html b/docs/faq/troubleshooting/index.html index 3cb76e9e4..a4fae3b9f 100644 --- a/docs/faq/troubleshooting/index.html +++ b/docs/faq/troubleshooting/index.html @@ -6,7 +6,7 @@ - Troubleshooting - Javet 3.0.2 documentation + Troubleshooting - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ @@ -358,7 +362,7 @@

    Troubleshooting + diff --git a/docs/faq/troubleshooting/sigsegv_at_createv8runtime_in_v8_mode_on_aws.html b/docs/faq/troubleshooting/sigsegv_at_createv8runtime_in_v8_mode_on_aws.html new file mode 100644 index 000000000..2c0d6712f --- /dev/null +++ b/docs/faq/troubleshooting/sigsegv_at_createv8runtime_in_v8_mode_on_aws.html @@ -0,0 +1,463 @@ + + + + + + + + + SIGSEGV at createV8Runtime() in V8 Mode on AWS - Javet 3.0.3 documentation + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + + + + + Back to top + +
    + +
    + +
    + +
    +
    +
    +

    SIGSEGV at createV8Runtime() in V8 Mode on AWS#

    +
    +

    Symptoms#

    +

    Sometimes creating multiple Javet engines meets SIGSEGV at createV8Runtime() in V8 mode on AWS.

    +
    import com.caoccao.javet.enums.JSRuntimeType;
    +import com.caoccao.javet.interop.V8Runtime;
    +import com.caoccao.javet.interop.engine.IJavetEngine;
    +import com.caoccao.javet.interop.engine.JavetEnginePool;
    +
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +public class TestCrash {
    +    public static void main(String[] args) throws Exception {
    +        final int threadCount;
    +        if (args.length > 0) {
    +            final String arg = args[0];
    +            threadCount = Integer.parseInt(arg);
    +            System.out.println("Using threads from args: " + threadCount);
    +        } else {
    +            threadCount = 5;
    +            System.out.println("Using threads from default: " + threadCount);
    +        }
    +        final List<Thread> threadList = new ArrayList<>();
    +        for (int i = 0; i < threadCount; i++) {
    +            final Thread thread = new Thread(() -> {
    +                try (final JavetEnginePool<V8Runtime> enginePool = new JavetEnginePool<>()) {
    +                    System.out.println("Created engine pool");
    +                    enginePool.getConfig().setJSRuntimeType(JSRuntimeType.V8);
    +                    try (final IJavetEngine<V8Runtime> engine = enginePool.getEngine()) {
    +                        // This will not be reached for threadCount >= 2
    +                        System.out.println("Created engine");
    +                    }
    +                } catch (Throwable t) {
    +                    t.printStackTrace(System.err);
    +                }
    +            });
    +            threadList.add(thread);
    +            thread.start();
    +        }
    +        for (Thread thread : threadList) {
    +            thread.join();
    +        }
    +        System.out.println("Quit peacefully.");
    +    }
    +}
    +
    +
    +
    +
    +

    Analysis#

    +

    The root cause seems that the V8 memory protection key is not properly initialized in very few VM environments with specific CPU models. The changes were committed on May 26, 2023. That causes Javet v3.0.0+ to have this issue.

    +

    As the SIGSEGV only occurs on Linux x86_64 with small set of CPUs, the solution is expected to be only applied to Linux x86_64 build.

    +
    +
    +

    Solutions#

    +
    +

    Solution 1: Enforce the Initialization#

    +

    Execute the following code in the main thread during the application initialization to force V8 to initialize.

    +
    try (V8Runtime v8Runtime = V8Host.getV8Instance().createV8Runtime()) {
    +}
    +
    +
    +

    Why does this trick work?

    +

    V8 stores memory protection key flag in a global storage called ThreadIsolation. ThreadIsolation's initialization is broken in some Fedora based Linux distributions inside KVM.

    +

    A full cycle of V8Runtime ensures ThreadIsolation's initialization is performed successfully.

    +
    +
    +

    Solution 2: Set Environment Variable JAVET_DISABLE_PKU#

    +

    Add an environment variable JAVET_DISABLE_PKU before the application is started.

    +
    export JAVET_DISABLE_PKU=1
    +
    +
    +

    Why does this trick work?

    +

    V8 source code is patched to consume the environment variable JAVET_DISABLE_PKU so that a Linx kernel feature Memory Protection Keys is disabled.

    +
    +
    +
    + +
    +
    + +
    + +
    +
    + + + + + + \ No newline at end of file diff --git a/docs/faq/troubleshooting/sigsegv_at_createv8runtime_in_v8_mode_on_aws.rst b/docs/faq/troubleshooting/sigsegv_at_createv8runtime_in_v8_mode_on_aws.rst new file mode 100644 index 000000000..9a9984460 --- /dev/null +++ b/docs/faq/troubleshooting/sigsegv_at_createv8runtime_in_v8_mode_on_aws.rst @@ -0,0 +1,92 @@ +============================================== +SIGSEGV at createV8Runtime() in V8 Mode on AWS +============================================== + +Symptoms +======== + +Sometimes creating multiple Javet engines meets SIGSEGV at ``createV8Runtime()`` in V8 mode on AWS. + +.. code-block:: java + + import com.caoccao.javet.enums.JSRuntimeType; + import com.caoccao.javet.interop.V8Runtime; + import com.caoccao.javet.interop.engine.IJavetEngine; + import com.caoccao.javet.interop.engine.JavetEnginePool; + + import java.util.ArrayList; + import java.util.List; + + public class TestCrash { + public static void main(String[] args) throws Exception { + final int threadCount; + if (args.length > 0) { + final String arg = args[0]; + threadCount = Integer.parseInt(arg); + System.out.println("Using threads from args: " + threadCount); + } else { + threadCount = 5; + System.out.println("Using threads from default: " + threadCount); + } + final List threadList = new ArrayList<>(); + for (int i = 0; i < threadCount; i++) { + final Thread thread = new Thread(() -> { + try (final JavetEnginePool enginePool = new JavetEnginePool<>()) { + System.out.println("Created engine pool"); + enginePool.getConfig().setJSRuntimeType(JSRuntimeType.V8); + try (final IJavetEngine engine = enginePool.getEngine()) { + // This will not be reached for threadCount >= 2 + System.out.println("Created engine"); + } + } catch (Throwable t) { + t.printStackTrace(System.err); + } + }); + threadList.add(thread); + thread.start(); + } + for (Thread thread : threadList) { + thread.join(); + } + System.out.println("Quit peacefully."); + } + } + +Analysis +======== + +The root cause seems that the V8 memory protection key is not properly initialized in very few VM environments with specific CPU models. The changes were committed on May 26, 2023. That causes Javet v3.0.0+ to have this issue. + +As the SIGSEGV only occurs on Linux x86_64 with small set of CPUs, the solution is expected to be only applied to Linux x86_64 build. + +Solutions +========= + +Solution 1: Enforce the Initialization +-------------------------------------- + +Execute the following code in the main thread during the application initialization to force V8 to initialize. + +.. code-block:: java + + try (V8Runtime v8Runtime = V8Host.getV8Instance().createV8Runtime()) { + } + +Why does this trick work? + +V8 stores memory protection key flag in a global storage called ``ThreadIsolation``. ``ThreadIsolation``'s initialization is broken in some Fedora based Linux distributions inside KVM. + +A full cycle of V8Runtime ensures ``ThreadIsolation``'s initialization is performed successfully. + +Solution 2: Set Environment Variable JAVET_DISABLE_PKU +------------------------------------------------------ + +Add an environment variable ``JAVET_DISABLE_PKU`` before the application is started. + +.. code-block:: shell + + export JAVET_DISABLE_PKU=1 + +Why does this trick work? + +V8 source code is patched to consume the environment variable ``JAVET_DISABLE_PKU`` so that a Linx kernel feature `Memory Protection Keys `_ is disabled. diff --git a/docs/faq/troubleshooting/why_node_js_crashes_when_being_closed.html b/docs/faq/troubleshooting/why_node_js_crashes_when_being_closed.html index 720033014..a79e06fa3 100644 --- a/docs/faq/troubleshooting/why_node_js_crashes_when_being_closed.html +++ b/docs/faq/troubleshooting/why_node_js_crashes_when_being_closed.html @@ -3,10 +3,10 @@ - + - Why Node.js Crashes When being Closed? - Javet 3.0.2 documentation + Why Node.js Crashes When being Closed? - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/genindex.html b/docs/genindex.html index c56ae426a..d78a4267f 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -4,7 +4,7 @@ - Index - Javet 3.0.2 documentation + Index - Javet 3.0.3 documentation @@ -123,7 +123,7 @@ - + diff --git a/docs/index.html b/docs/index.html index 4894e4f2b..69c28ec9c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,7 +6,7 @@ - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -347,7 +350,7 @@

    Major Features -
  • Node.js v20.10.0 + V8 v12.0.267.8

  • +
  • Node.js v20.11.0 + V8 v12.1.285.26

  • Dynamic switch between Node.js and V8 mode (Which mode do you prefer?)

  • Polyfill V8 mode with Javenode

  • V8 API exposure in JVM

  • @@ -356,7 +359,8 @@

    Major FeaturesJavetSanitizer

    +
  • AST analysis with JavetSanitizer

  • +
  • Live interaction with JavetShell

  • @@ -369,40 +373,40 @@

    Maven#< <dependency> <groupId>com.caoccao.javet</groupId> <artifactId>javet</artifactId> - <version>3.0.2</version> + <version>3.0.3</version> </dependency> <!-- Linux (arm64) --> <dependency> <groupId>com.caoccao.javet</groupId> <artifactId>javet-linux-arm64</artifactId> - <version>3.0.2</version> + <version>3.0.3</version> </dependency> <!-- Mac OS (x86_64 and arm64) --> <dependency> <groupId>com.caoccao.javet</groupId> <artifactId>javet-macos</artifactId> - <version>3.0.2</version> + <version>3.0.3</version> </dependency>

    Gradle Kotlin DSL#

    -
    implementation("com.caoccao.javet:javet:3.0.2") // Linux and Windows (x86_64)
    -implementation("com.caoccao.javet:javet-linux-arm64:3.0.2") // Linux (arm64)
    -implementation("com.caoccao.javet:javet-macos:3.0.2") // Mac OS (x86_64 and arm64)
    -implementation("com.caoccao.javet:javet-android:3.0.2") // Android (arm, arm64, x86 and x86_64)
    +
    implementation("com.caoccao.javet:javet:3.0.3") // Linux and Windows (x86_64)
    +implementation("com.caoccao.javet:javet-linux-arm64:3.0.3") // Linux (arm64)
    +implementation("com.caoccao.javet:javet-macos:3.0.3") // Mac OS (x86_64 and arm64)
    +implementation("com.caoccao.javet:javet-android:3.0.3") // Android (arm, arm64, x86 and x86_64)
     

    Gradle Groovy DSL#

    -
    implementation 'com.caoccao.javet:javet:3.0.2' // Linux and Windows (x86_64)
    -implementation 'com.caoccao.javet:javet-linux-arm64:3.0.2' // Linux (arm64)
    -implementation 'com.caoccao.javet:javet-macos:3.0.2' // Mac OS (x86_64 and arm64)
    -implementation 'com.caoccao.javet:javet-android:3.0.2' // Android (arm, arm64, x86 and x86_64)
    +
    implementation 'com.caoccao.javet:javet:3.0.3' // Linux and Windows (x86_64)
    +implementation 'com.caoccao.javet:javet-linux-arm64:3.0.3' // Linux (arm64)
    +implementation 'com.caoccao.javet:javet-macos:3.0.3' // Mac OS (x86_64 and arm64)
    +implementation 'com.caoccao.javet:javet-android:3.0.3' // Android (arm, arm64, x86 and x86_64)
     
    @@ -524,7 +528,7 @@

    Documents + diff --git a/docs/index.rst b/docs/index.rst index edea2b0b4..c6ad05209 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,6 +1,6 @@ .. include:: ../README.rst :start-line: 0 - :end-line: 143 + :end-line: 144 .. toctree:: :maxdepth: 2 diff --git a/docs/reference/converters/bridge_converter.html b/docs/reference/converters/bridge_converter.html index 09e0bfa1f..db49576f5 100644 --- a/docs/reference/converters/bridge_converter.html +++ b/docs/reference/converters/bridge_converter.html @@ -6,7 +6,7 @@ - Bridge Converter - Javet 3.0.2 documentation + Bridge Converter - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -489,7 +492,7 @@

    How to Cast Java Objects to JavaScript Objects? +

    diff --git a/docs/reference/converters/custom_converter.html b/docs/reference/converters/custom_converter.html index 9c11a6e57..ee5303fa7 100644 --- a/docs/reference/converters/custom_converter.html +++ b/docs/reference/converters/custom_converter.html @@ -6,7 +6,7 @@ - Custom Converter - Javet 3.0.2 documentation + Custom Converter - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/reference/converters/index.html b/docs/reference/converters/index.html index 219b764c8..f0460d93a 100644 --- a/docs/reference/converters/index.html +++ b/docs/reference/converters/index.html @@ -6,7 +6,7 @@ - Converters - Javet 3.0.2 documentation + Converters - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/reference/converters/object_converter.html b/docs/reference/converters/object_converter.html index 230957c1a..87d24d731 100644 --- a/docs/reference/converters/object_converter.html +++ b/docs/reference/converters/object_converter.html @@ -6,7 +6,7 @@ - Object Converter - Javet 3.0.2 documentation + Object Converter - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/reference/converters/primitive_converter.html b/docs/reference/converters/primitive_converter.html index c8d6557b4..c5dc3d558 100644 --- a/docs/reference/converters/primitive_converter.html +++ b/docs/reference/converters/primitive_converter.html @@ -6,7 +6,7 @@ - Primitive Converter - Javet 3.0.2 documentation + Primitive Converter - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/reference/converters/proxy_converter.html b/docs/reference/converters/proxy_converter.html index 4057bbf10..daa558b39 100644 --- a/docs/reference/converters/proxy_converter.html +++ b/docs/reference/converters/proxy_converter.html @@ -6,7 +6,7 @@ - Proxy Converter - Javet 3.0.2 documentation + Proxy Converter - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -328,13 +331,53 @@

    Instance: File +

    Instance: List#

    +
    javetProxyConverter.getConfig().setProxyListEnabled(true);
    +List<String> list = SimpleList.of("x", "y");
    +v8Runtime.getGlobalObject().set("list", list);
    +assertSame(list, v8Runtime.getGlobalObject().getObject("list"));
    +// contains
    +assertTrue(v8Runtime.getExecutor("list.contains('x')").executeBoolean());
    +assertTrue(v8Runtime.getExecutor("list.contains('y')").executeBoolean());
    +assertFalse(v8Runtime.getExecutor("list.contains('z')").executeBoolean());
    +// includes
    +assertTrue(v8Runtime.getExecutor("list.includes('x')").executeBoolean());
    +assertFalse(v8Runtime.getExecutor("list.includes('x', 1)").executeBoolean());
    +assertTrue(v8Runtime.getExecutor("list.includes('y', 1)").executeBoolean());
    +// push
    +assertEquals(4, v8Runtime.getExecutor("list.push('z', '1')").executeInteger());
    +assertTrue(v8Runtime.getExecutor("list.includes('z')").executeBoolean());
    +// pop
    +assertEquals("1", v8Runtime.getExecutor("list.pop()").executeString());
    +// toJSON
    +assertEquals(
    +        "[\"x\",\"y\",\"z\"]",
    +        v8Runtime.getExecutor("JSON.stringify(list);").executeString());
    +// Symbol.iterator
    +assertEquals(
    +        "[\"x\",\"y\",\"z\"]",
    +        v8Runtime.getExecutor("JSON.stringify([...list]);").executeString());
    +// unshift
    +assertEquals(5, v8Runtime.getExecutor("list.unshift('1', '2')").executeInteger());
    +// shift
    +assertEquals("1", v8Runtime.getExecutor("list.shift()").executeString());
    +assertEquals("2", v8Runtime.getExecutor("list.shift()").executeString());
    +// delete
    +assertTrue(v8Runtime.getExecutor("delete list[2]").executeBoolean());
    +assertEquals(2, v8Runtime.getExecutor("list.size()").executeInteger());
    +// length
    +assertEquals(2, v8Runtime.getExecutor("list.length").executeInteger());
    +v8Runtime.getGlobalObject().delete("list");
    +v8Runtime.lowMemoryNotification();
    +javetProxyConverter.getConfig().setProxyListEnabled(false);
    +
    +
    +

    Instance: Map#

    javetProxyConverter.getConfig().setProxyMapEnabled(true);
    -Map<String, Object> map = new HashMap<String, Object>() {{
    -    put("x", 1);
    -    put("y", "2");
    -}};
    +Map<String, Object> map = SimpleMap.of("x", 1, "y", "2");
     v8Runtime.getGlobalObject().set("map", map);
     assertTrue(map == v8Runtime.getGlobalObject().getObject("map"));
     assertEquals(1, v8Runtime.getExecutor("map['x']").executeInteger());
    @@ -345,6 +388,16 @@ 

    Instance: MapassertEquals("3", map.get("z")); assertEquals("4", v8Runtime.getExecutor("map.z = '4'; map.z;").executeString()); assertEquals("4", map.get("z")); +assertEquals( + "[\"x\",\"y\",\"z\"]", + v8Runtime.getExecutor("JSON.stringify(Object.getOwnPropertyNames(map));").executeString()); +assertTrue(v8Runtime.getExecutor("delete map['x']").executeBoolean()); +assertFalse(map.containsKey("x")); +assertTrue(v8Runtime.getExecutor("delete map['y']").executeBoolean()); +assertFalse(map.containsKey("y")); +assertEquals( + "{\"z\":\"z\"}", + v8Runtime.getExecutor("JSON.stringify(map);").executeString()); v8Runtime.getGlobalObject().delete("map"); v8Runtime.lowMemoryNotification(); javetProxyConverter.getConfig().setProxyMapEnabled(false); @@ -366,6 +419,35 @@

    Instance: Path +

    Instance: Set#

    +
    javetProxyConverter.getConfig().setProxySetEnabled(true);
    +Set<String> set = SimpleSet.of("x", "y");
    +v8Runtime.getGlobalObject().set("set", set);
    +assertSame(set, v8Runtime.getGlobalObject().getObject("set"));
    +assertTrue(v8Runtime.getExecutor("set.contains('x')").executeBoolean());
    +assertTrue(v8Runtime.getExecutor("set.contains('y')").executeBoolean());
    +assertFalse(v8Runtime.getExecutor("set.contains('z')").executeBoolean());
    +assertFalse(v8Runtime.getExecutor("set.has('z')").executeBoolean());
    +assertTrue(v8Runtime.getExecutor("set.add('z')").executeBoolean());
    +assertTrue(v8Runtime.getExecutor("set.contains('z')").executeBoolean());
    +assertTrue(v8Runtime.getExecutor("set.has('z')").executeBoolean());
    +assertEquals(
    +        "[\"x\",\"y\",\"z\"]",
    +        v8Runtime.getExecutor("JSON.stringify(Object.getOwnPropertyNames(set));").executeString());
    +assertEquals(
    +        "[\"x\",\"y\",\"z\"]",
    +        v8Runtime.getExecutor("const keys = []; for (let key of set.keys()) { keys.push(key); } JSON.stringify(keys);").executeString());
    +assertTrue(v8Runtime.getExecutor("set.delete('z')").executeBoolean());
    +assertFalse(v8Runtime.getExecutor("set.delete('z')").executeBoolean());
    +assertFalse(v8Runtime.getExecutor("set.has('z')").executeBoolean());
    +v8Runtime.getGlobalObject().delete("set");
    +v8Runtime.getGlobalObject().delete("set");
    +v8Runtime.lowMemoryNotification();
    +javetProxyConverter.getConfig().setProxySetEnabled(false);
    +
    +
    +

    Static: StringBuilder#

    v8Runtime.getGlobalObject().set("StringBuilder", StringBuilder.class);
    @@ -558,16 +640,16 @@ 

    Dynamic: Anonymous Object for Class<dependency> <groupId>net.bytebuddy</groupId> <artifactId>byte-buddy</artifactId> - <version>1.12.17</version> + <version>1.14.10</version> </dependency>

    // Gradle Kotlin DSL
    -implementation("net.bytebuddy:byte-buddy:1.12.17")
    +implementation("net.bytebuddy:byte-buddy:1.14.10")
     
    // Gradle Groovy DSL
    -implementation 'net.bytebuddy:byte-buddy:1.12.17'
    +implementation 'net.bytebuddy:byte-buddy:1.14.10'
     
      @@ -613,7 +695,12 @@

      Dynamic: Anonymous Object for Class

      Note

      -

      The JavaScript implementation is backed up by V8ValueObject which is an orphan object. After its internal V8Runtime is closed, it will no longer callable. It's recommended to have the interface implement AutoCloseable as the sample shows so that the orphan V8ValueObject can be recycled explicitly. If you don't own the interface, Javet will force the recycle of the orphan V8ValueObject when the V8Runtime is being closed. Be careful, if you keep the application running for long while without recycling them in time, OutOfMemoryError may occur.

      +

      The JavaScript implementation is backed up by V8ValueObject which is an orphan object. After its internal V8Runtime is closed, it will no longer be callable. It's recommended to have the interface or the object implement AutoCloseable as the sample shows so that the orphan V8ValueObject can be recycled explicitly.

      +

      If you don't own the interface or the object, there are 2 ways of recycling it to avoid memory leak.

      +
        +
      1. Manually calling System.gc(); System.runFinalization(); will recycle the orphan V8ValueObject via the Java garbage collector.

      2. +
      3. Javet will force the recycle of the orphan V8ValueObject when the V8Runtime is being closed. Be careful, if you keep the application running for long time without recycling them in time, OutOfMemoryError may occur. Of course, that is less likely going to happen because the Java garbage collector runs periodically.

      4. +

    @@ -753,8 +840,10 @@

    How to Customize JavetProxyConverter?Usage @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -361,7 +364,7 @@

    Reference + diff --git a/docs/reference/javadoc/allclasses-frame.html b/docs/reference/javadoc/allclasses-frame.html index fb1e1e272..aee089a85 100644 --- a/docs/reference/javadoc/allclasses-frame.html +++ b/docs/reference/javadoc/allclasses-frame.html @@ -3,7 +3,7 @@ -All Classes (javet 3.0.2 API) +All Classes (javet 3.0.3 API) @@ -11,13 +11,16 @@

    All Classes

      +
    • ArrayUtils
    • BaseJavetConsoleInterceptor
    • BaseJavetConverter
    • +
    • BaseJavetDirectCallableInterceptor
    • BaseJavetDirectProxyHandler
    • BaseJavetInterceptor
    • BaseJavetProxyHandler
    • BaseJavetProxySymbolConverter
    • BaseJavetReflectionProxyHandler
    • +
    • BaseJavetReflectionProxyInvocationHandler
    • BaseJavetScriptingException
    • BaseNodeModule
    • BaseV8Executor
    • @@ -57,6 +60,7 @@

      All Classes

    • IJavetMappable
    • IJavetPromiseRejectCallback
    • IJavetProxyHandler
    • +
    • IJavetProxyPolyfillFunction
    • IJavetProxySymbolConverter
    • IJavetReflectionObjectFactory
    • IJavetResettable
    • @@ -122,6 +126,7 @@

      All Classes

    • JavetException
    • JavetExecutionException
    • JavetGCCallback
    • +
    • JavetJVMInterceptor
    • JavetLibLoader
    • JavetLibLoadingListener
    • JavetObjectConverter
    • @@ -143,13 +148,13 @@

      All Classes

    • JavetResourceUtils
    • JavetScriptingError
    • JavetStandardConsoleInterceptor
    • -
    • JavetStringUtils
    • JavetTerminatedException
    • JavetTypeUtils
    • JavetVirtualObject
    • JSFunctionType
    • JSRuntimeType
    • JSScopeType
    • +
    • ListUtils
    • MethodDescriptor
    • NodeModule
    • NodeModuleAny
    • @@ -159,7 +164,10 @@

      All Classes

    • NodeRuntimeOptions
    • RuntimeOptions
    • SimpleFreeMarkerFormat
    • +
    • SimpleList
    • SimpleMap
    • +
    • SimpleSet
    • +
    • StringUtils
    • ThreadSafeMap
    • ThreadSafeMap.Type
    • V8AllocationSpace
    • diff --git a/docs/reference/javadoc/allclasses-noframe.html b/docs/reference/javadoc/allclasses-noframe.html index 693f50cc1..714fe3e45 100644 --- a/docs/reference/javadoc/allclasses-noframe.html +++ b/docs/reference/javadoc/allclasses-noframe.html @@ -3,7 +3,7 @@ -All Classes (javet 3.0.2 API) +All Classes (javet 3.0.3 API) @@ -11,13 +11,16 @@

      All Classes

        +
      • ArrayUtils
      • BaseJavetConsoleInterceptor
      • BaseJavetConverter
      • +
      • BaseJavetDirectCallableInterceptor
      • BaseJavetDirectProxyHandler
      • BaseJavetInterceptor
      • BaseJavetProxyHandler
      • BaseJavetProxySymbolConverter
      • BaseJavetReflectionProxyHandler
      • +
      • BaseJavetReflectionProxyInvocationHandler
      • BaseJavetScriptingException
      • BaseNodeModule
      • BaseV8Executor
      • @@ -57,6 +60,7 @@

        All Classes

      • IJavetMappable
      • IJavetPromiseRejectCallback
      • IJavetProxyHandler
      • +
      • IJavetProxyPolyfillFunction
      • IJavetProxySymbolConverter
      • IJavetReflectionObjectFactory
      • IJavetResettable
      • @@ -122,6 +126,7 @@

        All Classes

      • JavetException
      • JavetExecutionException
      • JavetGCCallback
      • +
      • JavetJVMInterceptor
      • JavetLibLoader
      • JavetLibLoadingListener
      • JavetObjectConverter
      • @@ -143,13 +148,13 @@

        All Classes

      • JavetResourceUtils
      • JavetScriptingError
      • JavetStandardConsoleInterceptor
      • -
      • JavetStringUtils
      • JavetTerminatedException
      • JavetTypeUtils
      • JavetVirtualObject
      • JSFunctionType
      • JSRuntimeType
      • JSScopeType
      • +
      • ListUtils
      • MethodDescriptor
      • NodeModule
      • NodeModuleAny
      • @@ -159,7 +164,10 @@

        All Classes

      • NodeRuntimeOptions
      • RuntimeOptions
      • SimpleFreeMarkerFormat
      • +
      • SimpleList
      • SimpleMap
      • +
      • SimpleSet
      • +
      • StringUtils
      • ThreadSafeMap
      • ThreadSafeMap.Type
      • V8AllocationSpace
      • diff --git a/docs/reference/javadoc/com/caoccao/javet/annotations/CheckReturnValue.html b/docs/reference/javadoc/com/caoccao/javet/annotations/CheckReturnValue.html index af278fe6e..a7bda7421 100644 --- a/docs/reference/javadoc/com/caoccao/javet/annotations/CheckReturnValue.html +++ b/docs/reference/javadoc/com/caoccao/javet/annotations/CheckReturnValue.html @@ -3,7 +3,7 @@ -CheckReturnValue (javet 3.0.2 API) +CheckReturnValue (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/annotations/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/annotations/package-summary.html index fdb78880b..8e16b2446 100644 --- a/docs/reference/javadoc/com/caoccao/javet/annotations/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/annotations/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.annotations (javet 3.0.2 API) +com.caoccao.javet.annotations (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/entities/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/entities/package-summary.html index 879a18a43..3651c6b8a 100644 --- a/docs/reference/javadoc/com/caoccao/javet/entities/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/entities/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.entities (javet 3.0.2 API) +com.caoccao.javet.entities (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/enums/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/enums/package-summary.html index 0e56ad91e..db4eb3c1a 100644 --- a/docs/reference/javadoc/com/caoccao/javet/enums/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/enums/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.enums (javet 3.0.2 API) +com.caoccao.javet.enums (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/exceptions/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/exceptions/package-summary.html index d3c11e4c0..c062e66df 100644 --- a/docs/reference/javadoc/com/caoccao/javet/exceptions/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/exceptions/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.exceptions (javet 3.0.2 API) +com.caoccao.javet.exceptions (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ + + + + + + + + + +
        +
        com.caoccao.javet.interception
        +

        Class BaseJavetDirectCallableInterceptor

        +
        +
        + +
        + +
        +
        + +
        +
        +
          +
        • + +
            +
          • + + +

            Constructor Detail

            + + + +
              +
            • +

              BaseJavetDirectCallableInterceptor

              +
              public BaseJavetDirectCallableInterceptor(V8Runtime v8Runtime)
              +
              Instantiates a new Base javet direct callable interceptor.
              +
              +
              Parameters:
              +
              v8Runtime - the V8 runtime
              +
              Since:
              +
              3.0.3
              +
              +
            • +
            +
          • +
          +
        • +
        +
        +
        + + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/interception/BaseJavetInterceptor.html b/docs/reference/javadoc/com/caoccao/javet/interception/BaseJavetInterceptor.html index 8a279ac3a..f863d469b 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interception/BaseJavetInterceptor.html +++ b/docs/reference/javadoc/com/caoccao/javet/interception/BaseJavetInterceptor.html @@ -3,7 +3,7 @@ -BaseJavetInterceptor (javet 3.0.2 API) +BaseJavetInterceptor (javet 3.0.3 API) @@ -11,7 +11,7 @@ + + + + + + + + + +
        +
        com.caoccao.javet.interception.jvm
        +

        Class JavetJVMInterceptor

        +
        +
        + +
        +
          +
        • +
          +
          All Implemented Interfaces:
          +
          IJavetInterceptor, IJavetDirectCallable
          +
          +
          +
          +
          public class JavetJVMInterceptor
          +extends BaseJavetDirectCallableInterceptor
          +
          The Javet JVM interceptor exposes the whole JVM as javet in V8. + It must be accompanied by JavetProxyConverter. +

          + Usages: + + let sb = new javet.package.java.util.StringBuilder(); + sb.append(123).append('abc'); + sb.toString(); // 123abc + sb = undefined; + javet.v8.gc(); +

          +
          +
          Since:
          +
          3.0.3
          +
          +
        • +
        +
        +
        + +
        +
        +
          +
        • + +
            +
          • + + +

            Field Detail

            + + + +
              +
            • +

              DEFAULT_NAME

              +
              public static final java.lang.String DEFAULT_NAME
              +
              The constant DEFAULT_NAME.
              +
              +
              Since:
              +
              3.0.3
              +
              See Also:
              +
              Constant Field Values
              +
              +
            • +
            + + + +
              +
            • +

              ERROR_THE_CONVERTER_MUST_BE_INSTANCE_OF_JAVET_PROXY_CONVERTER

              +
              protected static final java.lang.String ERROR_THE_CONVERTER_MUST_BE_INSTANCE_OF_JAVET_PROXY_CONVERTER
              +
              The constant ERROR_THE_CONVERTER_MUST_BE_INSTANCE_OF_JAVET_PROXY_CONVERTER.
              +
              +
              Since:
              +
              3.0.3
              +
              See Also:
              +
              Constant Field Values
              +
              +
            • +
            + + + +
              +
            • +

              JAVET_PROXY_CONVERTER

              +
              protected static final JavetProxyConverter JAVET_PROXY_CONVERTER
              +
              The constant JAVET_PROXY_CONVERTER.
              +
              +
              Since:
              +
              3.0.3
              +
              +
            • +
            + + + +
              +
            • +

              JS_PROPERTY_PACKAGE

              +
              protected static final java.lang.String JS_PROPERTY_PACKAGE
              +
              The constant JS_PROPERTY_PACKAGE.
              +
              +
              Since:
              +
              3.0.3
              +
              See Also:
              +
              Constant Field Values
              +
              +
            • +
            + + + +
              +
            • +

              JS_PROPERTY_V8

              +
              protected static final java.lang.String JS_PROPERTY_V8
              +
              The constant JS_PROPERTY_V8.
              +
              +
              Since:
              +
              3.0.3
              +
              See Also:
              +
              Constant Field Values
              +
              +
            • +
            + + + +
              +
            • +

              name

              +
              protected java.lang.String name
              +
              The Name injected in V8.
              +
              +
              Since:
              +
              3.0.3
              +
              +
            • +
            +
          • +
          + +
            +
          • + + +

            Constructor Detail

            + + + +
              +
            • +

              JavetJVMInterceptor

              +
              public JavetJVMInterceptor(V8Runtime v8Runtime)
              +
              Instantiates a new Javet JVM interceptor.
              +
              +
              Parameters:
              +
              v8Runtime - the V8 runtime
              +
              Since:
              +
              3.0.3
              +
              +
            • +
            +
          • +
          + +
            +
          • + + +

            Method Detail

            + + + +
              +
            • +

              getCallbackContexts

              +
              public JavetCallbackContext[] getCallbackContexts()
              +
              Description copied from interface: IJavetDirectCallable
              +
              Get supported callback contexts.
              +
              +
              Returns:
              +
              the supported callback contexts
              +
              +
            • +
            + + + +
              +
            • +

              getName

              +
              public java.lang.String getName()
              +
              Gets name.
              +
              +
              Returns:
              +
              the name
              +
              Since:
              +
              3.0.3
              +
              +
            • +
            + + + + + + + +
              +
            • +

              setName

              +
              public void setName(java.lang.String name)
              +
              Sets name.
              +
              +
              Parameters:
              +
              name - the name
              +
              Since:
              +
              3.0.3
              +
              +
            • +
            + + + + +
          • +
          +
        • +
        +
        +
        + + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/interception/jvm/package-frame.html b/docs/reference/javadoc/com/caoccao/javet/interception/jvm/package-frame.html new file mode 100644 index 000000000..cf8f2c1f2 --- /dev/null +++ b/docs/reference/javadoc/com/caoccao/javet/interception/jvm/package-frame.html @@ -0,0 +1,19 @@ + + + + + +com.caoccao.javet.interception.jvm (javet 3.0.3 API) + + + + +

        com.caoccao.javet.interception.jvm

        +
        +

        Classes

        + +
        + + diff --git a/docs/reference/javadoc/com/caoccao/javet/interception/jvm/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interception/jvm/package-summary.html new file mode 100644 index 000000000..413465268 --- /dev/null +++ b/docs/reference/javadoc/com/caoccao/javet/interception/jvm/package-summary.html @@ -0,0 +1,141 @@ + + + + + +com.caoccao.javet.interception.jvm (javet 3.0.3 API) + + + + + + + + + + +
        +

        Package com.caoccao.javet.interception.jvm

        +
        +
        +
          +
        • + + + + + + + + + + + + +
          Class Summary 
          ClassDescription
          JavetJVMInterceptor +
          The Javet JVM interceptor exposes the whole JVM as javet in V8.
          +
          +
        • +
        +
        + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/interception/jvm/package-tree.html b/docs/reference/javadoc/com/caoccao/javet/interception/jvm/package-tree.html new file mode 100644 index 000000000..140019361 --- /dev/null +++ b/docs/reference/javadoc/com/caoccao/javet/interception/jvm/package-tree.html @@ -0,0 +1,142 @@ + + + + + +com.caoccao.javet.interception.jvm Class Hierarchy (javet 3.0.3 API) + + + + + + + + + + +
        +

        Hierarchy For Package com.caoccao.javet.interception.jvm

        +Package Hierarchies: + +
        +
        +

        Class Hierarchy

        + +
        + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/interception/logging/BaseJavetConsoleInterceptor.html b/docs/reference/javadoc/com/caoccao/javet/interception/logging/BaseJavetConsoleInterceptor.html index 37ba5e203..7819f54ca 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interception/logging/BaseJavetConsoleInterceptor.html +++ b/docs/reference/javadoc/com/caoccao/javet/interception/logging/BaseJavetConsoleInterceptor.html @@ -3,7 +3,7 @@ -BaseJavetConsoleInterceptor (javet 3.0.2 API) +BaseJavetConsoleInterceptor (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interception/logging/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interception/logging/package-summary.html index 60248c25d..21c6beb40 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interception/logging/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interception/logging/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interception.logging (javet 3.0.2 API) +com.caoccao.javet.interception.logging (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -12,6 +12,7 @@

        Classes

      diff --git a/docs/reference/javadoc/com/caoccao/javet/interception/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interception/package-summary.html index c84f583c7..f367a5240 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interception/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interception/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interception (javet 3.0.2 API) +com.caoccao.javet.interception (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interfaces/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interfaces/package-summary.html index 91dddce99..1fe6388ac 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interfaces/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interfaces/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interfaces (javet 3.0.2 API) +com.caoccao.javet.interfaces (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,13 +11,13 @@ @@ -11,13 +11,13 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,13 +11,13 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,13 +11,13 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/binding/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/binding/package-summary.html index bcac25852..4574003c0 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/binding/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/binding/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.binding (javet 3.0.2 API) +com.caoccao.javet.interop.binding (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/callback/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/callback/package-summary.html index e5d2f3502..59ae43abf 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/callback/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/callback/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.callback (javet 3.0.2 API) +com.caoccao.javet.interop.callback (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,13 +11,13 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/converters/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/converters/package-summary.html index a519a8908..efc8c6ebd 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/converters/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/converters/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.converters (javet 3.0.2 API) +com.caoccao.javet.interop.converters (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/engine/observers/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/engine/observers/package-summary.html index 027b6faee..434a2bfbe 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/engine/observers/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/engine/observers/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.engine.observers (javet 3.0.2 API) +com.caoccao.javet.interop.engine.observers (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/engine/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/engine/package-summary.html index 5cb0fd9d3..9c4780c48 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/engine/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/engine/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.engine (javet 3.0.2 API) +com.caoccao.javet.interop.engine (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/executors/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/executors/package-summary.html index 5256d353b..e4fc83de2 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/executors/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/executors/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.executors (javet 3.0.2 API) +com.caoccao.javet.interop.executors (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/loader/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/loader/package-summary.html index 0a02c715e..7636f5896 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/loader/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/loader/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.loader (javet 3.0.2 API) +com.caoccao.javet.interop.loader (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/monitoring/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/monitoring/package-summary.html index 38fc4af8e..c0c23eafa 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/monitoring/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/monitoring/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.monitoring (javet 3.0.2 API) +com.caoccao.javet.interop.monitoring (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,13 +11,13 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/options/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/options/package-summary.html index 4da32fddc..49b3bcbf1 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/options/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/options/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.options (javet 3.0.2 API) +com.caoccao.javet.interop.options (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/package-summary.html index 77cf7204c..bfffab081 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop (javet 3.0.2 API) +com.caoccao.javet.interop (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ + + + + + + + + + +
      +
      com.caoccao.javet.interop.proxy
      +

      Class BaseJavetReflectionProxyInvocationHandler<Reference extends V8ValueReference>

      +
      +
      +
        +
      • java.lang.Object
      • +
      • +
          +
        • com.caoccao.javet.interop.proxy.BaseJavetReflectionProxyInvocationHandler<Reference>
        • +
        +
      • +
      +
      + +
      +
      +
        +
      • + +
          +
        • + + +

          Field Summary

          + + + + + + + + + + + + + + +
          Fields 
          Modifier and TypeField and Description
          protected static java.lang.StringMETHOD_NAME_CLOSE +
          The constant METHOD_NAME_CLOSE.
          +
          protected Referencev8ValueReference +
          The V8 value reference.
          +
          +
        • +
        + + + +
          +
        • + + +

          Method Summary

          + + + + + + + + + + + + + + + + + + +
          All Methods Instance Methods Concrete Methods 
          Modifier and TypeMethod and Description
          voidclose() 
          protected voidfinalize() 
          booleanisClosed() +
          Is closed.
          +
          +
            +
          • + + +

            Methods inherited from class java.lang.Object

            +clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
          • +
          +
            +
          • + + +

            Methods inherited from interface java.lang.reflect.InvocationHandler

            +invoke
          • +
          +
        • +
        +
      • +
      +
      +
      +
        +
      • + +
          +
        • + + +

          Field Detail

          + + + +
            +
          • +

            METHOD_NAME_CLOSE

            +
            protected static final java.lang.String METHOD_NAME_CLOSE
            +
            The constant METHOD_NAME_CLOSE.
            +
            +
            Since:
            +
            3.0.3
            +
            See Also:
            +
            Constant Field Values
            +
            +
          • +
          + + + +
            +
          • +

            v8ValueReference

            +
            protected Reference extends V8ValueReference v8ValueReference
            +
            The V8 value reference.
            +
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          +
        • +
        + +
          +
        • + + +

          Constructor Detail

          + + + + + +
            +
          • +

            BaseJavetReflectionProxyInvocationHandler

            +
            public BaseJavetReflectionProxyInvocationHandler(Reference v8ValueReference)
            +
            Instantiates a new Base javet reflection proxy invocation handler.
            +
            +
            Parameters:
            +
            v8ValueReference - the V8 value object
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          +
        • +
        + +
          +
        • + + +

          Method Detail

          + + + + + + + +
            +
          • +

            finalize

            +
            protected void finalize()
            +                 throws java.lang.Throwable
            +
            +
            Overrides:
            +
            finalize in class java.lang.Object
            +
            Throws:
            +
            java.lang.Throwable
            +
            +
          • +
          + + + +
            +
          • +

            isClosed

            +
            public boolean isClosed()
            +
            Description copied from interface: IJavetClosable
            +
            Is closed.
            +
            +
            Specified by:
            +
            isClosed in interface IJavetClosable
            +
            Returns:
            +
            true : closed, false: not closed
            +
            +
          • +
          +
        • +
        +
      • +
      +
      +
      + + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/proxy/IJavetDirectProxyHandler.html b/docs/reference/javadoc/com/caoccao/javet/interop/proxy/IJavetDirectProxyHandler.html index 35e577c8f..076078cd7 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/proxy/IJavetDirectProxyHandler.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/proxy/IJavetDirectProxyHandler.html @@ -3,7 +3,7 @@ -IJavetDirectProxyHandler (javet 3.0.2 API) +IJavetDirectProxyHandler (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ + + + + + + + + + +
      +
      com.caoccao.javet.interop.proxy
      +

      Interface IJavetProxyPolyfillFunction<T,E extends java.lang.Exception>

      +
      +
      +
      +
        +
      • +
        +
        Type Parameters:
        +
        T - the type parameter
        +
        E - the type parameter
        +
        +
        +
        +
        public interface IJavetProxyPolyfillFunction<T,E extends java.lang.Exception>
        +
        The interface Javet proxy polyfill function.
        +
        +
        Since:
        +
        3.0.3
        +
        +
      • +
      +
      +
      + +
      +
      +
        +
      • + +
          +
        • + + +

          Method Detail

          + + + +
            +
          • +

            apply

            +
            V8Value apply(IJavetProxyHandler<T,E> handler)
            +       throws JavetException,
            +              E extends java.lang.Exception
            +
            Apply to the handle and return a V8 value.
            +
            +
            Parameters:
            +
            handler - the handler
            +
            Returns:
            +
            the V8 value
            +
            Throws:
            +
            JavetException - the javet exception
            +
            E - the custom exception
            +
            E extends java.lang.Exception
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          +
        • +
        +
      • +
      +
      +
      + + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/proxy/IJavetProxySymbolConverter.html b/docs/reference/javadoc/com/caoccao/javet/interop/proxy/IJavetProxySymbolConverter.html index ccf237b6a..6d236a05f 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/proxy/IJavetProxySymbolConverter.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/proxy/IJavetProxySymbolConverter.html @@ -3,7 +3,7 @@ -IJavetProxySymbolConverter (javet 3.0.2 API) +IJavetProxySymbolConverter (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,14 +11,14 @@ @@ -11,13 +11,13 @@ @@ -11,13 +11,13 @@ @@ -14,6 +14,7 @@

      Interfaces

      @@ -23,6 +24,7 @@

      Classes

    • BaseJavetProxyHandler
    • BaseJavetProxySymbolConverter
    • BaseJavetReflectionProxyHandler
    • +
    • BaseJavetReflectionProxyInvocationHandler
    • JavetDirectProxyFunctionHandler
    • JavetDirectProxyObjectHandler
    • JavetProxySymbolIterableConverter
    • diff --git a/docs/reference/javadoc/com/caoccao/javet/interop/proxy/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/interop/proxy/package-summary.html index 29c347186..057774e8b 100644 --- a/docs/reference/javadoc/com/caoccao/javet/interop/proxy/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/interop/proxy/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.interop.proxy (javet 3.0.2 API) +com.caoccao.javet.interop.proxy (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/node/modules/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/node/modules/package-summary.html index 8cb83dccf..04517229e 100644 --- a/docs/reference/javadoc/com/caoccao/javet/node/modules/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/node/modules/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.node.modules (javet 3.0.2 API) +com.caoccao.javet.node.modules (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ + + + + + + + + + +
      +
      com.caoccao.javet.utils
      +

      Class ArrayUtils

      +
      +
      +
        +
      • java.lang.Object
      • +
      • +
          +
        • com.caoccao.javet.utils.ArrayUtils
        • +
        +
      • +
      +
      +
        +
      • +
        +
        +
        public final class ArrayUtils
        +extends java.lang.Object
        +
        The type Array utils.
        +
        +
        Since:
        +
        3.0.3
        +
        +
      • +
      +
      +
      +
        +
      • + +
          +
        • + + +

          Constructor Summary

          + + + + + + + + +
          Constructors 
          Constructor and Description
          ArrayUtils() 
          +
        • +
        + +
          +
        • + + +

          Method Summary

          + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
          All Methods Static Methods Concrete Methods 
          Modifier and TypeMethod and Description
          static booleanisEmpty(byte[] array) +
          Test if the input byte array is empty.
          +
          static booleanisEmpty(long[] array) +
          Test if the input long array is empty.
          +
          static <T> booleanisEmpty(T[] array) +
          Test if the input array is empty.
          +
          static booleanisNotEmpty(byte[] array) +
          Test if the input byte array is not empty.
          +
          static booleanisNotEmpty(long[] array) +
          Test if the input long array is not empty.
          +
          static <T> booleanisNotEmpty(T[] array) +
          Test if the input array is not empty.
          +
          +
            +
          • + + +

            Methods inherited from class java.lang.Object

            +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
          • +
          +
        • +
        +
      • +
      +
      +
      +
        +
      • + +
          +
        • + + +

          Constructor Detail

          + + + +
            +
          • +

            ArrayUtils

            +
            public ArrayUtils()
            +
          • +
          +
        • +
        + +
          +
        • + + +

          Method Detail

          + + + +
            +
          • +

            isEmpty

            +
            public static boolean isEmpty(byte[] array)
            +
            Test if the input byte array is empty.
            +
            +
            Parameters:
            +
            array - the array
            +
            Returns:
            +
            true : empty, false : not empty
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + +
            +
          • +

            isEmpty

            +
            public static boolean isEmpty(long[] array)
            +
            Test if the input long array is empty.
            +
            +
            Parameters:
            +
            array - the array
            +
            Returns:
            +
            true : empty, false : not empty
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + + + +
            +
          • +

            isEmpty

            +
            public static <T> boolean isEmpty(T[] array)
            +
            Test if the input array is empty.
            +
            +
            Type Parameters:
            +
            T - the type parameter
            +
            Parameters:
            +
            array - the array
            +
            Returns:
            +
            true : empty, false : not empty
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + +
            +
          • +

            isNotEmpty

            +
            public static boolean isNotEmpty(byte[] array)
            +
            Test if the input byte array is not empty.
            +
            +
            Parameters:
            +
            array - the array
            +
            Returns:
            +
            true : not empty, false : empty
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + +
            +
          • +

            isNotEmpty

            +
            public static boolean isNotEmpty(long[] array)
            +
            Test if the input long array is not empty.
            +
            +
            Parameters:
            +
            array - the array
            +
            Returns:
            +
            true : not empty, false : empty
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + + + +
            +
          • +

            isNotEmpty

            +
            public static <T> boolean isNotEmpty(T[] array)
            +
            Test if the input array is not empty.
            +
            +
            Type Parameters:
            +
            T - the type parameter
            +
            Parameters:
            +
            array - the array
            +
            Returns:
            +
            true : not empty, false : empty
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          +
        • +
        +
      • +
      +
      +
      + + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/utils/JavetDateTimeUtils.html b/docs/reference/javadoc/com/caoccao/javet/utils/JavetDateTimeUtils.html index b4a9e484d..006c7bb3d 100644 --- a/docs/reference/javadoc/com/caoccao/javet/utils/JavetDateTimeUtils.html +++ b/docs/reference/javadoc/com/caoccao/javet/utils/JavetDateTimeUtils.html @@ -3,7 +3,7 @@ -JavetDateTimeUtils (javet 3.0.2 API) +JavetDateTimeUtils (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ + + + + + + + + + +
      +
      com.caoccao.javet.utils
      +

      Class ListUtils

      +
      +
      +
        +
      • java.lang.Object
      • +
      • +
          +
        • com.caoccao.javet.utils.ListUtils
        • +
        +
      • +
      +
      +
        +
      • +
        +
        +
        public final class ListUtils
        +extends java.lang.Object
        +
        The type List utils.
        +
        +
        Since:
        +
        3.0.3
        +
        +
      • +
      +
      +
      +
        +
      • + +
          +
        • + + +

          Method Summary

          + + + + + + + + + + + + + + + + + + + + + + + + + + +
          All Methods Static Methods Concrete Methods 
          Modifier and TypeMethod and Description
          static <T> booleanincludes(java.util.List<T> list, + T element, + int fromIndex) +
          The includes() method of Array instances determines whether an array includes a certain value among its entries, + returning true or false as appropriate.
          +
          static <T> Tpop(java.util.List<T> list) +
          The pop() method of Array instances removes the last element from an array and returns that element.
          +
          static <T> intpush(java.util.List<T> list, + T... elements) +
          The push() method of Array instances adds the specified elements to the end of an array + and returns the new length of the array.
          +
          static <T> Tshift(java.util.List<T> list) +
          The shift() method of Array instances removes the first element from an array and + returns that removed element.
          +
          static <T> intunshift(java.util.List<T> list, + T... elements) +
          The unshift() method of Array instances adds the specified elements to the beginning of an array and + returns the new length of the array.
          +
          +
            +
          • + + +

            Methods inherited from class java.lang.Object

            +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
          • +
          +
        • +
        +
      • +
      +
      +
      +
        +
      • + +
          +
        • + + +

          Method Detail

          + + + + + +
            +
          • +

            includes

            +
            public static <T> boolean includes(java.util.List<T> list,
            +                                   T element,
            +                                   int fromIndex)
            +
            The includes() method of Array instances determines whether an array includes a certain value among its entries, + returning true or false as appropriate.
            +
            +
            Type Parameters:
            +
            T - the type parameter
            +
            Parameters:
            +
            list - the list
            +
            element - the element
            +
            fromIndex - the from index
            +
            Returns:
            +
            true : included, false : not included
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + +
            +
          • +

            pop

            +
            public static <T> T pop(java.util.List<T> list)
            +
            The pop() method of Array instances removes the last element from an array and returns that element. + This method changes the length of the array.
            +
            +
            Type Parameters:
            +
            T - the type parameter
            +
            Parameters:
            +
            list - the list
            +
            Returns:
            +
            the removed element
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + + + +
            +
          • +

            push

            +
            public static <T> int push(java.util.List<T> list,
            +                           T... elements)
            +
            The push() method of Array instances adds the specified elements to the end of an array + and returns the new length of the array.
            +
            +
            Type Parameters:
            +
            T - the type parameter
            +
            Parameters:
            +
            list - the list
            +
            elements - the elements
            +
            Returns:
            +
            the new length of the array
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + +
            +
          • +

            shift

            +
            public static <T> T shift(java.util.List<T> list)
            +
            The shift() method of Array instances removes the first element from an array and + returns that removed element. This method changes the length of the array.
            +
            +
            Type Parameters:
            +
            T - the type parameter
            +
            Parameters:
            +
            list - the list
            +
            Returns:
            +
            the removed element
            +
            +
          • +
          + + + + + +
            +
          • +

            unshift

            +
            public static <T> int unshift(java.util.List<T> list,
            +                              T... elements)
            +
            The unshift() method of Array instances adds the specified elements to the beginning of an array and + returns the new length of the array.
            +
            +
            Type Parameters:
            +
            T - the type parameter
            +
            Parameters:
            +
            list - the list
            +
            elements - the elements
            +
            Returns:
            +
            the new length of the array
            +
            +
          • +
          +
        • +
        +
      • +
      +
      +
      + + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/utils/SimpleFreeMarkerFormat.html b/docs/reference/javadoc/com/caoccao/javet/utils/SimpleFreeMarkerFormat.html index f4fe820e5..ddd1e165f 100644 --- a/docs/reference/javadoc/com/caoccao/javet/utils/SimpleFreeMarkerFormat.html +++ b/docs/reference/javadoc/com/caoccao/javet/utils/SimpleFreeMarkerFormat.html @@ -3,7 +3,7 @@ -SimpleFreeMarkerFormat (javet 3.0.2 API) +SimpleFreeMarkerFormat (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,13 +11,13 @@ @@ -11,7 +11,7 @@ + + + + + + + + + +
      +
      com.caoccao.javet.utils
      +

      Class SimpleSet

      +
      +
      +
        +
      • java.lang.Object
      • +
      • +
          +
        • com.caoccao.javet.utils.SimpleSet
        • +
        +
      • +
      +
      +
        +
      • +
        +
        +
        public final class SimpleSet
        +extends java.lang.Object
        +
        The type Simple set is a polyfill because Set.of() is not available at JDK 8 .
        +
        +
        Since:
        +
        3.0.3
        +
        +
      • +
      +
      +
      +
        +
      • + +
          +
        • + + +

          Method Summary

          + + + + + + + + + + + + + + +
          All Methods Static Methods Concrete Methods 
          Modifier and TypeMethod and Description
          static <T> java.util.Set<T>of() +
          Of set.
          +
          static <T> java.util.Set<T>of(T... objects) +
          Of set.
          +
          +
            +
          • + + +

            Methods inherited from class java.lang.Object

            +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
          • +
          +
        • +
        +
      • +
      +
      +
      +
        +
      • + +
          +
        • + + +

          Method Detail

          + + + +
            +
          • +

            of

            +
            public static <T> java.util.Set<T> of()
            +
            Of set.
            +
            +
            Type Parameters:
            +
            T - the type parameter
            +
            Returns:
            +
            the set
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + + + +
            +
          • +

            of

            +
            @SafeVarargs
            +public static <T> java.util.Set<T> of(T... objects)
            +
            Of set.
            +
            +
            Type Parameters:
            +
            T - the type parameter
            +
            Parameters:
            +
            objects - the objects
            +
            Returns:
            +
            the set
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          +
        • +
        +
      • +
      +
      +
      + + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/utils/StringUtils.html b/docs/reference/javadoc/com/caoccao/javet/utils/StringUtils.html new file mode 100644 index 000000000..48df2f381 --- /dev/null +++ b/docs/reference/javadoc/com/caoccao/javet/utils/StringUtils.html @@ -0,0 +1,421 @@ + + + + + +StringUtils (javet 3.0.3 API) + + + + + + + + + + + +
      +
      com.caoccao.javet.utils
      +

      Class StringUtils

      +
      +
      +
        +
      • java.lang.Object
      • +
      • +
          +
        • com.caoccao.javet.utils.StringUtils
        • +
        +
      • +
      +
      +
        +
      • +
        +
        +
        public final class StringUtils
        +extends java.lang.Object
        +
        The type String utils.
        +
        +
        Since:
        +
        3.0.3
        +
        +
      • +
      +
      +
      +
        +
      • + +
          +
        • + + +

          Field Summary

          + + + + + + + + + + +
          Fields 
          Modifier and TypeField and Description
          static java.lang.StringEMPTY +
          The constant EMPTY.
          +
          +
        • +
        + +
          +
        • + + +

          Method Summary

          + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
          All Methods Static Methods Concrete Methods 
          Modifier and TypeMethod and Description
          static booleanisBlank(java.lang.String str) +
          Is blank.
          +
          static booleanisDigital(java.lang.String str) +
          Is digital.
          +
          static booleanisEmpty(java.lang.String str) +
          Is empty.
          +
          static booleanisNotEmpty(java.lang.String str) +
          Is not empty.
          +
          static java.lang.Stringjoin(java.lang.CharSequence delimiter, + java.lang.CharSequence... elements) +
          Join string.
          +
          static java.lang.Stringjoin(java.lang.CharSequence delimiter, + java.lang.Iterable<? extends java.lang.CharSequence> elements) +
          Join string.
          +
          +
            +
          • + + +

            Methods inherited from class java.lang.Object

            +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
          • +
          +
        • +
        +
      • +
      +
      +
      +
        +
      • + +
          +
        • + + +

          Field Detail

          + + + +
            +
          • +

            EMPTY

            +
            public static final java.lang.String EMPTY
            +
            The constant EMPTY.
            +
            +
            Since:
            +
            3.0.3
            +
            See Also:
            +
            Constant Field Values
            +
            +
          • +
          +
        • +
        + +
          +
        • + + +

          Method Detail

          + + + +
            +
          • +

            isBlank

            +
            public static boolean isBlank(java.lang.String str)
            +
            Is blank.
            +
            +
            Parameters:
            +
            str - the str
            +
            Returns:
            +
            true : blank, false : not blank
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + +
            +
          • +

            isDigital

            +
            public static boolean isDigital(java.lang.String str)
            +
            Is digital.
            +
            +
            Parameters:
            +
            str - the str
            +
            Returns:
            +
            true : yes, false : no
            +
            Since:
            +
            1.0.6
            +
            +
          • +
          + + + +
            +
          • +

            isEmpty

            +
            public static boolean isEmpty(java.lang.String str)
            +
            Is empty.
            +
            +
            Parameters:
            +
            str - the str
            +
            Returns:
            +
            true : empty, false : not empty
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + +
            +
          • +

            isNotEmpty

            +
            public static boolean isNotEmpty(java.lang.String str)
            +
            Is not empty.
            +
            +
            Parameters:
            +
            str - the str
            +
            Returns:
            +
            true : not empty, false : empty
            +
            Since:
            +
            3.0.3
            +
            +
          • +
          + + + +
            +
          • +

            join

            +
            public static java.lang.String join(java.lang.CharSequence delimiter,
            +                                    java.lang.CharSequence... elements)
            +
            Join string.
            +
            +
            Parameters:
            +
            delimiter - the delimiter
            +
            elements - the elements
            +
            Returns:
            +
            the string
            +
            Since:
            +
            1.0.3
            +
            +
          • +
          + + + +
            +
          • +

            join

            +
            public static java.lang.String join(java.lang.CharSequence delimiter,
            +                                    java.lang.Iterable<? extends java.lang.CharSequence> elements)
            +
            Join string.
            +
            +
            Parameters:
            +
            delimiter - the delimiter
            +
            elements - the elements
            +
            Returns:
            +
            the string
            +
            Since:
            +
            1.0.3
            +
            +
          • +
          +
        • +
        +
      • +
      +
      +
      + + + + + + + diff --git a/docs/reference/javadoc/com/caoccao/javet/utils/ThreadSafeMap.Type.html b/docs/reference/javadoc/com/caoccao/javet/utils/ThreadSafeMap.Type.html index 4e5995f8a..2e35bf34e 100644 --- a/docs/reference/javadoc/com/caoccao/javet/utils/ThreadSafeMap.Type.html +++ b/docs/reference/javadoc/com/caoccao/javet/utils/ThreadSafeMap.Type.html @@ -3,7 +3,7 @@ -ThreadSafeMap.Type (javet 3.0.2 API) +ThreadSafeMap.Type (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,13 +11,13 @@ @@ -12,16 +12,20 @@

      Classes

      diff --git a/docs/reference/javadoc/com/caoccao/javet/utils/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/utils/package-summary.html index d1ae78b71..112713c5e 100644 --- a/docs/reference/javadoc/com/caoccao/javet/utils/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/utils/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.utils (javet 3.0.2 API) +com.caoccao.javet.utils (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/utils/receivers/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/utils/receivers/package-summary.html index 4fef2ab9a..90bcaf416 100644 --- a/docs/reference/javadoc/com/caoccao/javet/utils/receivers/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/utils/receivers/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.utils.receivers (javet 3.0.2 API) +com.caoccao.javet.utils.receivers (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/values/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/values/package-summary.html index 6b6bacd3f..fd5d263da 100644 --- a/docs/reference/javadoc/com/caoccao/javet/values/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/values/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.values (javet 3.0.2 API) +com.caoccao.javet.values (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/values/primitive/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/values/primitive/package-summary.html index 5211c78f6..a98fdeaec 100644 --- a/docs/reference/javadoc/com/caoccao/javet/values/primitive/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/values/primitive/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.values.primitive (javet 3.0.2 API) +com.caoccao.javet.values.primitive (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/values/reference/builtin/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/values/reference/builtin/package-summary.html index 33e3f50f1..e328bdb5c 100644 --- a/docs/reference/javadoc/com/caoccao/javet/values/reference/builtin/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/values/reference/builtin/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.values.reference.builtin (javet 3.0.2 API) +com.caoccao.javet.values.reference.builtin (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/values/reference/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/values/reference/package-summary.html index 85d73fc81..b2d389d20 100644 --- a/docs/reference/javadoc/com/caoccao/javet/values/reference/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/values/reference/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.values.reference (javet 3.0.2 API) +com.caoccao.javet.values.reference (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ diff --git a/docs/reference/javadoc/com/caoccao/javet/values/virtual/package-summary.html b/docs/reference/javadoc/com/caoccao/javet/values/virtual/package-summary.html index 63bc6e169..62dfc50ce 100644 --- a/docs/reference/javadoc/com/caoccao/javet/values/virtual/package-summary.html +++ b/docs/reference/javadoc/com/caoccao/javet/values/virtual/package-summary.html @@ -3,7 +3,7 @@ -com.caoccao.javet.values.virtual (javet 3.0.2 API) +com.caoccao.javet.values.virtual (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -17,6 +17,7 @@

      Packages

    • com.caoccao.javet.enums
    • com.caoccao.javet.exceptions
    • com.caoccao.javet.interception
    • +
    • com.caoccao.javet.interception.jvm
    • com.caoccao.javet.interception.logging
    • com.caoccao.javet.interfaces
    • com.caoccao.javet.interop
    • diff --git a/docs/reference/javadoc/overview-summary.html b/docs/reference/javadoc/overview-summary.html index 8ec071034..5fc00f401 100644 --- a/docs/reference/javadoc/overview-summary.html +++ b/docs/reference/javadoc/overview-summary.html @@ -3,7 +3,7 @@ -Overview (javet 3.0.2 API) +Overview (javet 3.0.3 API) @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@ +
    diff --git a/docs/reference/resource_management/load_and_unload.html b/docs/reference/resource_management/load_and_unload.html index 9faed3290..af1053b2c 100644 --- a/docs/reference/resource_management/load_and_unload.html +++ b/docs/reference/resource_management/load_and_unload.html @@ -6,7 +6,7 @@ - Load and Unload - Javet 3.0.2 documentation + Load and Unload - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -514,7 +517,7 @@

    Can Javet Libraries be Removed from the Jar File?

    - + diff --git a/docs/reference/resource_management/lock.html b/docs/reference/resource_management/lock.html index 5a25e872a..2ee573e0d 100644 --- a/docs/reference/resource_management/lock.html +++ b/docs/reference/resource_management/lock.html @@ -6,7 +6,7 @@ - Know the Lock - Javet 3.0.2 documentation + Know the Lock - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/reference/resource_management/memory_management.html b/docs/reference/resource_management/memory_management.html index 7ed5fc775..f4fab4219 100644 --- a/docs/reference/resource_management/memory_management.html +++ b/docs/reference/resource_management/memory_management.html @@ -6,7 +6,7 @@ - Memory Management - Javet 3.0.2 documentation + Memory Management - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -536,8 +539,47 @@

    V8Runtime.idleNotificationDeadline(long deadlineInMillis)#

    This API explicitly tells Node.js or V8 runtime to perform a GC immediately. It is also used in automatic GC aforementioned.

    +
    +

    System.gc() and System.runFinalization()#

    +

    If JavetProxyConverter or JavetBridgeConverter is used to inject JavaScript functions or objects to JVM, please be aware that those injected JavaScript functions and objects cannot be recycled by V8 garbage collector because they are referenced in JVM. They will be eventually recycled by JVM if their holding objects are recycled. The following code can explicitly recycle them.

    +
    System.gc();
    +System.runFinalization();
    +
    +
    +
    +
    +

    V8 Options and V8Flags#

    +

    Almost all V8 options can be set via V8Flags as follows.

    +
    // Node.js Mode
    +V8Flags v8Flags = NodeRuntimeOptions.V8_FLAGS;
    +v8Flags.setAllowNativesSyntax(true);
    +v8Flags.setExposeGC(false);
    +v8Flags.setExposeInspectorScripts(true);
    +v8Flags.setMaxHeapSize(768);
    +v8Flags.setMaxOldSpaceSize(512);
    +v8Flags.setUseStrict(true);
    +v8Flags.setTrackRetainingPath(true);
    +v8Flags.setCustomFlags("--max-semi-space-size=384 --min-semi-space-size=256");
    +
    +// V8 Mode
    +V8Flags v8Flags = NodeRuntimeOptions.V8_FLAGS;
    +v8Flags.setAllowNativesSyntax(true);
    +v8Flags.setExposeGC(false);
    +v8Flags.setExposeInspectorScripts(true);
    +v8Flags.setMaxHeapSize(768);
    +v8Flags.setMaxOldSpaceSize(512);
    +v8Flags.setUseStrict(true);
    +v8Flags.setTrackRetainingPath(true);
    +v8Flags.setCustomFlags("--max-semi-space-size=384 --min-semi-space-size=256");
    +
    +
    +
    +

    Note

    +

    The V8 flags must be set during application initialization. Once the first V8 runtime is created, the V8 flags are sealed and further modification to the V8 flags will no longer take effect.

    +
    +

    Statistics#

    V8 exposes quite a few statistics for applications to analyze the memory usage, performance, etc. Javet selectively exposes some of those statistics via V8Runtime or V8Host.

    @@ -638,10 +680,12 @@

    StatisticsV8Runtime.await()
  • V8Runtime.idleNotificationDeadline(long deadlineInMillis)
  • V8Runtime.lowMemoryNotification()
  • +
  • System.gc() and System.runFinalization()
  • +
  • V8 Options and V8Flags
  • Statistics
  • @@ -654,7 +698,7 @@

    Statistics +

    diff --git a/docs/reference/resource_management/memory_management.rst b/docs/reference/resource_management/memory_management.rst index 40cf377ad..f4f359749 100644 --- a/docs/reference/resource_management/memory_management.rst +++ b/docs/reference/resource_management/memory_management.rst @@ -193,6 +193,49 @@ V8Runtime.lowMemoryNotification() This API explicitly tells Node.js or V8 runtime to perform a GC immediately. It is also used in automatic GC aforementioned. +System.gc() and System.runFinalization() +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If ``JavetProxyConverter`` or ``JavetBridgeConverter`` is used to inject JavaScript functions or objects to JVM, please be aware that those injected JavaScript functions and objects cannot be recycled by V8 garbage collector because they are referenced in JVM. They will be eventually recycled by JVM if their holding objects are recycled. The following code can explicitly recycle them. + +.. code-block:: java + + System.gc(); + System.runFinalization(); + +V8 Options and V8Flags +====================== + +Almost all `V8 options `_ can be set via `V8Flags <../javadoc/com/caoccao/javet/interop/options/V8Flags.html>`_ as follows. + +.. code-block:: java + + // Node.js Mode + V8Flags v8Flags = NodeRuntimeOptions.V8_FLAGS; + v8Flags.setAllowNativesSyntax(true); + v8Flags.setExposeGC(false); + v8Flags.setExposeInspectorScripts(true); + v8Flags.setMaxHeapSize(768); + v8Flags.setMaxOldSpaceSize(512); + v8Flags.setUseStrict(true); + v8Flags.setTrackRetainingPath(true); + v8Flags.setCustomFlags("--max-semi-space-size=384 --min-semi-space-size=256"); + + // V8 Mode + V8Flags v8Flags = NodeRuntimeOptions.V8_FLAGS; + v8Flags.setAllowNativesSyntax(true); + v8Flags.setExposeGC(false); + v8Flags.setExposeInspectorScripts(true); + v8Flags.setMaxHeapSize(768); + v8Flags.setMaxOldSpaceSize(512); + v8Flags.setUseStrict(true); + v8Flags.setTrackRetainingPath(true); + v8Flags.setCustomFlags("--max-semi-space-size=384 --min-semi-space-size=256"); + +.. note:: + + The V8 flags must be set during application initialization. Once the first V8 runtime is created, the V8 flags are sealed and further modification to the V8 flags will no longer take effect. + Statistics ========== diff --git a/docs/reference/resource_management/modularization.html b/docs/reference/resource_management/modularization.html index a62b9c155..80dcf0317 100644 --- a/docs/reference/resource_management/modularization.html +++ b/docs/reference/resource_management/modularization.html @@ -3,10 +3,10 @@ - + - Modularization - Javet 3.0.2 documentation + Modularization - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -300,6 +303,7 @@

    Modularization#

    +

    JavaScript ECMAScript Modules (ESM), is the official standardized format for modularizing JavaScript code. It was introduced in ES6 (ECMAScript 2015) and aims to address the drawbacks of earlier module systems like CommonJS and AMD.

    Node.js Mode#

    @@ -591,12 +595,12 @@

    Internals - +
    Next
    -
    Troubleshooting
    +
    Snapshot
    @@ -671,7 +675,7 @@

    Internals +

    diff --git a/docs/reference/resource_management/modularization.rst b/docs/reference/resource_management/modularization.rst index 95547f638..c1705f701 100644 --- a/docs/reference/resource_management/modularization.rst +++ b/docs/reference/resource_management/modularization.rst @@ -2,6 +2,8 @@ Modularization ============== +JavaScript ECMAScript Modules (ESM), is the official standardized format for modularizing JavaScript code. It was introduced in ES6 (ECMAScript 2015) and aims to address the drawbacks of earlier module systems like CommonJS and AMD. + Node.js Mode ============ diff --git a/docs/reference/resource_management/snapshot.html b/docs/reference/resource_management/snapshot.html new file mode 100644 index 000000000..76eb23bb9 --- /dev/null +++ b/docs/reference/resource_management/snapshot.html @@ -0,0 +1,514 @@ + + + + + + + + + Snapshot - Javet 3.0.3 documentation + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    + + + + + Back to top + +
    + +
    + +
    + +
    +
    +
    +

    Snapshot#

    +

    A V8 snapshot is a way to speed up the startup time of JavaScript applications built with the V8 JavaScript engine, which powers Chrome, Node.js, and many other popular platforms. Think of it like pre-cooking a meal so you don't have to start from scratch when you're hungry.

    +
    +

    How Snapshot Works#

    +
      +
    1. Creating the Snapshot: During development or deployment, you can take a snapshot of the V8 heap, which is where JavaScript objects and data are stored in memory. This snapshot captures the initial state of your application, including all the built-in JavaScript functions and any custom code you've written.

    2. +
    3. Embedding the Snapshot: When you launch your application, the V8 engine can load the pre-made snapshot instead of having to compile and execute all the JavaScript code from scratch. This significantly reduces the startup time, making your application launch faster and feel more responsive.

    4. +
    +
    +

    Benefits#

    +
      +
    • Faster Startup Times: This is the primary benefit, as applications can launch in milliseconds instead of seconds.

    • +
    • Reduced Memory Usage: Snapshots can sometimes be smaller than the equivalent compiled code, leading to lower memory usage.

    • +
    • Improved Security: Snapshots can help mitigate certain security vulnerabilities by making it harder to inject malicious code.

    • +
    +
    +
    +

    Limitations#

    +
      +
    • Not all modules supported: Only a subset of the built-in Node.js modules are currently supported in snapshots, so some applications might not be suitable for snapshotting.

    • +
    • Dynamic code updates not possible: Once a snapshot is created, it's static and cannot be updated with new code without creating a new snapshot.

    • +
    • V8 version dependent: The snapshot created from a particular version of V8 only works in that version of V8. If you want to support a new version of V8, you will have to create a new snapshot in that new version of V8.

    • +
    +
    +
    +
    +

    How to Create a Snapshot#

    +
    +

    Create a Snapshot in Javet#

    +

    It's simple to create a snapshot or provide an existing snapshot in Javet via the V8RuntimeOptions.

    +
      +
    • setCreateSnapshotEnabled(boolean): Enable or disable the snapshot creation.

    • +
    • setSnapshotBlob(byte[]): Provide an existing snapshot blob.

    • +
    +
    V8RuntimeOptions options = new V8RuntimeOptions();
    +// Set create snapshot enabled.
    +options.setCreateSnapshotEnabled(true);
    +byte[] snapshotBlob1;
    +byte[] snapshotBlob2;
    +try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) {
    +    // Prepare function add.
    +    v8Runtime.getExecutor("const add = (a, b) => a + b;").executeVoid();
    +    assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger());
    +    // Create a snapshot with function add.
    +    snapshotBlob1 = v8Runtime.createSnapshot();
    +    assertNotNull(snapshotBlob1);
    +    assertTrue(snapshotBlob1.length > 0);
    +    // Test the runtime is still usable after the snapshot is created.
    +    assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger());
    +}
    +// Set the snapshot blob.
    +options.setSnapshotBlob(snapshotBlob1);
    +for (int i = 0; i < 5; ++i) {
    +    // Create a new V8 runtime with the snapshot 5 times.
    +    try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) {
    +        // Test the function add.
    +        assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger());
    +    }
    +}
    +// Create a new V8 runtime with the snapshot.
    +try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) {
    +    // Test the function add.
    +    assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger());
    +    // Prepare function subtract.
    +    v8Runtime.getExecutor("const subtract = (a, b) => a - b;").executeVoid();
    +    // Create a new snapshot with function add and subtract.
    +    snapshotBlob2 = v8Runtime.createSnapshot();
    +    assertNotNull(snapshotBlob2);
    +    assertTrue(snapshotBlob2.length > 0);
    +}
    +// Set the new snapshot blob.
    +options.setSnapshotBlob(snapshotBlob2);
    +for (int i = 0; i < 5; ++i) {
    +    // Create a new V8 runtime with the snapshot 5 times.
    +    try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) {
    +        // Test the function add and subtract.
    +        assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger());
    +        assertEquals(1, v8Runtime.getExecutor("subtract(3, 2)").executeInteger());
    +    }
    +}
    +
    +
    +
    +

    Note

    +
      +
    • Snapshot is only available in the V8 mode. There are some technical difficulties to be resolved in the Node.js mode.

    • +
    • Both setCreateSnapshotEnabled() and setSnapshotBlob() can be used together so that you may create a V8 runtime by an existing snapshot, then create a new snapshot from that V8 runtime.

    • +
    +
    +
    +
    +

    Create a Snapshot via mksnapshot#

    +

    mksnapshot is a powerful tool in the V8 development toolkit. If you are able to build mksnapshot, you may use it to create snapshots. Its usage is as follows:

    +
    Usage: mksnapshot [--startup-src=file] [--startup-blob=file] [--embedded-src=file]
    +  [--embedded-variant=label] [--static-roots-src=file] [--target-arch=arch]
    +  [--target-os=os] [extras]
    +
    +
    +

    Let's take a try.

    +
      +
    • Create test.js with a simple function that adds the 2 arguments as follows.

    • +
    +
    const add = (a, b) => a + b;
    +
    +
    +
      +
    • Execute the following command.

    • +
    +
    mksnapshot.exe --startup-src=startup.cpp --startup-blob=startup.blob --embedded-src=embedded.js test.js
    +
    +
    +
      +
    • The following 3 files will be generated.

    • +
    +
    5.1M embedded.js    // Embedded blob with assembly directives
    +298K startup.blob   // The blob that can be used in Javet
    +745K startup.cpp    // The CPP file that can be built in a CPP application
    +  28 test.js
    +
    +
    +
      +
    • Read startup.blob to a byte[] and follow the previous section.

    • +
    +
    +
    +
    + +
    +
    + +
    + +
    +
    + + + + + + \ No newline at end of file diff --git a/docs/reference/resource_management/snapshot.rst b/docs/reference/resource_management/snapshot.rst new file mode 100644 index 000000000..97dd682b5 --- /dev/null +++ b/docs/reference/resource_management/snapshot.rst @@ -0,0 +1,127 @@ +======== +Snapshot +======== + +A V8 snapshot is a way to speed up the startup time of JavaScript applications built with the V8 JavaScript engine, which powers Chrome, Node.js, and many other popular platforms. Think of it like pre-cooking a meal so you don't have to start from scratch when you're hungry. + +How Snapshot Works +================== + +1. **Creating the Snapshot**: During development or deployment, you can take a snapshot of the V8 heap, which is where JavaScript objects and data are stored in memory. This snapshot captures the initial state of your application, including all the built-in JavaScript functions and any custom code you've written. + +2. **Embedding the Snapshot**: When you launch your application, the V8 engine can load the pre-made snapshot instead of having to compile and execute all the JavaScript code from scratch. This significantly reduces the startup time, making your application launch faster and feel more responsive. + +Benefits +-------- + +* **Faster Startup Times**: This is the primary benefit, as applications can launch in milliseconds instead of seconds. +* **Reduced Memory Usage**: Snapshots can sometimes be smaller than the equivalent compiled code, leading to lower memory usage. +* **Improved Security**: Snapshots can help mitigate certain security vulnerabilities by making it harder to inject malicious code. + +Limitations +----------- + +* **Not all modules supported**: Only a subset of the built-in Node.js modules are currently supported in snapshots, so some applications might not be suitable for snapshotting. +* **Dynamic code updates not possible**: Once a snapshot is created, it's static and cannot be updated with new code without creating a new snapshot. +* **V8 version dependent**: The snapshot created from a particular version of V8 only works in that version of V8. If you want to support a new version of V8, you will have to create a new snapshot in that new version of V8. + +How to Create a Snapshot +======================== + +Create a Snapshot in Javet +-------------------------- + +It's simple to create a snapshot or provide an existing snapshot in Javet via the ``V8RuntimeOptions``. + +* ``setCreateSnapshotEnabled(boolean)``: Enable or disable the snapshot creation. +* ``setSnapshotBlob(byte[])``: Provide an existing snapshot blob. + +.. code-block:: java + + V8RuntimeOptions options = new V8RuntimeOptions(); + // Set create snapshot enabled. + options.setCreateSnapshotEnabled(true); + byte[] snapshotBlob1; + byte[] snapshotBlob2; + try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) { + // Prepare function add. + v8Runtime.getExecutor("const add = (a, b) => a + b;").executeVoid(); + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + // Create a snapshot with function add. + snapshotBlob1 = v8Runtime.createSnapshot(); + assertNotNull(snapshotBlob1); + assertTrue(snapshotBlob1.length > 0); + // Test the runtime is still usable after the snapshot is created. + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + } + // Set the snapshot blob. + options.setSnapshotBlob(snapshotBlob1); + for (int i = 0; i < 5; ++i) { + // Create a new V8 runtime with the snapshot 5 times. + try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) { + // Test the function add. + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + } + } + // Create a new V8 runtime with the snapshot. + try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) { + // Test the function add. + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + // Prepare function subtract. + v8Runtime.getExecutor("const subtract = (a, b) => a - b;").executeVoid(); + // Create a new snapshot with function add and subtract. + snapshotBlob2 = v8Runtime.createSnapshot(); + assertNotNull(snapshotBlob2); + assertTrue(snapshotBlob2.length > 0); + } + // Set the new snapshot blob. + options.setSnapshotBlob(snapshotBlob2); + for (int i = 0; i < 5; ++i) { + // Create a new V8 runtime with the snapshot 5 times. + try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) { + // Test the function add and subtract. + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + assertEquals(1, v8Runtime.getExecutor("subtract(3, 2)").executeInteger()); + } + } + +.. note:: + + * Snapshot is only available in the V8 mode. There are some technical difficulties to be resolved in the Node.js mode. + * Both ``setCreateSnapshotEnabled()`` and ``setSnapshotBlob()`` can be used together so that you may create a V8 runtime by an existing snapshot, then create a new snapshot from that V8 runtime. + +Create a Snapshot via mksnapshot +-------------------------------- + +``mksnapshot`` is a powerful tool in the V8 development toolkit. If you are able to build ``mksnapshot``, you may use it to create snapshots. Its usage is as follows: + +.. code-block:: shell + + Usage: mksnapshot [--startup-src=file] [--startup-blob=file] [--embedded-src=file] + [--embedded-variant=label] [--static-roots-src=file] [--target-arch=arch] + [--target-os=os] [extras] + +Let's take a try. + +* Create ``test.js`` with a simple function that adds the 2 arguments as follows. + +.. code-block:: js + + const add = (a, b) => a + b; + +* Execute the following command. + +.. code-block:: shell + + mksnapshot.exe --startup-src=startup.cpp --startup-blob=startup.blob --embedded-src=embedded.js test.js + +* The following 3 files will be generated. + +.. code-block:: js + + 5.1M embedded.js // Embedded blob with assembly directives + 298K startup.blob // The blob that can be used in Javet + 745K startup.cpp // The CPP file that can be built in a CPP application + 28 test.js + +* Read ``startup.blob`` to a ``byte[]`` and follow the previous section. diff --git a/docs/reference/tips/best_practices.html b/docs/reference/tips/best_practices.html index daa96bdb5..3634600e9 100644 --- a/docs/reference/tips/best_practices.html +++ b/docs/reference/tips/best_practices.html @@ -6,7 +6,7 @@ - Best Practices - Javet 3.0.2 documentation + Best Practices - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/reference/tips/index.html b/docs/reference/tips/index.html index 0fdfaf9d0..96b530959 100644 --- a/docs/reference/tips/index.html +++ b/docs/reference/tips/index.html @@ -6,7 +6,7 @@ - Tips - Javet 3.0.2 documentation + Tips - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/reference/todo_list.html b/docs/reference/todo_list.html index c3a512878..9a61b09fb 100644 --- a/docs/reference/todo_list.html +++ b/docs/reference/todo_list.html @@ -6,7 +6,7 @@ - TODO List - Javet 3.0.2 documentation + TODO List - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/reference/troubleshooting/error_codes.html b/docs/reference/troubleshooting/error_codes.html index 197f7e792..ff1a08702 100644 --- a/docs/reference/troubleshooting/error_codes.html +++ b/docs/reference/troubleshooting/error_codes.html @@ -6,7 +6,7 @@ - Error Codes - Javet 3.0.2 documentation + Error Codes - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/reference/troubleshooting/error_codes.rst b/docs/reference/troubleshooting/error_codes.rst index 64e195a19..179d417ba 100644 --- a/docs/reference/troubleshooting/error_codes.rst +++ b/docs/reference/troubleshooting/error_codes.rst @@ -54,6 +54,8 @@ Code Type Name Format 804 Runtime RuntimeLeakageDetected ${count} runtime(s) leakage is detected 805 Runtime RuntimeCloseFailure Failed to close the runtime with error message ${message} 806 Runtime RuntimeOutOfMemory Runtime is out of memory because ${message} with ${heapStatistics} +807 Runtime RuntimeCreateSnapshotDisabled Runtime create snapshot is disabled +808 Runtime RuntimeCreateSnapshotBlocked Runtime create snapshot is blocked because of ${callbackContextCount} callback context(s), ${referenceCount} reference(s), ${v8ModuleCount} module(s) 901 Engine EngineNotAvailable Engine is not available. ==== =========== ====================================== ================================================================================================================================================================= diff --git a/docs/reference/troubleshooting/index.html b/docs/reference/troubleshooting/index.html index 47e63ddb4..c8dcf1a6f 100644 --- a/docs/reference/troubleshooting/index.html +++ b/docs/reference/troubleshooting/index.html @@ -3,10 +3,10 @@ - + - Troubleshooting - Javet 3.0.2 documentation + Troubleshooting - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/reference/troubleshooting/logging.html b/docs/reference/troubleshooting/logging.html index 8fc51ff33..0306e83ee 100644 --- a/docs/reference/troubleshooting/logging.html +++ b/docs/reference/troubleshooting/logging.html @@ -6,7 +6,7 @@ - Logging - Javet 3.0.2 documentation + Logging - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/reference/troubleshooting/termination.html b/docs/reference/troubleshooting/termination.html index f669da00d..fcb2bff1b 100644 --- a/docs/reference/troubleshooting/termination.html +++ b/docs/reference/troubleshooting/termination.html @@ -6,7 +6,7 @@ - Termination - Javet 3.0.2 documentation + Termination - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/reference/v8_values/index.html b/docs/reference/v8_values/index.html index e7a45d637..af42064dd 100644 --- a/docs/reference/v8_values/index.html +++ b/docs/reference/v8_values/index.html @@ -6,7 +6,7 @@ - V8 Values - Javet 3.0.2 documentation + V8 Values - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/reference/v8_values/v8_collection.html b/docs/reference/v8_values/v8_collection.html index 42917374d..ce4c4c8a6 100644 --- a/docs/reference/v8_values/v8_collection.html +++ b/docs/reference/v8_values/v8_collection.html @@ -6,7 +6,7 @@ - V8 Collection - Javet 3.0.2 documentation + V8 Collection - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/reference/v8_values/v8_function.html b/docs/reference/v8_values/v8_function.html index 7cf696eb4..bbe7affac 100644 --- a/docs/reference/v8_values/v8_function.html +++ b/docs/reference/v8_values/v8_function.html @@ -6,7 +6,7 @@ - V8 Function - Javet 3.0.2 documentation + V8 Function - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -1063,7 +1066,7 @@

    How to Handle Argument Count Mismatches? +

    diff --git a/docs/reference/v8_values/v8_promise.html b/docs/reference/v8_values/v8_promise.html index f6ca9f506..c70744954 100644 --- a/docs/reference/v8_values/v8_promise.html +++ b/docs/reference/v8_values/v8_promise.html @@ -6,7 +6,7 @@ - V8 Promise - Javet 3.0.2 documentation + V8 Promise - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/release_notes/index.html b/docs/release_notes/index.html index 3d715a40d..ebff7f65f 100644 --- a/docs/release_notes/index.html +++ b/docs/release_notes/index.html @@ -6,7 +6,7 @@ - Release Notes - Javet 3.0.2 documentation + Release Notes - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/release_notes/release_notes_0_7.html b/docs/release_notes/release_notes_0_7.html index 83787a4c1..9d36c9d28 100644 --- a/docs/release_notes/release_notes_0_7.html +++ b/docs/release_notes/release_notes_0_7.html @@ -6,7 +6,7 @@ - Release Notes 0.7.x - Javet 3.0.2 documentation + Release Notes 0.7.x - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/release_notes/release_notes_0_8.html b/docs/release_notes/release_notes_0_8.html index d98891edb..0b1461b39 100644 --- a/docs/release_notes/release_notes_0_8.html +++ b/docs/release_notes/release_notes_0_8.html @@ -6,7 +6,7 @@ - Release Notes 0.8.x - Javet 3.0.2 documentation + Release Notes 0.8.x - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/release_notes/release_notes_0_9.html b/docs/release_notes/release_notes_0_9.html index 3c4b61e94..5f045d8ec 100644 --- a/docs/release_notes/release_notes_0_9.html +++ b/docs/release_notes/release_notes_0_9.html @@ -6,7 +6,7 @@ - Release Notes 0.9.x - Javet 3.0.2 documentation + Release Notes 0.9.x - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/release_notes/release_notes_1_0.html b/docs/release_notes/release_notes_1_0.html index 21ab1cb19..037c0eaf7 100644 --- a/docs/release_notes/release_notes_1_0.html +++ b/docs/release_notes/release_notes_1_0.html @@ -6,7 +6,7 @@ - Release Notes 1.0.x - Javet 3.0.2 documentation + Release Notes 1.0.x - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/release_notes/release_notes_1_1.html b/docs/release_notes/release_notes_1_1.html index bc67ac9c4..a3eaaf3ef 100644 --- a/docs/release_notes/release_notes_1_1.html +++ b/docs/release_notes/release_notes_1_1.html @@ -6,7 +6,7 @@ - Release Notes 1.1.x - Javet 3.0.2 documentation + Release Notes 1.1.x - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/release_notes/release_notes_2_0.html b/docs/release_notes/release_notes_2_0.html index 85ee8cdf3..bb967ff2a 100644 --- a/docs/release_notes/release_notes_2_0.html +++ b/docs/release_notes/release_notes_2_0.html @@ -6,7 +6,7 @@ - Release Notes 2.0.x - Javet 3.0.2 documentation + Release Notes 2.0.x - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/release_notes/release_notes_2_1.html b/docs/release_notes/release_notes_2_1.html index cd3d717f9..321da28d6 100644 --- a/docs/release_notes/release_notes_2_1.html +++ b/docs/release_notes/release_notes_2_1.html @@ -6,7 +6,7 @@ - Release Notes 2.1.x - Javet 3.0.2 documentation + Release Notes 2.1.x - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/release_notes/release_notes_2_2.html b/docs/release_notes/release_notes_2_2.html index 3964976d1..959dcec8a 100644 --- a/docs/release_notes/release_notes_2_2.html +++ b/docs/release_notes/release_notes_2_2.html @@ -6,7 +6,7 @@ - Release Notes 2.2.x - Javet 3.0.2 documentation + Release Notes 2.2.x - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/release_notes/release_notes_3_0.html b/docs/release_notes/release_notes_3_0.html index 21fa0f4ae..8959eb6af 100644 --- a/docs/release_notes/release_notes_3_0.html +++ b/docs/release_notes/release_notes_3_0.html @@ -6,7 +6,7 @@ - Release Notes 3.0.x - Javet 3.0.2 documentation + Release Notes 3.0.x - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -300,6 +303,27 @@

    Release Notes 3.0.x#

    +
    +

    3.0.3 V8 v12.1#

    +
      +
    • Upgraded V8 to v12.1.285.26 (2024-01-17)

    • +
    • Upgraded Node.js to v20.11.0 (2024-01-09)

    • +
    • Restore the reference lock

    • +
    • Downgraded to Ubuntu 20.04 for better compatibility

    • +
    • Fixed a slight memory leak in closing the V8 runtime

    • +
    • Fixed a memory leak in dynamic proxy and dynamic object

    • +
    • Applied a temporary patch to V8 to avoid crashes on few Linux distributions in VM

    • +
    • Added kNoStdioInitialization and kNoDefaultSignalHandling to Node.js initialization

    • +
    • Improved performance of BaseJavetConsoleInterceptor

    • +
    • Added JavetJVMInterceptor

    • +
    • Added createSnapshot() to V8Runtime

    • +
    • Added isCreateSnapshotEnabled(), setCreateSnapshotEnabled(), getSnapshotBlob(), setSnapshotBlob() to RuntimeOptions

    • +
    • Added RuntimeCreateSnapshotDisabled, RuntimeCreateSnapshotBlocked to JavetError

    • +
    • Added isProxyListEnabled(), setProxyListEnabled() to JavetConverterConfig

    • +
    • Added ArrayUtils, CollectionUtils

    • +
    • Fixed CDTShell

    • +
    +

    3.0.2 V8 v12.0#

    diff --git a/docs/release_notes/release_notes_3_0.rst b/docs/release_notes/release_notes_3_0.rst index 4b5a52621..9fa7810d5 100644 --- a/docs/release_notes/release_notes_3_0.rst +++ b/docs/release_notes/release_notes_3_0.rst @@ -2,6 +2,26 @@ Release Notes 3.0.x =================== +3.0.3 V8 v12.1 +-------------- + +* Upgraded V8 to ``v12.1.285.26`` (2024-01-17) +* Upgraded Node.js to ``v20.11.0`` `(2024-01-09) `_ +* Restore the reference lock +* Downgraded to Ubuntu 20.04 for better compatibility +* Fixed a slight memory leak in closing the V8 runtime +* Fixed a memory leak in dynamic proxy and dynamic object +* Applied a temporary `patch `_ to V8 to avoid crashes on few Linux distributions in VM +* Added ``kNoStdioInitialization`` and ``kNoDefaultSignalHandling`` to Node.js initialization +* Improved performance of ``BaseJavetConsoleInterceptor`` +* Added ``JavetJVMInterceptor`` +* Added ``createSnapshot()`` to ``V8Runtime`` +* Added ``isCreateSnapshotEnabled()``, ``setCreateSnapshotEnabled()``, ``getSnapshotBlob()``, ``setSnapshotBlob()`` to ``RuntimeOptions`` +* Added ``RuntimeCreateSnapshotDisabled``, ``RuntimeCreateSnapshotBlocked`` to ``JavetError`` +* Added ``isProxyListEnabled()``, ``setProxyListEnabled()`` to ``JavetConverterConfig`` +* Added ``ArrayUtils``, ``CollectionUtils`` +* Fixed ``CDTShell`` + 3.0.2 V8 v12.0 -------------- diff --git a/docs/search.html b/docs/search.html index c697d151a..f6fcd937b 100644 --- a/docs/search.html +++ b/docs/search.html @@ -4,7 +4,7 @@ - Search - Javet 3.0.2 documentation + Search - Javet 3.0.3 documentation @@ -122,7 +122,7 @@ - + diff --git a/docs/searchindex.js b/docs/searchindex.js index 0edefca2e..187c02b56 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"docnames": ["development/build", "development/build_javet_from_scratch", "development/build_javet_with_docker", "development/debug_with_chrome_developer_tools", "development/design", "development/index", "development/performance", "development/test", "development/tools", "faq/background/history_with_j2v8", "faq/background/index", "faq/background/what_is_the_motivation", "faq/development/how_to_think_in_javet", "faq/development/index", "faq/development/where_are_es6_api_in_v8_mode", "faq/development/where_are_the_examples", "faq/development/why_is_the_inspector_disabled_in_node_js_mode", "faq/environment/can_javet_support_legacy_linux", "faq/environment/index", "faq/index", "faq/troubleshooting/a_dynamic_link_library_dll_initialization_routine_failed", "faq/troubleshooting/can_i18n_be_supported", "faq/troubleshooting/can_i_debug_javet_in_chrome_dev_tools", "faq/troubleshooting/index", "faq/troubleshooting/why_node_js_crashes_when_being_closed", "index", "reference/converters/bridge_converter", "reference/converters/custom_converter", "reference/converters/index", "reference/converters/object_converter", "reference/converters/primitive_converter", "reference/converters/proxy_converter", "reference/index", "reference/javadoc/index", "reference/resource_management/index", "reference/resource_management/load_and_unload", "reference/resource_management/lock", "reference/resource_management/memory_management", "reference/resource_management/modularization", "reference/tips/best_practices", "reference/tips/index", "reference/todo_list", "reference/troubleshooting/error_codes", "reference/troubleshooting/index", "reference/troubleshooting/logging", "reference/troubleshooting/termination", "reference/v8_values/index", "reference/v8_values/v8_collection", "reference/v8_values/v8_function", "reference/v8_values/v8_promise", "release_notes/index", "release_notes/release_notes_0_7", "release_notes/release_notes_0_8", "release_notes/release_notes_0_9", "release_notes/release_notes_1_0", "release_notes/release_notes_1_1", "release_notes/release_notes_2_0", "release_notes/release_notes_2_1", "release_notes/release_notes_2_2", "release_notes/release_notes_3_0", "tutorial/advanced/expose_json_node_in_v8", "tutorial/advanced/index", "tutorial/advanced/interact_with_node_js", "tutorial/advanced/java_and_javascript_interop", "tutorial/advanced/object_converter", "tutorial/basic/engine_pool", "tutorial/basic/hello_javet", "tutorial/basic/index", "tutorial/basic/installation", "tutorial/basic/interception", "tutorial/basic/javet_shell", "tutorial/basic/node_js_mode_and_v8_mode", "tutorial/basic/polyfill", "tutorial/basic/spring_integration", "tutorial/index", "tutorial/migration_guides/index", "tutorial/migration_guides/migrate_from_j2v8"], "filenames": ["development/build.rst", "development/build_javet_from_scratch.rst", "development/build_javet_with_docker.rst", "development/debug_with_chrome_developer_tools.rst", "development/design.rst", "development/index.rst", "development/performance.rst", "development/test.rst", "development/tools.rst", "faq/background/history_with_j2v8.rst", "faq/background/index.rst", "faq/background/what_is_the_motivation.rst", "faq/development/how_to_think_in_javet.rst", "faq/development/index.rst", "faq/development/where_are_es6_api_in_v8_mode.rst", "faq/development/where_are_the_examples.rst", "faq/development/why_is_the_inspector_disabled_in_node_js_mode.rst", "faq/environment/can_javet_support_legacy_linux.rst", "faq/environment/index.rst", "faq/index.rst", "faq/troubleshooting/a_dynamic_link_library_dll_initialization_routine_failed.rst", "faq/troubleshooting/can_i18n_be_supported.rst", "faq/troubleshooting/can_i_debug_javet_in_chrome_dev_tools.rst", "faq/troubleshooting/index.rst", "faq/troubleshooting/why_node_js_crashes_when_being_closed.rst", "index.rst", "reference/converters/bridge_converter.rst", "reference/converters/custom_converter.rst", "reference/converters/index.rst", "reference/converters/object_converter.rst", "reference/converters/primitive_converter.rst", "reference/converters/proxy_converter.rst", "reference/index.rst", "reference/javadoc/index.rst", "reference/resource_management/index.rst", "reference/resource_management/load_and_unload.rst", "reference/resource_management/lock.rst", "reference/resource_management/memory_management.rst", "reference/resource_management/modularization.rst", "reference/tips/best_practices.rst", "reference/tips/index.rst", "reference/todo_list.rst", "reference/troubleshooting/error_codes.rst", "reference/troubleshooting/index.rst", "reference/troubleshooting/logging.rst", "reference/troubleshooting/termination.rst", "reference/v8_values/index.rst", "reference/v8_values/v8_collection.rst", "reference/v8_values/v8_function.rst", "reference/v8_values/v8_promise.rst", "release_notes/index.rst", "release_notes/release_notes_0_7.rst", "release_notes/release_notes_0_8.rst", "release_notes/release_notes_0_9.rst", "release_notes/release_notes_1_0.rst", "release_notes/release_notes_1_1.rst", "release_notes/release_notes_2_0.rst", "release_notes/release_notes_2_1.rst", "release_notes/release_notes_2_2.rst", "release_notes/release_notes_3_0.rst", "tutorial/advanced/expose_json_node_in_v8.rst", "tutorial/advanced/index.rst", "tutorial/advanced/interact_with_node_js.rst", "tutorial/advanced/java_and_javascript_interop.rst", "tutorial/advanced/object_converter.rst", "tutorial/basic/engine_pool.rst", "tutorial/basic/hello_javet.rst", "tutorial/basic/index.rst", "tutorial/basic/installation.rst", "tutorial/basic/interception.rst", "tutorial/basic/javet_shell.rst", "tutorial/basic/node_js_mode_and_v8_mode.rst", "tutorial/basic/polyfill.rst", "tutorial/basic/spring_integration.rst", "tutorial/index.rst", "tutorial/migration_guides/index.rst", "tutorial/migration_guides/migrate_from_j2v8.rst"], "titles": ["Build Javet", "Build Javet from Scratch", "Build Javet with Docker", "Debug with Chrome Developer Tools", "Javet Design", "Development", "Javet Performance", "Test Javet", "Development Tools", "History with J2V8", "Background", "What is the Motivation?", "How to Think in Javet?", "Development", "Where are ES6 API in V8 Mode?", "Where are the Examples?", "Why is the Inspector Disabled in Node.js Mode?", "Can Javet Support Legacy Linux?", "Environment", "FAQ", "A dynamic link library (DLL) initialization routine failed", "Can i18n be Supported?", "Can I Debug Javet in Chrome DevTools?", "Troubleshooting", "Why Node.js Crashes When being Closed?", "Javet", "Bridge Converter", "Custom Converter", "Converters", "Object Converter", "Primitive Converter", "Proxy Converter", "Reference", "API Reference", "Resource Management", "Load and Unload", "Know the Lock", "Memory Management", "Modularization", "Best Practices", "Tips", "TODO List", "Error Codes", "Troubleshooting", "Logging", "Termination", "V8 Values", "V8 Collection", "V8 Function", "V8 Promise", "Release Notes", "Release Notes 0.7.x", "Release Notes 0.8.x", "Release Notes 0.9.x", "Release Notes 1.0.x", "Release Notes 1.1.x", "Release Notes 2.0.x", "Release Notes 2.1.x", "Release Notes 2.2.x", "Release Notes 3.0.x", "Expose JsonNode in V8", "Advanced", "Interact with Node.js", "Java and JavaScript Interop", "Object Converter", "Javet Engine Pool", "Hello Javet", "Basic", "Installation", "Interception", "Javet Shell", "Node.js Mode and V8 Mode", "Polyfill", "Spring Integration", "Tutorial", "Migration Guides", "Migrate from J2V8"], "terms": {"It": [0, 2, 4, 6, 9, 12, 16, 21, 25, 27, 28, 31, 36, 37, 38, 39, 48, 65, 70, 71, 76], "": [0, 2, 4, 6, 9, 11, 24, 27, 31, 36, 37, 38, 39, 42, 48, 49, 60, 62, 64, 71, 76], "quit": [0, 4, 6, 11, 12, 28, 31, 37, 44, 45, 48, 60, 62, 65, 76], "hard": [0, 9, 49, 76], "develop": [0, 19, 22, 25, 42, 49, 51, 60, 76], "successfulli": [0, 2, 3], "variou": [0, 58, 76], "reason": [0, 4, 9, 21, 24, 42, 49, 62, 76], "node": [0, 2, 3, 5, 7, 9, 13, 14, 19, 20, 21, 23, 25, 35, 36, 37, 41, 42, 48, 49, 50, 53, 55, 57, 58, 59, 60, 61, 65, 67, 68, 70, 73, 74], "j": [0, 2, 5, 7, 9, 13, 14, 19, 20, 21, 23, 25, 35, 36, 37, 41, 42, 48, 49, 50, 51, 53, 55, 57, 58, 59, 61, 65, 67, 68, 74], "need": [0, 3, 6, 9, 27, 28, 29, 31, 36, 37, 38, 48, 49, 60, 63, 68, 76], "built": [0, 2, 3, 6, 7, 26, 29, 37, 42, 45, 48, 49, 52, 53, 57, 60, 76], "static": [0, 1, 16, 27, 48, 53, 55, 62], "librari": [0, 2, 3, 4, 7, 12, 19, 21, 23, 38, 42, 44, 48, 53], "monolith": 0, "everi": [0, 4, 12, 28, 36, 37, 48], "o": [0, 2, 4, 25, 36, 42, 48, 60, 76], "platform": [0, 5], "ha": [0, 2, 4, 6, 8, 9, 12, 16, 27, 29, 31, 35, 37, 38, 44, 47, 48, 49, 52, 60, 76], "its": [0, 4, 9, 31, 36, 37, 38, 48, 49], "own": [0, 4, 9, 27, 29, 31, 35, 37, 38, 48, 49], "pitfal": 0, "which": [0, 3, 4, 6, 7, 9, 12, 15, 17, 24, 25, 28, 29, 31, 35, 37, 38, 45, 48, 60, 63, 69, 71, 72, 76], "usual": [0, 27, 31, 38, 45, 48, 49, 62], "make": [0, 1, 2, 16, 28, 29, 37, 38, 49, 62, 72, 76], "frustrat": [0, 9], "even": [0, 9, 76], "desper": 0, "here": [0, 3, 4, 6, 9, 11, 27, 31, 35, 37, 38, 48, 49, 62, 63, 64], "ar": [0, 1, 2, 3, 4, 6, 8, 9, 12, 13, 17, 19, 24, 25, 26, 27, 28, 29, 30, 31, 35, 36, 37, 38, 39, 42, 45, 48, 49, 51, 52, 53, 60, 62, 63, 64, 68, 69, 71, 76], "3": [0, 1, 5, 6, 9, 17, 24, 25, 26, 31, 35, 38, 47, 48, 50, 66, 68, 69, 70], "wai": [0, 4, 12, 24, 25, 26, 27, 35, 37, 38, 39, 45, 48, 49, 53, 60, 62, 65, 69, 73], "docker": [0, 5, 9], "from": [0, 2, 4, 5, 6, 9, 11, 15, 16, 17, 24, 28, 31, 36, 38, 39, 42, 45, 48, 49, 52, 53, 54, 55, 60, 62, 63, 65, 66, 69, 70, 74, 75], "scratch": [0, 5, 11], "all": [0, 1, 3, 4, 9, 24, 26, 27, 29, 31, 35, 37, 38, 48, 52, 54, 60, 62, 64, 76], "them": [0, 3, 31, 37, 38, 48, 60], "share": [0, 1, 4, 36, 38, 48, 49, 62, 76], "same": [0, 4, 16, 36, 37, 38, 39, 48, 49, 60, 76], "next": [0, 28, 48], "section": [0, 38, 48], "ubuntu": [0, 2, 17, 38, 52, 55, 59, 68], "22": [0, 54, 59, 68], "04": [0, 2, 17, 51, 52, 55, 57, 59, 68], "cmake": [0, 1, 9], "25": [0, 54, 56, 59], "1": [0, 4, 6, 9, 12, 17, 26, 27, 29, 31, 35, 38, 39, 45, 47, 48, 50, 60, 63, 64, 68, 69, 70, 71, 72, 76], "jdk": [0, 5, 27, 44, 60], "8": [0, 3, 5, 6, 9, 17, 25, 27, 37, 50, 54, 57, 60, 62, 68], "gradl": [0, 1, 2, 5, 9, 31], "2": [0, 6, 8, 9, 12, 17, 25, 26, 29, 31, 35, 38, 39, 45, 47, 50, 63, 66, 68, 69, 70, 71, 72, 76], "gcc": [0, 17, 52, 59], "11": [0, 27, 54, 55, 56, 59], "python": [0, 1, 5], "9": [0, 9, 17, 50, 62], "catalina": [0, 68], "latest": [0, 2, 71], "brew": 0, "xcode": 0, "4": [0, 6, 9, 31, 35, 37, 38, 47, 48, 50, 62, 69, 70], "16": [0, 6, 17, 37, 52, 53, 55, 56, 57, 58, 68], "10": [0, 2, 6, 25, 37, 45, 54, 59, 60, 68], "visual": [0, 5, 56, 57], "studio": [0, 5, 56, 57], "2022": [0, 5, 55, 56, 57], "commun": [0, 3, 5, 9, 16, 25], "24": [0, 52, 57, 59, 68], "come": [0, 4, 6, 36, 38], "sdk": [0, 44, 73], "windbg": 0, "wsl2": [0, 2], "option": [0, 5, 16, 30, 38, 39, 48, 53, 55, 59, 60, 69, 71], "ndk": [0, 55], "r25b": 0, "30": [0, 56], "javet_hom": [0, 1], "i": [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 12, 13, 14, 15, 17, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 35, 36, 37, 38, 39, 42, 44, 45, 47, 49, 52, 53, 60, 63, 64, 65, 66, 68, 69, 70, 71, 72, 73, 76], "home": 0, "directori": [0, 4, 38, 72], "node_hom": [0, 1], "v8_home": [0, 1], "depot_tools_hom": [0, 1], "googl": [0, 3], "depot": 0, "tool": [0, 1, 2, 5, 17, 22, 25, 51], "android_ndk_hom": [0, 1], "android_sdk_hom": 0, "descript": [0, 31, 37], "custom": [0, 4, 5, 28, 38, 39, 48, 52, 53, 55], "libcxx": 0, "off": [0, 1, 3, 4, 37], "The": [0, 1, 2, 3, 4, 6, 7, 9, 12, 15, 16, 20, 24, 26, 27, 28, 31, 35, 36, 37, 38, 42, 45, 48, 49, 60, 62, 63, 68, 69, 70, 71, 76], "offici": [0, 1, 9, 15, 17, 25], "releas": [0, 1, 4, 6, 9, 25, 37, 42, 76], "doesn": [0, 3, 4, 9, 29, 31, 35, 36, 37, 38, 42, 44, 45, 48, 73, 76], "t": [0, 3, 4, 9, 16, 24, 25, 27, 28, 29, 31, 35, 36, 37, 38, 42, 44, 45, 48, 70, 71, 73, 76], "support": [0, 1, 2, 4, 8, 9, 16, 18, 19, 23, 25, 29, 30, 31, 35, 37, 38, 42, 45, 47, 48, 52, 53, 54, 55, 56, 58, 59, 68, 71, 76], "debug": [0, 4, 5, 16, 19, 23, 25, 44, 48], "extern": [0, 6, 37], "startup": 0, "data": [0, 4, 28, 37, 38, 48, 51, 56], "i18n": [0, 1, 19, 23, 42, 55], "pleas": [0, 1, 2, 3, 4, 6, 11, 16, 17, 21, 22, 25, 28, 31, 35, 36, 37, 38, 39, 45, 48, 49, 50, 60, 63, 64, 65, 66, 68, 69, 70, 72, 76], "contact": [0, 1, 9, 16, 17, 21, 50, 68, 76], "maintain": [0, 16, 17, 21, 50, 68, 76], "privat": [0, 16, 17, 21, 27, 29, 31, 48, 60, 68, 69], "thi": [0, 3, 4, 9, 11, 12, 17, 20, 24, 25, 27, 28, 29, 31, 35, 36, 37, 38, 49, 55, 60, 62, 63, 69, 71, 76], "pointer": [0, 37, 48], "compress": 0, "sandbox": 0, "snapshot": [0, 17, 56], "follow": [1, 2, 3, 4, 15, 17, 21, 24, 25, 27, 29, 37, 38, 39, 42, 44, 47, 48, 49, 60, 62, 69, 71], "guid": [1, 25, 74], "If": [1, 2, 12, 24, 25, 28, 29, 30, 31, 37, 38, 39, 45, 48, 68, 69, 70, 76], "you": [1, 2, 3, 8, 9, 12, 15, 22, 24, 25, 27, 31, 36, 37, 44, 48, 49, 50, 68, 72, 73, 76], "face": [1, 4], "ani": [1, 9, 28, 29, 30, 31, 38, 42, 44, 45, 48, 76], "issu": [1, 4, 11, 24, 36, 37, 38, 39, 52, 53, 54, 57, 59], "mai": [1, 2, 3, 4, 6, 9, 12, 15, 24, 25, 26, 28, 31, 35, 36, 37, 38, 39, 44, 45, 48, 73], "sjtucaocao": [1, 2, 25], "clone": [1, 2, 56], "sourc": [1, 3, 16, 28, 36, 38, 42, 45, 60, 63, 64, 65, 66, 69, 70, 72, 76], "code": [1, 3, 4, 6, 9, 12, 16, 27, 28, 29, 36, 37, 38, 39, 43, 45, 49, 53, 54, 58, 60, 63, 64, 65, 66, 69, 70, 72, 76], "checkout": 1, "proper": 1, "version": [1, 3, 4, 8, 11, 25, 31, 38, 50, 68, 71], "also": [1, 2, 4, 6, 9, 11, 12, 28, 30, 31, 35, 36, 37, 38, 44, 48, 49, 62, 76], "sure": [1, 2, 9, 16, 28, 37, 38, 62, 72], "arg": [1, 27, 48, 62], "gn": 1, "file": [1, 4, 6, 9, 21, 37, 38, 49, 62, 72], "look": [1, 4, 9, 11, 38, 53], "like": [1, 3, 6, 9, 11, 12, 25, 38, 39, 42, 48, 55, 70], "is_debug": 1, "fals": [1, 16, 26, 28, 31, 35, 37, 38, 48, 62, 63], "target_cpu": 1, "v8_monolith": 1, "true": [1, 11, 16, 26, 28, 31, 35, 37, 38, 45, 48, 60, 62, 63, 64, 68, 70], "v8_use_external_startup_data": 1, "is_component_build": 1, "v8_enable_i18n_support": 1, "v8_enable_pointer_compress": 1, "v8_static_librari": 1, "symbol_level": 1, "0": [1, 3, 9, 17, 25, 26, 27, 29, 31, 37, 38, 39, 45, 47, 48, 50, 60, 62, 64, 68, 69, 72, 76], "use_custom_libcxx": 1, "v8_enable_sandbox": 1, "x64": [1, 38], "To": [1, 3, 9, 21, 28, 35, 41, 63], "enabl": [1, 2, 3, 6, 12, 16, 21, 31, 37, 48, 49, 52, 53, 63], "set": [1, 3, 4, 7, 9, 12, 26, 27, 28, 29, 31, 35, 37, 38, 44, 47, 49, 52, 58, 60, 62, 63, 64, 69], "export": [1, 38], "path": [1, 17, 35, 38, 42, 58, 62], "cd": [1, 2, 38], "ninja": 1, "c": [1, 31, 38, 48, 55, 56, 57, 60, 64], "out": [1, 25, 37, 38, 42, 45, 60, 62, 63, 64, 66, 69, 70, 76], "python3": [1, 9], "script": [1, 4, 9, 12, 25, 38, 39, 45, 48, 52, 56, 65, 70, 72], "patch_v8_build": 1, "py": 1, "p": [1, 31], "requir": [1, 6, 8, 12, 35, 38, 39, 45, 48, 49, 62], "depot_tools_win_toolchain": 1, "gen": 1, "id": [1, 3, 4, 42, 48, 68], "v": [1, 5, 9, 25, 38], "solut": [1, 11, 29, 48], "dev": [1, 6], "v8gen": 1, "arm": [1, 25, 54, 68], "target_o": 1, "v8_target_cpu": 1, "ia32": 1, "x86": [1, 25, 53, 54, 68], "A": [1, 4, 19, 23, 27, 38, 48], "few": [1, 2, 3, 8, 9, 11, 12, 27, 28, 31, 37, 48, 51, 52, 59, 63, 64, 70], "certain": [1, 3, 4, 12, 48, 49, 53], "warn": [1, 44, 52], "error": [1, 9, 35, 38, 43, 44, 48, 49, 53, 54, 55, 58], "so": [1, 2, 4, 6, 7, 9, 12, 14, 16, 17, 24, 26, 27, 28, 29, 31, 35, 36, 37, 38, 39, 44, 48, 49, 56, 60, 62, 64, 68, 72, 73, 76], "msvc": [1, 38], "stop": [1, 9, 57], "compil": [1, 4, 6, 31, 38, 42, 48, 59, 63, 76], "turn": [1, 3, 4, 37, 52, 59], "those": [1, 3, 4, 12, 24, 37, 38, 48], "lt": 1, "patch_node_build": 1, "configur": 1, "without": [1, 2, 3, 4, 24, 29, 31, 35, 36, 48, 54, 58, 60, 76], "intl": 1, "j4": 1, "first": [1, 3, 35, 38, 48, 51, 76], "thin": 1, "disabl": [1, 12, 13, 19, 31, 37, 39, 45, 49, 56], "second": [1, 3, 15, 21, 38, 45, 48], "mani": [1, 9, 11, 37, 48, 76], "posit": [1, 6, 48], "independ": [1, 6], "link": [1, 19, 23, 37, 38], "phase": 1, "broken": [1, 9, 37, 48], "fpic": 1, "usr": [1, 17], "bin": [1, 17], "ld": 1, "libnod": 1, "node_bind": 1, "reloc": 1, "r_x86_64_tpoff32": 1, "against": [1, 48], "_zn4nodel23thread_local_modpending": 1, "can": [1, 2, 3, 4, 6, 12, 18, 19, 23, 24, 29, 31, 37, 38, 39, 49, 62, 63, 71, 72, 73, 76], "us": [1, 3, 4, 6, 8, 11, 24, 28, 30, 35, 37, 38, 39, 44, 48, 65, 76], "when": [1, 4, 6, 9, 19, 20, 23, 31, 37, 38, 39, 45, 48, 49, 55, 57, 76], "object": [1, 4, 12, 24, 37, 39, 47, 52, 53, 54, 55, 60, 61, 63, 65, 69, 74, 76], "recompil": 1, "vcbuild": 1, "bat": 1, "vs2022": 1, "onc": [1, 27, 28, 37, 38, 42, 62], "readi": 1, "navig": [1, 38], "cpp": 1, "access": [1, 12, 31, 35, 37, 42, 48], "execut": [1, 3, 4, 6, 31, 38, 39, 42, 45, 47, 48, 49, 60, 65, 66, 70], "correspond": [1, 2, 4, 24, 37, 38, 39, 48], "command": [1, 70], "sh": [1, 38], "dnode_dir": 1, "dv8_dir": 1, "maco": [1, 9, 25, 35, 68], "cmd": [1, 38], "after": [1, 3, 9, 29, 31, 35, 38, 39, 45, 48, 49, 60, 76], "while": [1, 2, 31, 45, 62, 70], "place": [1, 4, 9, 24, 28, 37, 76], "folder": [1, 39, 62], "src": 1, "main": [1, 27, 31, 63], "resourc": [1, 4, 12, 15, 25, 28, 32, 36, 38, 42, 45, 49, 60, 66, 69, 70, 73], "libjavet": [1, 35, 38], "dylib": 1, "dll": [1, 19, 23, 38], "arch": [1, 25, 54, 68], "dcmake_android_ndk": 1, "dcmake_android_arch": 1, "jnilib": 1, "armeabi": 1, "v7a": 1, "v8a": 1, "mode": [1, 5, 7, 13, 17, 19, 20, 21, 24, 25, 35, 37, 39, 48, 49, 52, 53, 55, 58, 65, 67, 68, 74, 76], "append": [1, 31, 63], "denable_i18n": 1, "test": [1, 2, 4, 5, 6, 9, 15, 16, 17, 25, 31, 36, 38, 48, 49, 51, 62, 68, 72], "jar": [1, 4, 9], "lib": [1, 38, 54], "aar": 1, "output": [1, 27, 48, 60, 62, 63, 64], "As": [2, 3, 4, 12, 26, 29, 31, 35, 37, 44, 48, 73], "regard": [2, 3], "mac": [2, 9, 25, 76], "contributor": 2, "welcom": [2, 70], "interest": [2, 9], "Or": [2, 16], "have": [2, 9, 16, 25, 27, 29, 31, 37, 38, 48, 49, 72, 76], "wait": [2, 3, 54, 62], "long": [2, 29, 30, 31, 36, 48, 60], "20": [2, 24, 52, 54, 55, 56, 57, 58, 68], "git": 2, "network": 2, "connect": [2, 3, 4, 65], "up": [2, 3, 4, 6, 12, 31, 36, 37, 38, 53, 54, 62], "run": [2, 4, 6, 27, 31, 36, 37, 38, 45, 72], "repositori": [2, 17], "imag": [2, 9], "avail": [2, 3, 4, 20, 35, 42, 48, 71], "http": [2, 3, 4, 6, 25, 62], "com": [2, 6, 25, 37, 38, 44, 68], "r": [2, 17, 63], "caoccao": [2, 6, 25, 37, 38, 44, 68], "f": [2, 4, 38], "x86_64": [2, 25, 38, 54, 68], "build_artifact": 2, "dockerfil": [2, 53, 57], "pull": 2, "5gb": 2, "actual": [2, 3, 4, 6, 9, 12, 28, 36, 37, 38, 42, 48, 60, 62], "take": [2, 4, 6, 9, 11, 24, 30, 31, 37, 38, 48, 52, 54, 60, 62, 65, 70, 76], "minut": [2, 4, 28], "includ": [2, 9, 26, 35, 48, 76], "depend": [2, 4, 6, 9, 31, 38, 44, 48, 73], "maven": [2, 5, 31], "central": [2, 8], "instruct": [2, 37], "insid": [2, 3, 4, 31, 37, 49], "perform": [2, 3, 4, 5, 9, 24, 25, 26, 28, 29, 35, 37, 38, 39, 48, 51, 54, 58, 59, 60, 62, 65, 69, 76], "base_jvm": 2, "base": [2, 6, 7, 31, 37, 48, 53, 55, 56, 60, 76], "jvm": [2, 4, 21, 25, 28, 31, 35, 36, 51, 62, 64, 65, 71, 76], "base_nod": 2, "base_v8": 2, "v8": [2, 3, 5, 7, 9, 11, 12, 13, 19, 21, 24, 25, 28, 29, 31, 32, 35, 36, 39, 41, 42, 45, 50, 61, 62, 63, 64, 65, 67, 68, 69, 70, 73, 74], "base_gradl": 2, "final": [2, 27, 28, 29, 31, 37, 38, 42, 45, 48, 49, 60], "artifact": 2, "base_all_in_on": 2, "build_all_in_on": 2, "updat": [2, 17, 35, 48, 52, 53, 54, 55, 57], "daemon": [2, 37, 45], "json": [2, 3, 26, 38, 60, 64], "storag": [2, 6], "opt": 2, "dm": 2, "bases": 2, "120gb": 2, "size": [2, 4, 6, 21, 26, 29, 35, 37, 42], "restart": [2, 76], "m": [2, 6, 60], "4g": 2, "roughli": 2, "5": [2, 3, 24, 37, 38, 50, 62, 68, 69, 70], "hour": [2, 9], "internet": 2, "stabl": 2, "dai": [2, 39], "just": [2, 3, 6, 9, 12, 27, 29, 35, 36, 37, 38, 48, 63, 76], "fail": [2, 19, 23, 38, 42, 45, 48, 55], "forev": [2, 37], "larg": [2, 16], "60": 2, "gb": 2, "effici": [2, 15, 53], "push": [2, 47, 48, 49, 58], "Of": [2, 37, 38, 48, 76], "cours": [2, 37, 38, 48, 76], "wise": [2, 17, 48, 60, 68], "workflow": 2, "11gb": 2, "process": [2, 3, 24, 27, 49], "been": [2, 8, 9, 24, 35, 48, 76], "significantli": [2, 42], "chang": [2, 3, 16, 28, 29, 36, 38, 42, 53, 54, 58, 59, 63, 69], "sinc": [2, 9, 68], "v12": [2, 25], "That": [2, 4, 6, 9, 24, 28, 35, 37, 38, 44, 45, 48, 76], "result": [2, 3, 4, 6, 28, 36, 39, 49, 66, 70], "devtool": [3, 19, 23, 25], "aka": 3, "web": [3, 37, 39], "directli": [3, 31, 35, 37, 48, 60, 63, 76], "browser": [3, 39], "help": [3, 39], "edit": [3, 48], "page": 3, "fly": 3, "diagnos": 3, "problem": [3, 6, 9, 27, 48], "quickli": 3, "ultim": 3, "build": [3, 4, 5, 8, 11, 16, 17, 21, 25, 38, 48, 52, 53, 57, 59, 68], "better": [3, 4, 6, 35, 36, 48, 60], "websit": 3, "faster": 3, "javet": [3, 5, 8, 9, 13, 14, 15, 16, 18, 19, 20, 23, 24, 26, 27, 28, 29, 31, 37, 39, 41, 42, 44, 45, 47, 48, 49, 51, 53, 58, 62, 63, 64, 67, 68, 69, 71, 72, 73, 74], "ship": 3, "demo": 3, "applic": [3, 4, 6, 12, 16, 24, 27, 28, 29, 31, 35, 36, 37, 38, 45, 48, 49, 62, 63, 65, 69, 70, 76], "demonstr": 3, "how": [3, 4, 7, 11, 13, 15, 19, 24, 25, 27, 35, 36, 38, 53, 60, 76], "work": [3, 4, 9, 12, 24, 25, 35, 36, 37, 38, 48, 49, 60, 62, 68, 76], "live": [3, 25, 36, 37, 48], "normal": [3, 37, 45, 62], "java": [3, 4, 5, 9, 14, 25, 27, 28, 31, 35, 36, 37, 38, 49, 54, 61, 62, 64, 69, 72, 74, 76], "consol": [3, 4, 27, 48, 49, 60, 62, 65, 66, 69, 70], "an": [3, 4, 6, 9, 11, 12, 14, 25, 26, 28, 31, 35, 36, 37, 38, 39, 44, 45, 48, 49, 64, 69, 70, 71], "interact": [3, 4, 27, 52, 61, 70, 74], "appear": [3, 48], "doe": [3, 4, 16, 24, 35, 37, 45, 48, 76], "arbitrari": [3, 4, 12, 28, 29, 31, 63, 76], "what": [3, 9, 10, 15, 19, 28, 37, 38, 60, 76], "done": [3, 76], "let": [3, 9, 24, 27, 31, 38, 60, 62, 70], "undefin": [3, 28, 31, 38, 48, 60, 70], "b": [3, 26, 28, 31, 38, 48, 60, 63, 64, 70, 72], "7": [3, 6, 17, 37, 50, 62, 68, 69, 70, 76], "inspect": [3, 16, 48], "remot": 3, "target": [3, 7, 28, 29, 60, 76], "click": 3, "voil\u00e0": [3, 31, 62], "screenshot": 3, "show": [3, 4, 31, 37, 38, 48, 49], "evalu": [3, 4, 38, 55, 76], "auto": [3, 17, 35, 52], "complet": [3, 4, 7, 29, 31, 37, 38, 39, 45, 48, 53, 54, 62, 63, 68, 76], "enjoi": 3, "listen": [3, 24, 37, 49, 62], "port": [3, 50, 62], "9229": 3, "default": [3, 4, 21, 28, 29, 31, 35, 37, 38, 45, 48, 63, 69, 71], "becaus": [3, 4, 6, 8, 9, 16, 24, 25, 26, 27, 28, 29, 31, 35, 36, 37, 39, 42, 48, 49, 60, 65, 71, 72, 76], "constantli": 3, "queri": 3, "127": [3, 37], "tell": [3, 24, 31, 35, 37, 38, 62, 69], "flavor": [3, 15, 48, 70], "via": [3, 4, 31, 37, 38, 39, 45, 48, 49, 62, 69], "websocket": 3, "address": [3, 24, 37, 38, 39, 48, 59, 62], "protocol": 3, "current": [3, 4, 9, 42, 48, 68], "v1": [3, 50, 54, 68], "api": [3, 4, 9, 11, 12, 13, 19, 25, 27, 28, 31, 32, 35, 36, 37, 38, 44, 48, 49, 51, 52, 54, 58, 60, 62, 64, 72, 76], "doc": [3, 6, 52, 54], "chromedevtool": 3, "github": [3, 6], "io": [3, 16], "upgrad": [3, 8, 9, 11, 17, 41, 52, 53, 54, 55, 56, 57, 58, 59], "request": 3, "respons": [3, 35, 38, 48], "accept": [3, 16, 28, 44, 48, 49, 53], "switch": [3, 25, 35, 36, 39, 52], "w": 3, "send": [3, 28, 37, 62], "messag": [3, 37, 42, 44], "method": [3, 12, 27, 29, 31, 42, 48, 60], "runtim": [3, 4, 17, 21, 31, 35, 36, 38, 39, 42, 45, 48, 53, 54, 55, 57, 60, 62, 65, 66, 69, 70, 71, 76], "param": 3, "notif": [3, 37], "executioncontextcr": 3, "context": [3, 6, 12, 24, 36, 37, 38, 39, 57], "origin": [3, 4, 48], "name": [3, 4, 12, 27, 29, 35, 38, 42, 44, 48, 54, 57, 60, 69, 72, 73], "inspector": [3, 13, 19], "00000000": 3, "uniqueid": 3, "debugg": [3, 48], "maxscriptscaches": 3, "100000000": 3, "debuggerid": 3, "setpauseonexcept": 3, "state": [3, 48], "none": [3, 48], "setasynccallstackdepth": 3, "maxdepth": [3, 42], "32": [3, 37], "profil": [3, 68], "6": [3, 8, 9, 38, 50, 56, 59, 62, 68, 69, 70], "getisolateid": 3, "setblackboxpattern": 3, "pattern": [3, 12, 15, 29, 45], "runifwaitingfordebugg": 3, "pars": [3, 6], "expos": [3, 4, 25, 28, 29, 31, 37, 38, 41, 48, 49, 54, 61, 74, 76], "callback": [3, 24, 37, 38, 42, 48, 52, 53, 54, 55, 57, 58, 62], "iv8inspectorlisten": 3, "rest": [3, 38], "refer": [3, 6, 11, 24, 25, 31, 35, 36, 38, 39, 45, 48, 49, 57, 59, 60, 63, 64, 65, 66, 68, 69, 70, 72, 76], "detail": [3, 4, 11, 21, 22, 36, 45, 48, 49, 60, 63, 64, 65, 66, 68, 69, 70, 71, 72, 76], "ye": [3, 4, 17, 22, 24, 28, 29, 31, 35, 36, 38, 47, 48, 68, 72], "feel": [3, 38, 48], "free": [3, 4, 12, 29, 36, 37, 38, 48, 52, 65, 76], "server": [3, 6, 28, 68], "your": [3, 9, 17, 31, 35, 39, 44, 73, 76], "environ": [3, 4, 5, 6, 17, 19, 25, 36, 38, 52, 54, 65], "creat": [3, 16, 21, 26, 29, 31, 36, 37, 38, 44, 45, 48, 49, 53, 58, 60, 62, 63, 64, 65, 66, 69, 70, 73, 76], "showcas": 3, "further": [3, 6], "some": [3, 4, 6, 9, 12, 14, 17, 20, 24, 28, 35, 37, 48, 49, 54, 58, 60, 65, 72, 76], "tip": [3, 25, 32], "integr": [3, 9, 25, 44, 51, 67, 74], "embed": [3, 4, 6, 9, 21, 25, 39], "jetti": 3, "Be": [3, 31, 37, 39, 49], "care": [3, 30, 31, 36, 37, 38, 39, 49], "host": [3, 4, 21, 35, 38, 60, 62, 66, 69, 70], "togeth": [3, 62], "otherwis": [3, 29, 30, 35, 36, 48], "refus": 3, "add": [3, 17, 26, 27, 29, 31, 37, 38, 47, 48, 49, 64, 69, 72, 76], "intercept": [3, 5, 31, 37, 38, 51, 53, 67, 74], "event": [3, 39, 49, 62, 76], "In": [3, 4, 6, 12, 16, 24, 26, 28, 31, 35, 36, 37, 38, 39, 45, 48, 49, 60, 62, 76], "practic": [3, 4, 12, 40], "decent": [3, 6, 9, 47, 49], "jackson": [3, 60], "gson": [3, 60], "interpret": [3, 4], "why": [3, 12, 13, 19, 23, 35, 37, 72], "breakpoint": 3, "befor": [3, 12, 24, 28, 35, 37, 38, 62], "right": [3, 35], "featur": [3, 4, 5, 8, 9, 12, 29, 35, 37, 38, 42, 47, 48, 49, 50, 63, 68, 71, 72, 76], "enforc": 3, "authent": 3, "author": 3, "There": [4, 9, 12, 17, 26, 27, 28, 35, 37, 38, 42, 48, 60, 71], "vagu": 4, "boundari": 4, "between": [4, 6, 9, 25, 28, 29, 37, 39, 48, 52, 60, 63], "definit": 4, "mixtur": 4, "both": [4, 6, 28, 35, 37, 42, 49, 53, 71, 76], "trade": 4, "No": [4, 9, 27, 28, 35, 38, 45, 47, 48, 62], "copi": [4, 31, 35, 37], "valu": [4, 25, 27, 28, 29, 30, 32, 35, 37, 38, 42, 47, 51, 52, 53, 54, 60, 69], "Not": [4, 48, 68], "possibl": [4, 29, 36, 39, 60], "weak": 4, "keep": [4, 28, 31, 36, 37, 39, 60], "footprint": 4, "jni": [4, 8, 35, 37, 48, 54, 55, 57], "recycl": [4, 6, 24, 28, 31, 37, 39, 66], "close": [4, 9, 12, 16, 19, 23, 31, 35, 37, 38, 39, 42, 45, 48, 52, 53, 57, 59, 64, 65], "call": [4, 6, 9, 12, 16, 24, 27, 28, 31, 35, 36, 37, 38, 39, 45, 49, 52, 60, 62, 63, 69, 76], "old": [4, 9, 39, 49], "school": 4, "manag": [4, 9, 12, 15, 25, 32, 38, 52], "tri": [4, 9, 20], "hide": [4, 9], "kind": [4, 9, 27, 36, 48, 76], "tediou": [4, 12, 76], "try": [4, 9, 11, 25, 27, 31, 36, 38, 39, 45, 47, 48, 49, 60, 62, 65, 66, 69, 70, 71, 72], "best": [4, 15, 40], "co": 4, "exist": [4, 11, 31, 38, 60, 72], "one": [4, 7, 9, 11, 12, 16, 21, 26, 31, 35, 37, 38, 48, 60, 63, 69, 70, 71, 76], "other": [4, 12, 28, 35, 36, 37, 39, 44, 48, 49, 52, 62, 64, 68, 71, 76], "word": [4, 37, 62], "thei": [4, 9, 29, 35, 38, 39, 42, 49, 60, 71], "side": [4, 6, 16, 37], "don": [4, 9, 16, 25, 31, 38, 44, 71, 73, 76], "interfer": 4, "each": [4, 37, 48, 71, 76], "diagram": [4, 48], "lazi": 4, "load": [4, 12, 20, 34, 42, 72, 76], "dedic": [4, 37, 39, 62, 76], "classload": [4, 76], "comparison": [4, 5, 9, 25], "loadabl": 4, "high": [4, 28, 37], "ecosystem": [4, 71], "secur": [4, 6, 12, 38, 72, 76], "low": 4, "unload": [4, 34, 38, 76], "One": [4, 28], "beauti": [4, 28, 48], "appli": [4, 28, 31, 35, 38, 39, 45, 48, 55, 62], "exampl": [4, 13, 19, 27, 63, 64], "e": [4, 6, 12, 14, 24, 26, 27, 28, 35, 37, 38, 45, 48, 49, 60, 62, 69, 71, 72, 76], "g": [4, 6, 12, 14, 17, 24, 26, 28, 35, 37, 38, 48, 49, 60, 62, 63, 69, 71, 72, 76], "net": [4, 31], "etc": [4, 11, 12, 14, 26, 28, 35, 37, 48, 62, 72], "zero": [4, 37], "byte": [4, 29, 30, 31, 37, 48], "buffer": [4, 37], "achiev": [4, 9, 31, 36, 37, 48], "thread": [4, 6, 9, 16, 37, 42, 45, 49, 52, 53, 65, 76], "multipl": [4, 16, 21, 36, 38, 39, 53, 76], "instanc": [4, 6, 12, 16, 26, 37, 38, 39, 44, 48, 63, 69], "onli": [4, 12, 14, 16, 21, 28, 30, 31, 35, 38, 39, 44, 48, 50, 60, 68, 76], "visibl": [4, 48], "beyond": 4, "allow": [4, 6, 9, 21, 26, 27, 28, 29, 31, 35, 38, 44, 48, 49, 52, 53, 54, 58, 62, 63, 64, 65, 69, 76], "explicit": [4, 26, 76], "await": [4, 6, 39, 48, 49, 52, 56, 62], "more": [4, 6, 9, 17, 29, 35, 37, 38, 41, 42, 45, 48, 49, 53, 54, 65, 66, 69, 70, 71, 72, 76], "control": [4, 24, 28, 38, 45, 48], "over": [4, 24, 28, 38, 48, 76], "async": [4, 6, 24, 49], "global": [4, 12, 38, 48, 57, 65, 76], "recommend": [4, 6, 8, 31, 39, 48, 49, 60, 65], "project": [4, 9, 11, 12, 14, 15, 25, 31, 38, 49, 68, 72, 76], "increas": [4, 28, 42, 76], "provid": [4, 6, 17, 24, 26, 27, 28, 29, 31, 38, 47, 48, 65, 69, 76], "align": 4, "chrome": [4, 5, 19, 23, 25, 51], "bring": [4, 28, 35], "system": [4, 8, 11, 25, 35, 38, 42, 44, 60, 62, 63, 64, 66, 68, 69, 70], "unfortun": [4, 9], "veri": [4, 31, 38, 39, 48, 70, 71], "limit": [4, 12], "howev": [4, 6, 9, 11, 12, 24, 28, 29, 35, 37, 48, 60, 76], "bad": [4, 9], "leav": [4, 11, 29, 38], "typic": [4, 38, 45, 48], "challeng": [4, 9, 12, 28], "sync": 4, "locat": [4, 38, 76], "interceptor": [4, 24, 48, 49, 65, 69], "partial": 4, "know": [4, 7, 9, 24, 34, 38, 48, 76], "want": [4, 8, 9, 12, 24, 28, 35, 36, 37, 42, 48, 49, 50], "defin": [4, 28, 31], "es6": [4, 9, 13, 19, 38], "repres": [4, 12, 28, 37, 48, 76], "string": [4, 27, 29, 30, 31, 38, 44, 49, 51, 60, 62, 64, 66, 69, 70, 72], "dure": [4, 24, 28, 35, 38, 48, 52, 76], "url": 4, "whatev": [4, 24, 36, 37, 48, 49], "store": [4, 37, 38, 48, 57], "map": [4, 26, 28, 29, 38, 47], "kei": [4, 38, 47, 60], "feed": [4, 38], "get": [4, 9, 12, 24, 26, 27, 29, 31, 35, 37, 38, 39, 44, 45, 47, 48, 49, 54, 55, 60, 62, 64, 65, 71, 72, 73, 76], "start": [4, 11, 16, 28, 45, 48, 54, 62, 76], "excel": [4, 9], "articl": 4, "explain": 4, "concept": [4, 12, 49], "insight": 4, "summari": [4, 6], "vm": [4, 39], "heap": [4, 37], "separ": [4, 6, 12, 31], "unrel": [4, 6], "javascript": [4, 6, 16, 24, 25, 28, 31, 36, 38, 49, 54, 61, 64, 66, 69, 74, 76], "singl": [4, 6, 9, 36, 48, 62], "model": [4, 36], "simplifi": [4, 48], "v8runtim": [4, 6, 25, 26, 27, 29, 31, 36, 38, 39, 45, 47, 48, 49, 51, 52, 53, 54, 56, 59, 60, 63, 64, 65, 66, 69, 70, 71, 72], "resetisol": [4, 36, 52], "resetcontext": [4, 36, 39, 52], "alwai": [4, 27, 39, 48], "brand": 4, "new": [4, 6, 7, 9, 11, 26, 27, 29, 31, 35, 36, 37, 38, 44, 45, 47, 48, 49, 50, 60, 62, 63, 64, 65, 69, 70, 71, 72, 73], "much": [4, 6, 9, 31, 37, 39, 48, 60, 70, 72, 76], "cheaper": 4, "oper": [4, 28], "good": [4, 25, 37, 69], "enough": [4, 27, 31], "term": [4, 45, 48, 60], "almost": [4, 9, 31, 48, 62], "db": 4, "safe": [4, 24, 28, 36, 48], "NOT": [4, 36, 48], "lock": [4, 34, 37, 42, 45, 52, 76], "violat": 4, "core": [4, 35, 36, 38, 39, 53], "dump": [4, 36, 39, 53, 54], "immedi": [4, 16, 21, 36, 37, 39, 45], "valid": [4, 37, 48], "minim": [4, 29, 39, 65], "overhead": [4, 6, 12, 28, 29, 36, 37, 45, 65], "behind": [4, 6, 11, 12, 24, 64], "scene": [4, 12, 24, 64], "sampl": [4, 27, 31, 35, 37, 38, 48, 62], "function": [4, 14, 16, 29, 35, 37, 38, 46, 51, 54, 55, 56, 60, 62, 63, 69, 76], "packag": [4, 6, 8, 9], "automat": [4, 7, 28, 31, 35, 36, 38, 42, 57, 66, 69, 76], "per": [4, 31, 35, 36, 37, 38], "calcul": [4, 48], "unpack": 4, "system_temporary_directori": 4, "pid": 4, "either": [4, 6, 7, 48], "deploi": [4, 53], "avoid": [4, 12, 21, 28, 35, 39], "race": [4, 36], "condit": [4, 29, 36], "initi": [4, 6, 19, 23, 38, 55, 62, 65, 69], "purg": [4, 62], "legaci": [4, 9, 18, 19, 55], "least": [4, 9], "begin": 4, "nativ": [4, 20, 25, 26, 29, 36, 37, 39, 48, 51, 62, 76], "track": [4, 37, 58], "delet": [4, 26, 31, 47, 48, 63, 69], "javetnativemonitor": 4, "unit": [4, 15], "case": [4, 6, 7, 9, 15, 28, 30, 35, 36, 37, 38, 48, 49, 51, 76], "fetch": [4, 6, 49], "compar": [4, 7, 36], "count": [4, 42, 45, 47, 62], "verifi": [4, 38, 48], "unmanag": [4, 37], "properli": 4, "alloc": [4, 36, 48, 54], "freed": 4, "intellij": [5, 9], "flag": [5, 37, 53, 55], "design": [5, 7, 15, 16, 25, 29, 31, 35, 36, 38, 48, 62, 71, 76], "architectur": [5, 9], "modul": [5, 20, 24, 39, 41, 42, 48, 56, 57, 72], "engin": [5, 25, 26, 37, 38, 42, 54, 67, 73, 74], "pool": [5, 25, 37, 44, 51, 54, 67, 73, 74], "cross": [5, 76], "memori": [5, 9, 11, 15, 24, 28, 34, 35, 39, 42, 48, 52, 54, 60, 76], "leak": [5, 9, 11, 28, 37, 39, 52, 54], "detect": [5, 27, 28, 42, 48, 53, 54], "wasm": 5, "benchmark": 5, "improv": [5, 9, 36, 37, 54, 58], "cdt": [5, 70], "shell": [5, 67, 74], "intern": [5, 31, 35, 36, 37, 48, 54, 55, 58, 68], "reset": [6, 39], "i7": [6, 9], "10700k": [6, 9], "window": [6, 11, 12, 20, 25, 51, 60, 76], "type": [6, 12, 26, 27, 28, 29, 31, 35, 36, 37, 38, 42, 51, 52, 54, 55, 60], "tp": [6, 9], "751": 6, "032": 6, "ad": [6, 9, 31, 36, 51, 52, 53, 54, 55, 56, 57, 58, 59], "hoc": [6, 9, 36, 53], "65": 6, "410": 6, "143": 6, "363": 6, "isol": [6, 12, 36, 37, 38, 39, 76], "51": 6, "263": [6, 37], "647": 6, "458": 6, "846": 6, "968": 6, "253": 6, "508": 6, "748": 6, "660": 6, "slightli": 6, "mainli": 6, "older": 6, "than": [6, 11, 28, 45, 48, 72, 76], "dramat": [6, 48], "outperform": 6, "huge": [6, 21, 68], "serious": [6, 9], "slow": [6, 29], "down": [6, 76], "creation": [6, 37, 65], "unless": [6, 37, 39, 76], "particular": [6, 9, 35, 38], "linux": [6, 11, 18, 19, 25, 51, 52, 53, 55, 57, 59, 76], "addit": [6, 17, 29, 36, 48, 68, 76], "emb": 6, "bind": [6, 31, 38, 49, 52, 64, 69, 76], "webassembli": 6, "concern": 6, "program": 6, "languag": [6, 37, 48], "gener": [6, 27, 31, 37, 42, 48, 53, 60], "jul": 6, "13": [6, 54, 56, 57], "2023": [6, 56, 57, 58, 59], "binarytre": 6, "672": 6, "2048": 6, "305": 6, "edigit": 6, "814": 6, "484": 6, "59": 6, "fannkuch": 6, "redux": 6, "1660": 6, "4639": 6, "279": 6, "fasta": 6, "512": 6, "367": 6, "72": 6, "helloworld": 6, "mandelbrot": 6, "1411": 6, "1095": 6, "78": 6, "merkletre": 6, "1134": 6, "221": 6, "nbodi": 6, "546": 6, "472": 6, "86": 6, "nsiev": 6, "694": 6, "586": 6, "84": 6, "pidigit": 6, "4975": 6, "2761": 6, "55": 6, "spectral": 6, "norm": 6, "4198": 6, "4128": 6, "98": 6, "coro": 6, "prime": 6, "siev": 6, "796": 6, "105": [6, 42], "jit": 6, "optim": 6, "warm": 6, "could": [6, 9], "higher": 6, "And": [6, 9, 25, 62], "measur": [6, 60], "choos": [6, 24, 48], "technologi": 6, "accord": 6, "differ": [6, 9, 12, 29, 38, 39, 48, 49, 60], "signific": [6, 37], "algorithm": [6, 54], "awar": [6, 39], "drawback": [6, 60], "consider": [6, 17, 28, 45, 68], "written": [6, 28], "rust": 6, "21": [6, 36, 53, 59, 68], "kb": 6, "amount": [6, 21, 68, 76], "time": [6, 9, 16, 29, 31, 35, 38, 60, 65], "eventu": 6, "whole": [6, 31], "asynchron": 6, "mean": [6, 35, 38, 44, 48], "busi": [6, 54, 76], "logic": [6, 9, 28, 48, 49, 62, 76], "deal": [6, 27, 29, 37, 48], "promis": [6, 24, 39, 46, 62], "synchron": [6, 36, 76], "flexibl": [6, 38], "black": 6, "box": [6, 38], "impli": [6, 11, 16, 17, 24, 68, 76], "vulner": [6, 39], "among": [6, 36, 48, 58, 76], "major": [6, 38, 51, 76], "list": [6, 25, 28, 29, 31, 32, 48], "javetperf": [6, 58], "reus": [7, 12], "do": [7, 9, 12, 22, 24, 25, 36, 37, 38, 39, 48, 49, 64], "suit": 7, "timestamp": 7, "newer": 7, "instal": [8, 9, 17, 35, 38, 62, 67, 72, 74], "though": [8, 42, 48, 65, 76], "drop": [8, 9, 38, 48], "heavili": [8, 27, 48, 76], "person": 8, "idea": [8, 9, 11, 37], "For": [8, 12, 31, 38, 48], "now": [8, 9, 27, 31, 38, 44, 48, 69], "v7": 8, "kotlin": [8, 31, 36], "dsl": [8, 31], "construct": [8, 48, 53], "14": [8, 9, 54, 55, 56, 57, 58], "17": [8, 31, 53, 55, 58], "v3": [8, 38, 50], "bundl": 8, "hasn": [9, 24, 48], "activ": [9, 24, 35, 38, 68], "2017": 9, "last": 9, "wa": [9, 76], "2016": 9, "v4": 9, "fulli": [9, 27], "were": 9, "around": [9, 38], "android": [9, 25, 35, 55, 56, 57], "year": [9, 76], "nearli": 9, "seriou": [9, 11], "fix": [9, 11, 20, 26, 37, 38, 50, 52, 53, 54, 55, 56, 57, 58, 59], "under": [9, 37, 39, 48], "Its": [9, 37, 76], "evolv": 9, "expect": [9, 37, 42, 48], "chanc": 9, "implement": [9, 25, 29, 31, 35, 37, 38, 48, 49, 60, 68], "obvious": [9, 38, 48, 60], "couldn": [9, 76], "easili": [9, 28, 37, 45, 73], "would": [9, 11, 16], "contribut": 9, "me": [9, 25], "had": [9, 11], "admit": 9, "think": [9, 11, 13, 15, 16, 19], "mere": 9, "meanwhil": [9, 62], "ecmascript": 9, "move": [9, 52, 53], "forward": [9, 38], "rapidli": 9, "caus": [9, 20, 21, 35, 45, 48, 54, 76], "unexpect": [9, 28, 48], "someon": [9, 38], "team": 9, "realiti": 9, "cruel": 9, "unoffici": 9, "v6": 9, "110": 9, "2020": [9, 11], "temporarili": 9, "ve": [9, 11], "j2v8_win32_x86_64": 9, "machin": 9, "cpu": [9, 25, 60], "session": 9, "003": 9, "009": 9, "338": 9, "688": 9, "35": 9, "299": 9, "274": 9, "019": 9, "571": 9, "428": 9, "With": [9, 12, 38, 60], "stick": 9, "devic": [9, 25], "precis": [9, 28, 48], "mini": 9, "macbook": 9, "air": 9, "too": [9, 16, 38], "plan": 9, "bui": 9, "futur": 9, "donat": [9, 25], "joke": 9, "intend": [9, 12], "tl": 9, "dr": 9, "rel": 9, "easi": [9, 12, 25, 27, 48, 51, 60, 65, 70], "master": [9, 49], "didn": 9, "well": [9, 24, 31, 37, 76], "213": 9, "solvabl": 9, "revisit": 9, "remov": [9, 52, 53, 54, 55], "earli": [9, 39], "haven": 9, "got": [9, 11], "reviv": 9, "v2": [9, 50, 68], "far": 9, "lowest": [9, 68], "my": [9, 25], "eclips": 9, "plai": [9, 36, 38, 49, 60, 62], "hei": 9, "satisfi": 9, "luck": 9, "understand": 9, "suffer": 9, "nowadai": 9, "2019": [9, 57], "cmakelist": 9, "txt": 9, "still": [9, 45, 48, 76], "2015": 9, "ag": 9, "surpris": 9, "deepli": 9, "gone": [9, 24], "step": [9, 12, 24, 26, 29, 31, 35, 37, 38, 48, 63, 66, 69, 70], "sit": 9, "watch": 9, "break": [9, 28, 38, 48, 49, 60, 70], "made": [9, 11], "full": [9, 39, 48], "thought": [9, 11], "month": [9, 11], "pai": [9, 76], "python2": 9, "form": [9, 48], "outer": 9, "layer": [9, 76], "who": [9, 38], "spend": 9, "preciou": 9, "wish": [9, 76], "hair": 9, "guido": 9, "van": 9, "rossum": 9, "am": [9, 31, 48], "problemat": 9, "At": [9, 11, 48], "hack": [9, 12, 24], "pom": [9, 55], "xml": [9, 55], "uncertainti": 9, "someth": [9, 48], "roi": 9, "suppos": [9, 30, 35, 49], "sai": [9, 27], "x": [9, 25, 26, 29, 31, 38, 48, 50, 64], "later": [9, 11, 38], "255": [9, 37, 51, 63], "permiss": 9, "realli": [9, 49], "local": [9, 27, 37, 48], "histori": [10, 11, 19, 76], "j2v8": [10, 11, 12, 19, 74, 75], "motiv": [10, 19, 76], "find": [11, 48], "compel": 11, "slowli": 11, "dy": 11, "sometim": [11, 26, 27, 28, 31, 37, 48, 49], "lower": 11, "cost": 11, "might": [11, 35], "learn": [11, 15], "lot": [11, 65], "manual": [11, 17], "end": [11, 31, 37, 39, 48, 66], "abl": [11, 12, 21, 24, 28, 38, 45, 48, 62, 76], "write": [11, 27, 28, 37, 76], "inde": [11, 39], "folk": [12, 38], "migrat": [12, 25, 74], "experienc": 12, "perspect": [12, 37], "noth": 12, "globalthi": [12, 38, 76], "mix": 12, "longer": [12, 28, 31, 37, 39, 76], "getglobalobject": [12, 26, 27, 29, 31, 38, 45, 48, 49, 60, 62, 63, 64, 65, 69, 72, 76], "top": [12, 38, 48, 76], "level": [12, 28, 36, 48], "globalobject": [12, 48], "invok": [12, 27, 52], "involv": 12, "common": [12, 17], "where": [12, 13, 19, 35, 38, 60, 76], "thing": [12, 28, 29, 37, 38], "offer": [12, 14, 37], "builder": 12, "check": [12, 36, 38, 48, 53, 76], "ast": [12, 25], "scope": [12, 16, 37, 56], "duplic": 12, "regist": [12, 24, 38, 39, 42, 48, 56, 58, 65, 69, 76], "decor": [12, 48, 53, 69, 76], "v8function": [12, 48, 49, 53, 54], "v8properti": [12, 48, 52, 53, 54, 76], "back": [12, 28, 31, 37, 38, 48, 50], "leakag": [12, 42], "lifecycl": [12, 37, 39, 48], "convers": [12, 26, 28, 56, 64], "handl": [12, 24, 27, 31, 36, 38, 49, 53, 55, 65], "everyth": 12, "goe": [12, 48], "smoothli": [12, 28], "experi": [12, 24, 31, 35, 38, 64, 65, 70], "littl": [12, 29], "bit": [12, 29, 37, 38], "spring": [12, 25, 51, 67, 74], "framework": [12, 73], "most": [12, 36, 38, 39, 48], "cover": [12, 27, 29, 37, 76], "express": [12, 31, 62, 68], "effect": [12, 35, 37, 38, 62], "basic": [14, 25, 30, 48, 65, 72, 74, 76], "absent": [14, 36, 48], "settimeout": [14, 62, 72, 76], "setinterv": [14, 62, 72], "javenod": [14, 15, 25, 49, 68, 72, 76], "extens": [14, 48, 65], "aim": [14, 72, 76], "simul": [14, 38, 48, 72, 76], "singleton": 16, "fine": [16, 25, 28], "noderuntim": [16, 38, 52, 55, 62, 66, 71], "But": [16, 35, 36, 37, 38, 48, 49, 73], "crash": [16, 19, 21, 23, 35, 36, 48, 54, 57], "serv": 16, "agent": 16, "check_eq": 16, "start_io_thread_async_initi": 16, "exchang": 16, "std": 16, "atomic_bool": 16, "flip": 16, "again": [16, 31, 35], "trigger": [16, 36, 37, 48], "workaround": [16, 38], "inevit": 16, "hacki": 16, "fundament": [16, 44, 73], "distribut": [17, 55, 68], "eg": 17, "18": [17, 54, 58, 68], "reli": [17, 37, 44, 60, 73], "advanc": [17, 25, 49, 74], "chain": [17, 37], "download": [17, 38], "drive": [17, 38], "prepar": [17, 35, 38, 48, 65], "sudo": [17, 38], "apt": [17, 38], "y": [17, 26, 29, 31, 64], "essenti": 17, "softwar": 17, "properti": [17, 28, 29, 31, 60, 68, 69, 73], "ppa": 17, "toolchain": 17, "altern": [17, 29], "90": 17, "slave": 17, "gcov": 17, "80": 17, "70": 17, "config": [17, 31, 44], "choic": [17, 25], "select": [17, 37, 48], "prioriti": [17, 54], "statu": [17, 45, 50], "effort": [17, 45, 68], "commit": [17, 68], "background": [19, 25, 49], "troubleshoot": [19, 25, 32], "dynam": [19, 23, 25, 35, 48, 52], "routin": [19, 23, 38], "being": [19, 23, 31, 37, 38, 45, 48], "failur": [20, 54], "happen": [20, 24, 28, 37, 49], "root": [20, 27, 37, 38], "napi": [20, 38], "symbol": [20, 26, 29, 38, 42, 53, 55, 58], "cannot": [20, 28, 36, 37, 38], "found": [20, 38, 42, 72], "modular": [20, 34, 39, 76], "By": [21, 35, 37, 69], "reduc": 21, "relat": [21, 48], "attempt": 21, "visit": [22, 25, 72], "user": [24, 28, 31, 38, 44, 65, 70, 73], "segfault": [24, 76], "occur": [24, 28, 31, 37], "82": 24, "loop": [24, 45, 49, 62, 70], "exit": [24, 70], "see": [24, 36, 38, 60, 71], "hand": 24, "yet": 24, "resolv": [24, 31, 38, 62, 76], "reject": [24, 39, 53], "land": 24, "lead": [24, 39], "corrupt": 24, "peopl": [24, 76], "mostli": 24, "genuin": 24, "prevent": [24, 35, 37, 39], "fact": [24, 49], "won": [24, 28, 35], "standard": [24, 57], "hit": [24, 45], "import": [24, 44, 45, 49, 68, 76], "explicitli": [24, 31, 35, 37, 39, 65], "forc": [24, 31, 39, 65], "garbag": [24, 35], "collect": [24, 26, 29, 35, 46, 51], "eight": 25, "awesom": [25, 71], "star": 25, "medium": 25, "blogspot": 25, "channel": 25, "discord": [25, 76], "retir": 25, "mail": 25, "great": 25, "thank": 25, "arm64": [25, 57, 59, 68], "v20": [25, 50, 59], "267": [25, 59], "prefer": 25, "polyfil": [25, 67, 74, 76], "exposur": [25, 51], "interop": [25, 61, 74], "bigint": [25, 30, 37, 51], "date": [25, 30, 38, 51], "analysi": [25, 38], "javetsanit": 25, "groupid": [25, 31, 68], "artifactid": [25, 31, 68], "v8host": [25, 27, 35, 37, 38, 45, 52, 53, 54, 60, 62, 66, 69, 70], "getnodeinst": [25, 27, 37, 62, 66, 71], "createv8runtim": [25, 27, 38, 45, 60, 62, 66, 69, 70, 71], "println": [25, 38, 60, 62, 63, 64, 66, 69, 70], "getexecutor": [25, 26, 27, 29, 31, 38, 45, 47, 48, 49, 60, 62, 63, 64, 65, 66, 69, 70, 72], "executestr": [25, 26, 29, 31, 38, 48, 63, 64, 66, 72], "getv8inst": [25, 37, 38, 45, 60, 66, 69, 70, 71], "hivemq": 25, "apach": 25, "graalj": [25, 31], "nashorn": 25, "elegantli": [25, 60], "jsonnod": [25, 61, 74], "compromis": 25, "typescript": 25, "intro": 25, "tutori": 25, "convert": [25, 32, 42, 48, 52, 54, 55, 60, 61, 63, 74, 76], "todo": [25, 32], "note": [25, 31, 37, 38, 48], "faq": 25, "javetproxyconvert": [26, 28, 53, 54, 60, 63, 76], "skip": [26, 28, 31, 53], "proxi": [26, 29, 54, 55, 60], "primit": [26, 27, 28, 29, 31, 39, 48, 51, 54, 55], "annoi": 26, "variabl": [26, 36, 38, 48, 54, 63, 64, 69], "accid": 26, "javetbridgeconvert": [26, 54], "ident": [26, 38, 48, 69], "setconvert": [26, 27, 31, 60, 63], "btrue": 26, "bfals": 26, "asserttru": [26, 31, 38, 45, 47, 48, 49], "executeobject": [26, 31, 63, 64], "assertfals": [26, 31, 38, 45, 47, 48], "assertequ": [26, 29, 31, 38, 45, 47, 48], "tov8valu": [26, 27, 60], "executeinteg": [26, 29, 31, 38, 45, 48, 66], "toprimit": 26, "12345": 26, "12346": 26, "intarrai": 26, "length": [26, 27, 29, 37], "assertarrayequ": [26, 31], "iter": [26, 58], "integerlist": 26, "arraylist": [26, 29, 64], "executevoid": [26, 27, 31, 38, 45, 48, 60, 62, 63, 64, 65, 69, 72], "longlist": 26, "unmodifiablelist": 26, "aslist": [26, 48], "1l": 26, "2l": 26, "stringifi": [26, 64], "implicit": [26, 76], "given": [26, 37], "give": [26, 28, 37, 45, 48], "ab": 26, "implicitli": [26, 54], "besid": [26, 48], "power": 27, "simpl": [27, 31, 35, 37, 38, 44, 48, 60, 62, 71], "about": [27, 36], "reflect": [27, 29, 31, 39, 48, 58], "tweak": 27, "pair": [27, 48], "public": [27, 29, 31, 35, 44, 48, 49, 55, 60, 62, 69, 72, 73], "class": [27, 29, 38, 44, 48, 60, 62, 69, 73], "null": [27, 29, 31, 38, 48, 49, 62, 69, 70], "getnam": [27, 29, 69, 73], "return": [27, 28, 29, 31, 35, 37, 38, 39, 45, 48, 49, 52, 60, 62, 63, 64, 69, 73], "void": [27, 29, 31, 44, 48, 49, 60, 62, 69, 72], "setnam": [27, 29, 69], "getvalu": [27, 29, 47, 48, 60, 69], "setvalu": [27, 29, 48, 69], "Then": 27, "recurs": [27, 28, 53], "parent": [27, 39], "overrid": [27, 31, 35, 44, 48, 49, 60], "depth": [27, 28, 42, 53], "argument": [27, 29, 76], "circular": [27, 42, 53], "structur": [27, 42, 53, 60], "increment": [27, 60], "suppresswarn": 27, "uncheck": 27, "extend": [27, 31, 38, 48], "javetobjectconvert": [27, 28, 29, 53, 76], "method_prefix_get": 27, "method_prefix_i": 27, "protect": [27, 36, 44, 45, 73], "excluded_method": 27, "hashset": [27, 29, 48], "getmethod": [27, 48], "getparametercount": 27, "methodnam": [27, 42, 48], "startswith": 27, "v8valu": [27, 28, 49, 52, 53, 55, 60, 64, 70, 76], "int": [27, 29, 30, 31, 45, 48, 60, 62, 69], "throw": [27, 28, 31, 38, 45, 48, 49, 60, 62, 72], "javetexcept": [27, 48, 49, 60, 62, 72], "super": [27, 60], "isundefin": 27, "objectclass": 27, "getclass": 27, "v8valueobject": [27, 31, 37, 38, 48, 53, 55, 69, 72, 76], "createv8valueobject": [27, 37, 38, 48, 69], "canaccess": 27, "propertynam": 27, "contain": [27, 38, 39, 48], "substr": 27, "tolowercas": 27, "els": [27, 38, 48, 49, 60, 62, 68, 72, 76], "v8valuetemp": 27, "catch": [27, 45, 48, 49, 62, 70], "except": [27, 31, 36, 37, 38, 39, 44, 45, 48, 52, 54, 55, 60, 76], "printstacktrac": [27, 45, 62], "line": [27, 36, 48, 70], "testpojo": 27, "pojoarrai": 27, "tom": 27, "ceo": 27, "jerri": 27, "cfo": 27, "log": [27, 37, 39, 43, 48, 49, 62, 65, 69], "transpar": [27, 31, 48, 76], "autom": [27, 37], "bridg": [28, 54], "arrai": [28, 29, 31, 37, 47, 48, 51], "meet": [28, 38], "famou": 28, "topic": [28, 49], "lang": [28, 35], "nullpointerexcept": 28, "luckili": [28, 38], "inject": [28, 31, 35, 42, 48, 49, 53, 60, 76], "javetconverterconfig": [28, 53], "overridden": [28, 35], "differenti": 28, "introduc": [28, 37, 54, 76], "ijavetentityfunct": [28, 29], "ijavetentitymap": [28, 29], "setskipfunctioninobject": 28, "boolean": [28, 29, 30, 35], "setextractfunctionsourcecod": 28, "opportun": 28, "extract": 28, "ineffici": 28, "inconveni": [28, 35], "substanti": 28, "instead": [28, 36, 37, 38, 52, 57, 64, 76], "javetconverterexcept": 28, "maximum": 28, "reach": [28, 42], "cheap": 28, "unrealist": 28, "number": [28, 30, 37, 38], "stackoverflowerror": 28, "wors": 28, "block": [28, 36, 37, 48, 66], "stack": [28, 48], "overflow": 28, "attack": [28, 45], "drain": [28, 37], "tini": 28, "behavior": [28, 31, 37, 39, 48], "fanci": 28, "read": [28, 37, 42, 49], "setproxymapen": [28, 31], "wherea": [28, 37], "conveni": 28, "bi": [28, 64], "direction": [28, 64], "grain": 28, "worri": [28, 35, 38, 45, 62], "vice": 28, "versa": 28, "open": [29, 31, 39], "subclass": [29, 31, 39, 49], "int8arrai": [29, 37], "char": [29, 30, 48], "doubl": [29, 30, 37, 48], "float64arrai": [29, 37], "float": [29, 30, 37, 48], "float32arrai": [29, 37], "int32arrai": [29, 37], "int64arrai": 29, "short": [29, 30, 37, 48], "int16arrai": [29, 37], "stream": [29, 48, 53, 55], "javetentitysymbol": 29, "ijavetmapp": [29, 53], "hashmap": [29, 31, 64], "uint8arrai": [29, 37], "uint8clampedarrai": [29, 37], "uint16arrai": [29, 37], "uint32arrai": [29, 37], "bigint32arrai": 29, "bigint64arrai": [29, 37], "pojo": 29, "registercustomobject": [29, 53], "alien": 29, "match": [29, 31, 38, 63], "constructor": [29, 31, 54, 72], "signatur": [29, 42, 48], "frommap": 29, "tomap": 29, "touchabl": 29, "easier": 29, "customobject": 29, "integ": [29, 30, 31, 37, 47, 48, 62], "put": [29, 31, 39, 60, 64], "getter": [29, 31, 48, 53, 54, 69, 76], "setter": [29, 31, 48, 53, 69, 76], "snippet": [29, 37, 38], "below": [29, 48], "getconvert": 29, "ones": 29, "upon": 29, "registr": [29, 42, 76], "customfrommap": 29, "customtomap": 29, "regular": [29, 36], "v8customobject": 29, "getobject": [29, 31], "assertnotnul": [29, 31, 47], "pro": 29, "con": 29, "intrus": [29, 60], "carri": [29, 76], "inform": 29, "memor": 29, "complic": [29, 38], "relationship": 29, "javetprimitiveconvert": [30, 53, 55], "charact": 30, "biginteg": 30, "zoneddatetim": [30, 55, 56], "optionalint": 30, "optionaldoubl": 30, "optionallong": 30, "fall": 30, "rang": [30, 37], "danger": 31, "touch": [31, 36], "tmp": 31, "executeboolean": 31, "isfil": 31, "isdirectori": 31, "canread": [31, 72], "canwrit": 31, "canexecut": 31, "lowmemorynotif": [31, 48, 49, 52, 60, 65, 69, 76], "getconfig": [31, 38, 71], "z": 31, "topath": 31, "tostr": [31, 38, 47, 48, 60, 63, 70, 72], "newpath": 31, "toobject": 31, "abc": [31, 35, 48, 63], "def": [31, 48, 62], "n": [31, 38, 48, 63], "d": [31, 38, 63], "instanceof": [31, 48, 49, 60], "matcher": [31, 63], "123": [31, 48, 63, 69, 72], "a123": 31, "smart": [31, 37], "javeterrortyp": 31, "assertthrow": 31, "javetexecutionexcept": [31, 38, 54], "field": 31, "should": [31, 45], "writabl": 31, "annot": [31, 48, 53], "autoclos": 31, "ijavetclos": [31, 53], "isassignablefrom": 31, "special": [31, 38, 48], "known": [31, 37], "lambda": [31, 48], "istringjoin": 31, "join": 31, "two": [31, 37], "stringjoin": 31, "hold": [31, 37, 49], "joiner": 31, "getjoin": 31, "setjoin": 31, "v8valuefunct": [31, 38, 48, 52, 53, 62, 72], "orphan": 31, "callabl": 31, "outofmemoryerror": 31, "similar": [31, 39, 65], "enhanc": [31, 48, 52, 53, 54, 55, 58], "istringutil": 31, "hello": [31, 62, 63, 65, 67, 74], "split": 31, "stringutil": 31, "util": 31, "getutil": 31, "setutil": 31, "str": [31, 48], "toarrai": [31, 64], "aussi": 31, "non": [31, 39, 48], "bytebuddi": [31, 56], "alreadi": [31, 42, 49], "referenc": [31, 37, 38], "buddi": 31, "12": [31, 54, 56, 57, 58], "groovi": 31, "javetreflectionobjectfactori": 31, "stai": [31, 35, 62, 76], "dynamicclass": 31, "ijavetanonym": [31, 48, 53], "setreflectionobjectfactori": 31, "getinst": [31, 35], "codestr": [31, 38, 51], "smartli": 31, "overload": 31, "vararg": [31, 48, 52, 55], "identifi": 31, "alter": 31, "v8allow": [31, 54], "v8block": [31, 54], "ignor": [31, 37, 48, 52], "v8getter": [31, 54], "v8setter": [31, 54], "treat": [31, 35, 37], "allowonli": 31, "blockonli": 31, "alia": 31, "virtual": [31, 38, 55], "document": [35, 48, 53], "assum": [35, 38, 48], "reload": 35, "setlibraryreload": 35, "jsruntimetyp": [35, 38, 71, 73], "unloadlibrari": [35, 53], "restor": [35, 48], "gc": [35, 60, 65, 69], "prior": 35, "loadlibrari": [35, 53], "unstabl": 35, "risk": [35, 39], "temp": 35, "javetlibload": 35, "setlibloadinglisten": 35, "ijavetlibloadinglisten": [35, 54], "getlibpath": 35, "anywher": 35, "bypass": [35, 48], "isdeploi": 35, "must": [35, 48, 72], "less": 35, "islibinsystempath": 35, "mavin": 35, "plug": 35, "osgi": 35, "repeatedli": 35, "regardless": [35, 36, 39], "unsatisfiedlinkerror": 35, "issuppressingerror": [35, 54], "javetlibloadinglisten": [35, 54], "mechan": [35, 36, 76], "djavet": 35, "unlock": [36, 60], "surround": 36, "v8locker": [36, 39, 51], "locker": 36, "getv8lock": 36, "nest": 36, "thrown": [36, 37, 39, 45, 48], "report": 36, "conflict": [36, 42], "slight": 36, "sensit": [36, 37, 39, 51, 76], "extrem": [36, 48], "50": 36, "granular": [36, 38], "concurr": 36, "scenario": [36, 37, 39, 51, 76], "maxim": [36, 39], "incompat": 36, "chao": 36, "sequenc": 36, "newglobalref": 37, "javaobject": [37, 76], "until": 37, "deleteglobalref": 37, "across": 37, "raw": 37, "categor": 37, "within": 37, "persist": 37, "aw": 37, "borrow": [37, 48], "rule": [37, 48], "wrap": 37, "outsid": 37, "setweak": [37, 39], "determin": [37, 48, 53], "javetstandardconsoleinterceptor": [37, 65, 69], "v8scope": [37, 39, 53], "setescap": 37, "getv8scop": 37, "binari": [37, 42, 57], "often": 37, "manipul": [37, 47], "content": [37, 49, 59], "dataview": 37, "specif": [37, 49], "format": [37, 42, 48], "nio": 37, "bytebuff": [37, 55], "consid": [37, 48, 60], "idl": 37, "equival": [37, 48], "128": 37, "complement": 37, "sign": 37, "int8_t": 37, "unsign": 37, "octet": 37, "uint8_t": 37, "clamp": 37, "32768": 37, "32767": 37, "int16_t": 37, "65535": 37, "uint16_t": 37, "2147483648": 37, "2147483647": 37, "int32_t": 37, "4294967295": 37, "uint32_t": 37, "38": 37, "1038": 37, "ieee": 37, "point": [37, 38], "digit": 37, "234567": 37, "unrestrict": 37, "324": 37, "10308": 37, "64": [37, 53], "23456789012345": 37, "int64_t": 37, "biguint64arrai": 37, "264": 37, "uint64_t": 37, "testv8valuetypedarrai": 37, "testv8valuedataview": 37, "frequenc": 37, "area": 37, "pace": 37, "zombi": 37, "cycl": 37, "notifi": [37, 60, 69], "space": 37, "v8notifi": 37, "setmemoryusagethresholdratio": [37, 52], "threshold": 37, "ratio": 37, "enablegcnotif": [37, 52], "ration": 37, "xms64m": 37, "xmx64m": 37, "pressur": [37, 76], "destroi": 37, "curv": 37, "smoother": 37, "exce": 37, "broadcast": 37, "schedul": [37, 54], "affect": 37, "worker": 37, "javetengineconfig": [37, 44, 52, 55, 73], "setautosendgcnotif": [37, 73], "light": 37, "weight": 37, "hint": [37, 48], "task": [37, 49, 52], "queue": [37, 49], "decis": 37, "millisecond": [37, 45, 62], "disregard": 37, "aforement": 37, "analyz": [37, 38], "getv8heapspacestatist": [37, 54], "getv8heapstatist": [37, 54], "getv8sharedmemorystatist": [37, 54], "javetenginepool": [38, 44, 52, 54, 65, 71, 73], "setjsruntimetyp": [38, 71, 73], "ijavetengin": [38, 45, 65, 71, 72], "getengin": [38, 45, 65, 71], "getv8runtim": [38, 45, 60, 65, 72], "workingdirectori": 38, "javetosutil": [38, 62, 72], "working_directori": [38, 62, 72], "node_modul": [38, 39, 62, 72], "getnodemodul": 38, "nodemodulemodul": 38, "setrequirerootdirectori": 38, "getlogg": [38, 44, 72], "loginfo": [38, 72], "23": [38, 52, 55, 56, 58, 68, 72], "34": [38, 72], "const": [38, 47, 48, 60, 62, 63, 64, 72], "decim": 38, "__dirnam": 38, "__filenam": 38, "scriptfil": 38, "scriptpath": 38, "scriptstr": 38, "iv8executor": [38, 56], "setresourcenam": 38, "resourcenam": 38, "setmodul": 38, "excit": 38, "potenti": [38, 53, 54], "piec": 38, "sqlite3": 38, "bother": 38, "electron": 38, "approach": [38, 48], "simpler": 38, "node_sqlite3": 38, "napi_create_error": 38, "patchelf": 38, "npm": [38, 62, 72], "node_module_fil": 38, "loadlibraryexw": 38, "unzip": 38, "somewher": 38, "replac": [38, 60], "voluntarili": 38, "compat": [38, 54], "go": [38, 50], "through": [38, 48], "pretti": 38, "backup": 38, "rebuilt": [38, 52], "dumpbin": 38, "win32": 38, "delai": 38, "ex": 38, "00000001": 38, "characterist": 38, "0000000180154a40": 38, "hmodul": 38, "0000000180154818": 38, "tabl": [38, 57], "000000018014f248": 38, "000000018014fa68": 38, "bound": 38, "0000000000000000": 38, "stamp": 38, "0000000180108724": 38, "424b": 38, "napi_create_funct": 38, "0000000180108ab5": 38, "4243": 38, "napi_create_buffer_copi": 38, "1801363d8": 38, "180166610": 38, "index": 38, "6096": 38, "napi_open_escapable_handle_scop": 38, "6072": 38, "napi_get_undefin": 38, "apart": 38, "swc": 38, "gyp": 38, "ppee": 38, "puppi": 38, "profession": 38, "pe": 38, "explor": 38, "cli": 38, "drag": 38, "directory_entry_delay_import": 38, "save": [38, 62], "resolut": [38, 58], "embedd": 38, "relai": [38, 54], "reachabl": 38, "javetbuiltinmoduleresolv": [38, 59], "setv8moduleresolv": 38, "existssync": 38, "getboolean": 38, "capabl": [38, 48, 60], "gain": 38, "order": [38, 47], "launch": [38, 39], "testfrommodul": 38, "assign": [38, 48, 53, 63], "v8modul": [38, 52, 56, 59], "compilemodul": 38, "containsmodul": 38, "getinteg": [38, 45], "heavi": 38, "v8modulereferr": 38, "equal": [38, 48, 51, 64, 70, 72], "compilev8modul": [38, 76], "cach": [38, 51, 55, 56], "propos": 38, "advantag": 38, "tradit": 38, "record": 38, "createv8valuefunct": [38, 48], "createv8modul": [38, 59], "issourcetextmodul": [38, 59], "issyntheticmodul": [38, 59], "invokeinteg": 38, "obtain": 39, "pass": [39, 53], "dangl": [39, 57], "ey": 39, "stage": 39, "prohibit": 39, "uncertain": 39, "acquir": [39, 42, 76], "malici": [39, 45], "eval": [39, 48], "impact": [39, 48], "unhandl": 39, "whose": 39, "period": 41, "style": 41, "statist": [41, 54], "101": 42, "osnotsupport": 42, "102": 42, "librarynotfound": 42, "103": 42, "librarynotload": 42, "104": 42, "notsupport": 42, "failedtoreadpath": 42, "201": 42, "compilationfailur": 42, "301": 42, "executionfailur": 42, "302": 42, "executiontermin": 42, "termin": [42, 43], "continu": 42, "401": 42, "callbacksignatureparametersizemismatch": 42, "mismatch": 42, "paramet": [42, 48], "expectedparameters": 42, "actualparameters": 42, "402": 42, "callbacksignatureparametertypemismatch": 42, "expectedparametertyp": 42, "actualparametertyp": 42, "403": 42, "callbackinjectionfailur": 42, "404": 42, "callbackregistrationfailur": 42, "405": 42, "callbackmethodfailur": 42, "406": 42, "callbackunknownfailur": 42, "unknown": 42, "407": [42, 53], "callbackunregistrationfailur": 42, "unregistr": 42, "408": [42, 58], "callbacktypenotsupport": [42, 58], "callbacktyp": 42, "501": 42, "converterfailur": 42, "502": 42, "convertercircularstructur": 42, "max": 42, "503": [42, 53], "convertersymbolnotbuiltin": 42, "601": 42, "modulenameempti": 42, "empti": 42, "602": [42, 53], "modulenotfound": 42, "modulenam": 42, "603": [42, 53], "modulepermissiondeni": 42, "deni": 42, "701": 42, "lockacquisitionfailur": 42, "702": 42, "lockreleasefailur": 42, "703": 42, "lockconflictthreadidmismatch": 42, "lockedthreadid": 42, "currentthreadid": 42, "801": 42, "runtimealreadyclos": 42, "802": 42, "runtimealreadyregist": 42, "803": 42, "runtimenotregist": 42, "804": 42, "runtimeleakagedetect": 42, "805": [42, 53], "runtimeclosefailur": 42, "806": [42, 54], "runtimeoutofmemori": 42, "heapstatist": 42, "901": [42, 55], "enginenotavail": [42, 55], "hell": [44, 73], "3rd": [44, 48], "parti": [44, 48], "interfac": [44, 49, 76], "slf4j": 44, "org": [44, 68], "loggerfactori": 44, "myjavetlogg": [44, 73], "isdebugen": 44, "throwabl": [44, 70], "info": [44, 56], "isinfoen": 44, "iswarnen": 44, "javetlogg": 44, "testlogg": 44, "setjavetlogg": [44, 73], "ijavetengineguard": [45, 51], "ijavetenginepool": [45, 65, 73], "guard": 45, "getguard": 45, "10000": 45, "infinit": [45, 70], "javetterminatedexcept": 45, "mark": 45, "iscontinu": 45, "dead": 45, "afterward": [45, 49], "hang": 45, "till": 45, "timeout": [45, 49], "cancel": 45, "monitor": 45, "daemonthread": 45, "isinus": [45, 51], "timeunit": [45, 62], "sleep": [45, 62], "interruptedexcept": [45, 62], "terminateexecut": [45, 51, 76], "var": [45, 48, 62], "greater": 45, "javetengineguard": [45, 52], "interrupt": 45, "disableindebugmod": [45, 52], "enableindebugmod": [45, 52], "getlength": 47, "getsiz": 47, "getkei": 47, "getownpropertynam": 47, "getentri": 47, "foreach": [47, 51, 58], "consum": 47, "biconsum": 47, "weakmap": 47, "weakset": 47, "atomicinteg": 47, "v8valueinteg": [47, 48, 60], "getandincr": 47, "popinteg": 47, "preserv": 47, "v8valuestr": [47, 60], "getjsfunctiontyp": [48, 52], "invis": 48, "stori": 48, "closur": 48, "goal": 48, "iv8valueobject": [48, 51, 52, 53, 56, 58], "caller": [48, 49], "scan": 48, "input": [48, 60, 64, 70], "receiv": [48, 49, 53, 60], "functioncallbackreceiv": 48, "tricki": 48, "charm": 48, "generatearraywithconvert": 48, "intrud": 48, "untouch": 48, "situat": 48, "v8runtimesett": 48, "generatearraywithoutconvert": 48, "declar": [48, 73, 76], "annotationbasedcallbackreceiv": 48, "stringvalu": 48, "getstringvalu": 48, "setstringvalu": 48, "echo": 48, "mathadd": 48, "recogn": [48, 60], "v8valuearrai": 48, "createv8valuearrai": 48, "staticecho": 48, "setv8runtim": 48, "tojsonstr": 48, "testopt": 48, "optionalstr": 48, "teststream": 48, "filter": 48, "thisobjectrequir": [48, 53], "specifi": [48, 76], "thisobject": 48, "bodi": [48, 60, 62], "especi": [48, 65, 76], "simpli": [48, 60], "symboltyp": 48, "v8valuesymboltyp": 48, "v8bindingenabl": [48, 53], "disabledfunct": 48, "disabledproperti": 48, "isv8bindingen": 48, "arbitrarymethod": 48, "whether": [48, 53], "refactor": [48, 52, 53, 54, 55], "friendli": [48, 76], "javetreflectionutil": [48, 53], "getmethodnamefromlambda": [48, 53], "getmethodnamesetfromlambda": [48, 53], "firstli": 48, "disabledfunctionset": 48, "supplier": 48, "serializ": 48, "secondli": 48, "est": 48, "tr\u00e8": 48, "bien": 48, "unbind": [48, 53, 76], "unbindproperti": [48, 53, 58], "unbindfunct": [48, 53, 58], "ijavetanonymous1": 48, "testfunct": 48, "testproperti": 48, "ijavetanonymous2": 48, "javetentityfunct": [48, 53], "jsfunctiontyp": 48, "userdefin": 48, "semi": 48, "mockcallbackreceiv": 48, "blank": 48, "iscal": 48, "happi": 48, "mirror": 48, "anonym": 48, "getsourcecod": [48, 52], "setsourcecod": [48, 52], "sourcecod": 48, "existingsourcecod": 48, "startposit": 48, "endposit": 48, "getposit": 48, "newsourcecod": 48, "setposit": 48, "len": 48, "radic": 48, "rough": 48, "layout": 48, "remain": 48, "accordingli": 48, "invoc": 48, "pseudo": [48, 49, 62], "originalsourcecod": 48, "getjsscopetyp": 48, "isclass": 48, "indic": 48, "callvoid": [48, 62], "isfunct": 48, "incorrect": 48, "malform": 48, "technic": [48, 71], "keyword": 48, "discard": 48, "createv8valuestr": [48, 52], "toclon": [48, 56], "abov": 48, "intvalu": 48, "valueof": 48, "createv8valueinteg": [48, 60], "safeti": 48, "sentenc": [48, 76], "belong": 48, "prototyp": 48, "combin": 48, "func": 48, "callobject": 48, "callprimit": 48, "callasconstructor": [48, 51, 72], "itself": 48, "invokevoid": [48, 60], "invokeobject": [48, 63], "invokeprimit": 48, "despit": 48, "deficit": 48, "quot": 48, "getcontext": [48, 54], "setcontext": 48, "copyscopeinfofrom": [48, 56], "anoth": [48, 72], "setscriptsourc": [48, 56], "lexic": 48, "jsfunction": 48, "ecma": 48, "262": 48, "speak": 48, "parallel": 48, "slot": 48, "scope_info": 48, "describ": 48, "lookup": 48, "presenc": 48, "previou": 48, "scopeinfo": [48, 56], "hascontextextensionslot": 48, "search": 48, "purpos": 48, "henc": 48, "sloppi": 48, "inner": [48, 54], "fast": 48, "harmoni": 48, "scriptcontext": 48, "rather": 48, "functioncontext": 48, "gather": 48, "scriptcontextt": 48, "toler": 48, "natur": [48, 49], "strongli": [48, 60], "conform": 48, "throughout": 48, "samplewithoutthi": 48, "samplewiththi": 48, "excess": 48, "behav": 48, "redund": 48, "fill": 48, "review": [48, 49], "due": 49, "multi": [49, 65, 76], "friend": 49, "iv8valuepromis": [49, 56], "ownership": 49, "chart": 49, "v8valuepromis": [49, 52, 53], "icallback": 49, "oncatch": 49, "v8valueerror": 49, "onfulfil": 49, "fulfil": 49, "onreject": 49, "manner": [49, 76], "filecont": 49, "filepath": 49, "v8valuepromiseresolv": 49, "createv8valuepromis": 49, "getpromis": 49, "getfilecont": 49, "getfilepath": 49, "createv8valueundefin": 49, "print": [49, 64, 70], "rais": 49, "setpromiserejectcallback": 49, "ijavetpromiserejectcallback": 49, "unhandledreject": 49, "handi": 49, "mainstream": 50, "v11": [50, 68], "mainten": [50, 53], "v18": [50, 57, 58], "v10": [50, 59], "v16": [50, 55], "v9": [50, 68], "v0": [50, 51, 52, 53, 76], "v14": [50, 52, 53], "critic": 50, "bug": [50, 52, 54, 55, 56, 57, 58, 76], "patch": 50, "deprec": [51, 52], "v8valueweakmap": 51, "v8valueweakset": 51, "setfunct": [51, 52], "functionnam": 51, "strictequ": 51, "samevalu": 51, "iv8valu": [51, 52, 56], "getidentityhash": 51, "iv8valuerefer": 51, "isdead": 51, "view": 51, "2021": [51, 52, 53, 54, 76], "02": [51, 52, 55, 56], "renam": [52, 53, 56, 58], "ijavetconsum": 52, "ijavetuniconsum": 52, "ijavetuniindexedconsum": 52, "ijavetbiindexedconsum": 52, "v8functioncallback": [52, 58], "bindfunct": [52, 58], "bindproperti": [52, 58], "checkreturnvalu": 52, "re": [52, 62], "organ": 52, "iv8valuefunct": [52, 53, 56], "emit": 52, "univers": 52, "createv8valuedoubl": 52, "createv8valuezoneddatetim": 52, "javeterror": [52, 55], "gcbeforeengineclos": 52, "javetcallbackexcept": 52, "isnullorundefin": 52, "06": [52, 53, 55, 58], "257": 52, "idlenotificationdeadlin": 52, "disablegcnotif": 52, "autosendgcnotif": 52, "javetcallbackcontext": [52, 58], "javetpromiserejectcallback": 52, "allowev": 52, "v8script": [52, 56], "v8bindenabl": 53, "v8virtualescapablevalu": 53, "146": [53, 54], "09": [53, 54, 56, 58, 59], "hasinternaltyp": 53, "isgeneratorobject": 53, "isgeneratorfunct": 53, "isasyncfunct": 53, "v8flag": 53, "v8valuesharedarraybuff": 53, "unregistercustomobject": 53, "javadoc": 53, "08": [53, 55, 58], "31": 53, "345": 53, "v8valuebuiltinsymbol": 53, "getownpropertysymbol": 53, "v8valuebuiltinobject": [53, 59], "createv8valuesymbol": 53, "javetvirtualobject": 53, "javetuniversalproxyhandl": 53, "isclos": 53, "07": [53, 55, 57, 58], "29": 53, "staticclassen": 53, "ownkei": 53, "iv8valueproxi": 53, "v8valueproxi": 53, "gettarget": 53, "gethandl": 53, "isrevok": 53, "revok": 53, "createv8valueproxi": 53, "230": 53, "19": [53, 54], "getprototyp": 53, "setprototyp": 53, "01": [53, 54, 55, 56], "iv8moduleresolv": 53, "nodemoduleprocess": 53, "getvers": 53, "15": [53, 55, 56, 57, 59], "05": [53, 55, 58], "269": 53, "28": [53, 56, 59], "106": 54, "javetcompilationexcept": 54, "convent": 54, "agnost": 54, "getdetailedmessag": 54, "getstack": 54, "javetscriptingerror": 54, "adjust": 54, "capac": 54, "observ": 54, "v8runtimeobserveraveragecallbackcontextcount": 54, "v8runtimeobserveraveragereferencecount": 54, "v8runtimeobserveraveragev8modulecount": 54, "v8convert": 54, "26": [54, 55], "180": 54, "javetoutofmemoryexcept": 54, "awai": 54, "haspendingexcept": 54, "haspendingmessag": 54, "hasscheduledexcept": 54, "promotescheduledexcept": 54, "reportpendingmessag": 54, "addgcepiloguecallback": 54, "addgcprologuecallback": 54, "removegcepiloguecallback": 54, "removegcprologuecallback": 54, "172": [54, 59], "v8intern": 54, "clean": 54, "methodhandl": 54, "cast": 54, "mistakenli": 54, "v8runtimeopt": 54, "noderuntimeopt": 54, "218": 55, "handler": [55, 62], "132": 55, "improp": 55, "waitforenginemaxretrycount": 55, "174": 55, "pend": [55, 62], "andoird": 55, "v8valuebiginteg": 55, "154": 55, "ispurgeeventloopbeforeclos": 55, "setpurgeeventloopbeforeclos": [55, 62], "124": [55, 69], "03": [55, 56, 57], "139": 55, "115": 55, "createv8valuearraybuff": 55, "177": 55, "r23b": 55, "abi": [55, 57, 68], "libgcc": 55, "libstdc": 55, "cento": 55, "226": 56, "verifynostrongbaseobject": 56, "ilisten": 56, "v8awaitmod": 56, "194": 56, "compilev8valuefunct": 56, "getcacheddata": 56, "iswrap": 56, "getargu": 56, "cacheddata": 56, "v8stringexecutor": 56, "168": 56, "revis": 56, "getscopeinfo": 56, "getownpropertynamestr": 56, "referencecopi": 56, "193": 56, "javetuniversalproxi": 56, "javetdynamicproxi": [56, 58], "javetdynamicobjectfactori": 56, "copycontextfrom": 56, "getscriptsourc": 56, "setsourcecodeopt": 56, "iscompil": 56, "candiscardcompil": 56, "discardcompil": 56, "244": 57, "214": 57, "277": 57, "439": 58, "189": 58, "executor": 58, "nativecontext": 58, "150": 58, "ijavetdirectproxyhandl": [58, 60], "v8virtualiter": 58, "javetproxysymboliterableconvert": 58, "183": 58, "receivecallback": 58, "iv8valuemap": 58, "iv8valuearrai": 58, "batchget": 58, "javetcallbacktyp": 58, "ijavetdirectcal": 58, "redesign": 58, "javetreflectionproxi": 58, "169": 59, "freez": 59, "leaf": 60, "elaps": 60, "leverag": 60, "verbos": [60, 76], "testjavaflavor": 60, "round": 60, "isobject": 60, "isint": 60, "asint": 60, "wrapper": 60, "neat": 60, "pure": 60, "testjsflavor": 60, "redirect": [60, 65], "proxyget": 60, "proxyset": 60, "jsonnodewrapp": 60, "requirenonnul": 60, "getjsonnod": 60, "childjsonnod": 60, "v8valueboolean": 60, "propertykei": 60, "propertyvalu": 60, "objectnod": 60, "createv8valueboolean": 60, "testnam": 60, "starttim": 60, "currenttimemilli": 60, "stoptim": 60, "100_000": 60, "interoper": 60, "testscriptjavaflavor": 60, "testscriptjsflavor": 60, "objectmapp": 60, "readtre": 60, "jsonstr": 60, "amd": 60, "5950x": 60, "128gb": 60, "22h2": 60, "corretto": 60, "0_282": 60, "19464m": 60, "100000": 60, "5214m": 60, "370": 60, "underli": 60, "spent": 60, "door": 62, "hijack": 62, "seamlessli": 62, "parser": 62, "cooki": 62, "multer": 62, "app": 62, "req": 62, "8991": 62, "testexpress": 62, "codefil": 62, "tofil": 62, "atomicboolean": 62, "serverup": 62, "500": 62, "max_valu": 62, "1000": 62, "trick": 62, "awaitmod": 62, "drain_the_task_queu": 62, "pause_the_event_loop": 62, "there_are_more_tasks_in_task_queu": 62, "sleep_a_whil": 62, "resume_the_event_loop": 62, "runonc": 62, "there_are_no_more_task": 62, "timer": 62, "gracefulli": 62, "color": 63, "pink": 63, "awt": 63, "175": 63, "stringarrai": 64, "represent": 64, "stringlist": 64, "assert": 64, "mapx": 64, "mapi": 64, "spawn": 65, "databas": 65, "javetengin": [65, 71], "javetconsoleinterceptor": 65, "unregist": [65, 69], "necessari": 65, "famili": 68, "unix": 68, "activebydefault": 68, "operatingsystem": 68, "val": 68, "cpuarch": 68, "getproperti": 68, "ismacosx": 68, "islinux": 68, "aarch64": 68, "cent": 68, "mission": 68, "imposs": 68, "guess": 69, "increaseandget": 69, "suitabl": 69, "testintercept": 69, "delta": 69, "testinterceptor": 69, "76": 69, "200": 69, "scanner": 70, "nextlin": 70, "captur": 70, "err": 70, "getmessag": 70, "highlight": 71, "javetenginepoo": 71, "l": 71, "loadj": 72, "decimaljsfil": 72, "getabsolutepath": 72, "logerror": 72, "v8valuefunctiondecim": 72, "v8valueobjectdecim": 72, "45": 72, "hasownproperti": 72, "getstr": 72, "bigdecim": 72, "lack": [72, 76], "bean": 73, "propertysourc": 73, "classpath": 73, "configurationproperti": 73, "prefix": 73, "myjavetengineconfig": 73, "javetenginepoolnod": 73, "getjavetenginepoolnod": 73, "javetengineconfignod": 73, "setallowev": 73, "setdefaultengineguardtimeoutmilli": 73, "setengineguardcheckintervalmilli": 73, "setpooldaemoncheckintervalmilli": 73, "setpoolidletimeoutsecond": 73, "setpoolmins": 73, "setpoolmaxs": 73, "setpoolshutdowntimeoutsecond": 73, "setresetenginetimeoutsecond": 73, "javetenginepoolv8": 73, "getjavetenginepoolv8": 73, "javetengineconfigv8": 73, "frequent": 76, "ask": 76, "question": 76, "jan": 76, "publish": 76, "smooth": 76, "took": 76, "week": 76, "abandon": 76, "hierarchi": 76, "inconsist": 76, "repeat": 76, "attent": 76, "mental": 76, "role": 76, "inherit": 76, "liter": 76, "richer": 76, "v8valueprimit": 76, "v8data": 76, "consist": 76, "rich": 76, "pain": 76, "imper": 76, "never": 76, "deliv": 76, "elimin": 76, "rid": 76, "everywher": 76, "hotfix": 76, "usag": 76, "extra": 76, "shut": 76, "success": 76}, "objects": {}, "objtypes": {}, "objnames": {}, "titleterms": {"build": [0, 1, 2, 9], "javet": [0, 1, 2, 4, 6, 7, 12, 17, 22, 25, 35, 36, 38, 54, 65, 66, 70, 76], "environ": [0, 2, 18, 35], "linux": [0, 1, 2, 9, 17, 38, 68], "maco": 0, "window": [0, 1, 2, 9, 38, 68], "android": [0, 1, 2, 54, 68], "variabl": [0, 35], "v8": [0, 1, 4, 6, 14, 37, 38, 46, 47, 48, 49, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 66, 71, 72, 76], "featur": [0, 25, 31], "flag": 0, "from": [1, 12, 29, 30, 35, 37, 76], "scratch": 1, "prepar": [1, 26, 31, 63], "arm64": [1, 2, 54], "x86_64": [1, 53], "mac": [1, 53, 54, 68], "o": [1, 53, 54, 68], "why": [1, 9, 16, 24, 42, 48, 76], "patch": [1, 38], "node": [1, 4, 6, 8, 16, 24, 38, 39, 52, 54, 56, 62, 66, 71, 72, 76], "j": [1, 4, 6, 8, 16, 24, 38, 39, 52, 54, 56, 60, 62, 66, 71, 72, 76], "jni": 1, "librari": [1, 20, 35, 54], "docker": 2, "hub": 2, "github": 2, "express": 2, "full": 2, "multi": [2, 4, 53], "stage": 2, "all": 2, "one": 2, "file": [2, 31, 35], "deprec": 2, "debug": [3, 22, 45, 51], "chrome": [3, 22], "develop": [3, 5, 8, 13], "tool": [3, 8], "cdt": 3, "shell": [3, 70], "1": [3, 36, 37, 44, 51, 52, 53, 54, 55, 56, 57, 58, 59, 62, 66], "run": 3, "2": [3, 36, 37, 44, 48, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62], "script": 3, "3": [3, 8, 37, 51, 52, 53, 54, 55, 56, 57, 58, 59, 62], "open": 3, "4": [3, 51, 52, 53, 54, 55, 56, 58], "usual": 3, "intern": [3, 38], "handshak": 3, "custom": [3, 27, 29, 31, 35, 54], "design": [4, 27], "architectur": 4, "primit": [4, 30, 52, 76], "refer": [4, 32, 33, 37], "type": [4, 48, 76], "mode": [4, 6, 14, 16, 31, 36, 38, 45, 66, 71, 72], "v": [4, 6, 48], "modul": [4, 38, 52, 53, 76], "requir": 4, "import": [4, 38, 48], "virtual": [4, 36], "engin": [4, 39, 45, 51, 65], "pool": [4, 39, 45, 65, 71], "isol": 4, "context": [4, 48], "intercept": [4, 12, 48, 52, 69], "cross": 4, "platform": 4, "process": [4, 53], "safeti": [4, 28, 36], "memori": [4, 37], "leak": 4, "detect": 4, "perform": [6, 36], "comparison": [6, 28, 36, 48], "highlight": [6, 29], "java": [6, 26, 29, 30, 48, 53, 60, 63], "wasm": 6, "benchmark": 6, "improv": 6, "test": [7, 12, 60, 69], "jdk": 8, "intellij": 8, "gradl": [8, 25, 68], "maven": [8, 9, 25, 68], "option": [8, 37], "visual": 8, "studio": 8, "commun": 8, "2022": 8, "python": 8, "8": [8, 52, 53, 55, 56, 59], "histori": 9, "j2v8": [9, 76], "issu": 9, "latest": 9, "version": 9, "onli": 9, "autom": 9, "system": 9, "deploi": [9, 35], "repositori": 9, "background": [10, 24], "what": [11, 36, 48, 62], "i": [11, 16, 22, 48, 62], "motiv": [11, 65], "how": [12, 26, 29, 31, 37, 45, 48, 62], "think": 12, "v8runtim": [12, 37, 76], "v8valueglobalobject": 12, "executor": 12, "execut": 12, "declar": [12, 52], "function": [12, 28, 31, 48, 52, 53], "properti": [12, 48, 52, 53], "learn": 12, "unit": 12, "where": [14, 15], "ar": [14, 15], "es6": [14, 76], "api": [14, 33], "exampl": [15, 38, 49], "inspector": 16, "disabl": [16, 48], "can": [17, 21, 22, 28, 35, 48], "support": [17, 21], "legaci": 17, "faq": 19, "A": 20, "dynam": [20, 31, 38], "link": 20, "dll": 20, "initi": 20, "routin": 20, "fail": 20, "i18n": 21, "devtool": 22, "troubleshoot": [23, 43], "crash": 24, "when": [24, 28], "being": 24, "close": [24, 62], "root": 24, "caus": 24, "solut": 24, "event": [24, 52], "unhandledreject": 24, "noderuntim": 24, "await": [24, 37], "lowmemorynotif": [24, 37], "major": 25, "quick": 25, "start": 25, "depend": [25, 68], "kotlin": [25, 68], "dsl": [25, 68], "groovi": [25, 68], "hello": [25, 66], "sponsor": 25, "licens": 25, "blog": 25, "document": 25, "bridg": 26, "convert": [26, 27, 28, 29, 30, 31, 53, 64], "usag": [26, 29, 31, 37, 47, 65, 71], "boolean": [26, 48], "int": 26, "arrai": [26, 64], "integ": 26, "list": [26, 41, 64], "long": [26, 37], "unmodifi": 26, "string": [26, 48], "cast": 26, "object": [26, 27, 28, 29, 31, 48, 64], "javascript": [26, 29, 30, 48, 62, 63], "pojo": 27, "defin": [27, 48], "creat": 27, "pojoconvert": 27, "readi": 27, "go": 27, "insid": 28, "bind": [28, 48], "via": 28, "nativ": [28, 35, 38, 52], "proxi": [28, 31, 53], "null": 28, "circular": 28, "structur": 28, "doe": [28, 29, 31, 36], "config": 28, "take": [28, 35], "effect": 28, "built": [28, 38], "ignor": 28, "regist": [29, 49], "enhanc": 29, "It": 29, "work": [29, 31], "instanc": 31, "map": [31, 48, 64], "path": 31, "static": [31, 63], "stringbuild": [31, 63], "pattern": [31, 63], "enum": [31, 63], "interfac": [31, 53], "anonym": [31, 53], "class": [31, 63], "v8convert": 31, "v8properti": [31, 69], "name": 31, "v8function": [31, 69, 76], "javetproxyconvert": 31, "resourc": [34, 37, 39, 48], "manag": [34, 37, 39, 48], "load": [35, 38, 54], "unload": 35, "On": [35, 38], "demand": [35, 38], "locat": 35, "deploy": 35, "skip": 35, "alreadi": 35, "anoth": 35, "classload": [35, 53], "suppress": 35, "lib": 35, "listen": 35, "remov": 35, "jar": 35, "know": 36, "lock": 36, "mean": 36, "implicit": 36, "explicit": 36, "thread": [36, 39, 62], "coroutin": 36, "challeng": 37, "jvm": 37, "gc": [37, 52], "c": 37, "runtim": 37, "recommend": 37, "automat": [37, 45, 48], "try": 37, "weak": 37, "escap": 37, "without": 37, "altern": 37, "arraybuff": 37, "passiv": 37, "aggress": 37, "manual": [37, 38, 45, 48], "idlenotificationdeadlin": 37, "deadlineinmilli": 37, "statist": 37, "modular": 38, "gap": 38, "between": 38, "deal": 38, "elf": 38, "rebuild": 38, "pre": 38, "synthet": 38, "best": 39, "practic": 39, "secur": 39, "tip": [40, 48], "todo": 41, "error": [42, 52], "code": [42, 48, 52], "backward": 42, "compat": [42, 68], "log": 44, "step": [44, 62], "implement": 44, "ijavetlogg": 44, "inject": [44, 63, 73], "logger": 44, "termin": 45, "about": [45, 48], "valu": [46, 48], "collect": 47, "v8valuearrai": 47, "v8valueset": 47, "v8valuemap": 47, "registr": 48, "convers": [48, 52, 76], "thi": 48, "pass": 48, "symbol": 48, "unregist": 48, "both": 48, "One": 48, "bindfunct": 48, "functionnam": 48, "javetcallbackcontext": 48, "set": 48, "kei": 48, "v8valu": 48, "codestr": 48, "mismatch": 48, "summari": 48, "chang": 48, "user": 48, "fly": 48, "sourc": [48, 52], "call": 48, "invok": 48, "scope": [48, 53], "info": 48, "avoid": 48, "argument": 48, "handl": 48, "count": 48, "promis": [49, 53], "resolv": [49, 53], "lifecycl": 49, "callback": 49, "f": 49, "readfileasync": 49, "unhandl": 49, "reject": 49, "releas": [50, 51, 52, 53, 54, 55, 56, 57, 58, 59], "note": [50, 51, 52, 53, 54, 55, 56, 57, 58, 59], "0": [51, 52, 53, 54, 55, 56, 57, 58, 59], "7": [51, 52, 53, 54, 55, 56, 58], "x": [51, 52, 53, 54, 55, 56, 57, 58, 59], "live": 51, "locker": 51, "guard": 51, "bug": 51, "fix": 51, "birth": 51, "9": [51, 52, 53, 54, 55, 56, 59], "10": [52, 53, 56], "index": 52, "foreach": 52, "hotfix": 52, "6": [52, 53, 54, 55, 58], "loop": 52, "5": [52, 53, 54, 55, 58], "v9": [52, 53, 54, 55], "first": [52, 54], "time": [52, 54], "14": 53, "13": 53, "12": 53, "privat": 53, "11": 53, "polyfil": [53, 72], "empow": 53, "v2": 53, "v1": 53, "safe": 53, "core": 54, "abi": 54, "21": 54, "v16": 54, "v10": [55, 56], "v11": [56, 57, 58, 59], "v18": 56, "v12": 59, "expos": 60, "jsonnod": 60, "approach": 60, "flavor": 60, "direct": 60, "exposur": 60, "wrap": 60, "conclus": 60, "advanc": 61, "interact": 62, "That": 62, "possibl": 62, "server": 62, "worker": 62, "main": 62, "If": 62, "hang": 62, "dure": 62, "interop": 63, "an": 63, "goal": 65, "print": 66, "basic": 67, "instal": 68, "sampl": 69, "co": 71, "exist": 71, "v8host": 71, "decim": 72, "spring": 73, "integr": 73, "configur": 73, "tutori": 74, "migrat": [75, 76], "guid": [75, 76], "registerjavamethod": 76, "v8locker": 76, "bless": 76}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 60}, "alltitles": {"Build Javet": [[0, "build-javet"], [1, "build-javet"], [1, "id1"]], "Build Environment": [[0, "build-environment"], [2, "build-environment"]], "Linux Environment": [[0, "linux-environment"], [2, "linux-environment"]], "MacOS Environment": [[0, "macos-environment"]], "Windows Environment": [[0, "windows-environment"], [2, "windows-environment"]], "Android Environment": [[0, "android-environment"]], "Environment Variables": [[0, "environment-variables"]], "V8 Feature Flags": [[0, "v8-feature-flags"]], "Build Javet from Scratch": [[1, "build-javet-from-scratch"]], "Build V8": [[1, "build-v8"]], "Prepare V8": [[1, "prepare-v8"]], "Build V8 for Linux arm64": [[1, "build-v8-for-linux-arm64"]], "Build V8 for Linux x86_64": [[1, "build-v8-for-linux-x86-64"]], "Build V8 for Mac OS arm64": [[1, "build-v8-for-mac-os-arm64"]], "Build V8 for Mac OS x86_64": [[1, "build-v8-for-mac-os-x86-64"]], "Build V8 for Windows": [[1, "build-v8-for-windows"]], "Build V8 for Android": [[1, "build-v8-for-android"]], "Why Patching V8?": [[1, "why-patching-v8"]], "Build Node.js": [[1, "build-node-js"]], "Prepare Node.js": [[1, "prepare-node-js"]], "Build Node.js on Linux": [[1, "build-node-js-on-linux"]], "Why Patching Node.js?": [[1, "why-patching-node-js"]], "Build Node.js on Mac OS": [[1, "build-node-js-on-mac-os"]], "Build Node.js on Windows": [[1, "build-node-js-on-windows"]], "Build Javet JNI Library for Android": [[1, "build-javet-jni-library-for-android"]], "Build Javet for Linux, Mac OS and Windows": [[1, "build-javet-for-linux-mac-os-and-windows"]], "Build Javet for Android": [[1, "build-javet-for-android"]], "Build Javet with Docker": [[2, "build-javet-with-docker"]], "Docker Hub and Github": [[2, "docker-hub-and-github"]], "Build Javet for Linux on Linux or Windows": [[2, "build-javet-for-linux-on-linux-or-windows"]], "Express Build": [[2, "express-build"]], "Full Build - Multi-staged": [[2, "full-build-multi-staged"]], "Full Build - All-in-one": [[2, "full-build-all-in-one"]], "Build Javet for Windows on Windows": [[2, "build-javet-for-windows-on-windows"]], "Build Javet for Android on Linux or Windows": [[2, "build-javet-for-android-on-linux-or-windows"]], "Linux arm64 Docker Files Deprecated": [[2, "linux-arm64-docker-files-deprecated"]], "Debug with Chrome Developer Tools": [[3, "debug-with-chrome-developer-tools"]], "CDT Shell": [[3, "cdt-shell"]], "1. Run CDT Shell": [[3, "run-cdt-shell"]], "2. Run Script in CDT Shell": [[3, "run-script-in-cdt-shell"]], "3. Open CDT": [[3, "open-cdt"]], "4. Debug as Usual": [[3, "debug-as-usual"]], "Chrome Developer Tools Internals": [[3, "chrome-developer-tools-internals"]], "Handshake": [[3, "handshake"]], "Customization": [[3, "customization"]], "Javet Design": [[4, "javet-design"]], "Architecture": [[4, "architecture"]], "Primitive and Reference Types in Javet": [[4, "primitive-and-reference-types-in-javet"]], "Node.js Mode vs. V8 Mode": [[4, "node-js-mode-vs-v8-mode"]], "Module": [[4, "module"]], "require() vs. import()": [[4, "require-vs-import"]], "Module Virtualization": [[4, "module-virtualization"]], "Engine Pool": [[4, "engine-pool"]], "V8 Isolate and Context in Javet": [[4, "v8-isolate-and-context-in-javet"]], "Javet Engine Pool": [[4, "javet-engine-pool"], [65, "javet-engine-pool"]], "Interception": [[4, "interception"], [69, "interception"]], "Cross-platform": [[4, "cross-platform"]], "Multi-process Safety": [[4, "multi-process-safety"]], "Memory Leak Detection": [[4, "memory-leak-detection"]], "Development": [[5, "development"], [13, "development"]], "Javet Performance": [[6, "javet-performance"]], "Performance Comparisons of Node.js Mode and V8 Mode": [[6, "performance-comparisons-of-node-js-mode-and-v8-mode"]], "Highlights": [[6, "highlights"], [29, "highlights"]], "Java VS Wasm Benchmarks": [[6, "java-vs-wasm-benchmarks"]], "Javet Performance Improvements": [[6, "javet-performance-improvements"]], "Test Javet": [[7, "test-javet"]], "Development Tools": [[8, "development-tools"]], "JDK": [[8, "jdk"]], "IntelliJ": [[8, "intellij"]], "Gradle": [[8, "gradle"]], "Node.js": [[8, "node-js"], [39, "node-js"]], "Maven (Optional)": [[8, "maven-optional"]], "Visual Studio Community 2022 (Optional)": [[8, "visual-studio-community-2022-optional"]], "Python 3.8+ (Optional)": [[8, "python-3-8-optional"]], "History with J2V8": [[9, "history-with-j2v8"]], "J2V8 Issues": [[9, "j2v8-issues"]], "J2V8 Latest Version": [[9, "j2v8-latest-version"]], "Why Windows and Linux only?": [[9, "why-windows-and-linux-only"]], "Why not Automate the J2V8 Build System?": [[9, "why-not-automate-the-j2v8-build-system"]], "Why not Deploy J2V8 to Maven Repository?": [[9, "why-not-deploy-j2v8-to-maven-repository"]], "Background": [[10, "background"], [24, "background"]], "What is the Motivation?": [[11, "what-is-the-motivation"]], "How to Think in Javet?": [[12, "how-to-think-in-javet"]], "V8Runtime and V8ValueGlobalObject": [[12, "v8runtime-and-v8valueglobalobject"]], "V8Runtime": [[12, "v8runtime"]], "V8ValueGlobalObject": [[12, "v8valueglobalobject"]], "Executor and Execute": [[12, "executor-and-execute"]], "Declarative Function and Property Interception": [[12, "declarative-function-and-property-interception"]], "Learn from Unit Test": [[12, "learn-from-unit-test"]], "Where are ES6 API in V8 Mode?": [[14, "where-are-es6-api-in-v8-mode"]], "Where are the Examples?": [[15, "where-are-the-examples"]], "Why is the Inspector Disabled in Node.js Mode?": [[16, "why-is-the-inspector-disabled-in-node-js-mode"]], "Can Javet Support Legacy Linux?": [[17, "can-javet-support-legacy-linux"]], "Environment": [[18, "environment"]], "FAQ": [[19, "faq"]], "A dynamic link library (DLL) initialization routine failed": [[20, "a-dynamic-link-library-dll-initialization-routine-failed"]], "Can i18n be Supported?": [[21, "can-i18n-be-supported"]], "Can I Debug Javet in Chrome DevTools?": [[22, "can-i-debug-javet-in-chrome-devtools"]], "Troubleshooting": [[23, "troubleshooting"], [43, "troubleshooting"]], "Why Node.js Crashes When being Closed?": [[24, "why-node-js-crashes-when-being-closed"]], "Root Cause": [[24, "root-cause"]], "Solution": [[24, "solution"]], "Event unhandledRejection": [[24, "event-unhandledrejection"]], "NodeRuntime.await()": [[24, "noderuntime-await"]], "NodeRuntime.lowMemoryNotification()": [[24, "noderuntime-lowmemorynotification"]], "Javet": [[25, "javet"]], "Major Features": [[25, "major-features"]], "Quick Start": [[25, "quick-start"]], "Dependency": [[25, "dependency"], [68, "dependency"]], "Maven": [[25, "maven"], [68, "maven"]], "Gradle Kotlin DSL": [[25, "gradle-kotlin-dsl"], [68, "gradle-kotlin-dsl"]], "Gradle Groovy DSL": [[25, "gradle-groovy-dsl"], [68, "gradle-groovy-dsl"]], "Hello Javet": [[25, "hello-javet"], [66, "hello-javet"]], "Sponsors": [[25, "sponsors"]], "License": [[25, "license"]], "Blog": [[25, "blog"]], "Documents": [[25, "documents"]], "Bridge Converter": [[26, "bridge-converter"]], "Usage": [[26, "usage"], [29, "usage"], [31, "usage"], [47, "usage"], [65, "usage"], [71, "usage"]], "Preparation": [[26, "preparation"], [31, "preparation"], [63, "preparation"]], "Boolean": [[26, "boolean"]], "int": [[26, "int"]], "int Array": [[26, "int-array"]], "Integer List": [[26, "integer-list"]], "Long Unmodifiable List": [[26, "long-unmodifiable-list"]], "String Array": [[26, "string-array"]], "How to Cast Java Objects to JavaScript Objects?": [[26, "how-to-cast-java-objects-to-javascript-objects"]], "Custom Converter": [[27, "custom-converter"]], "Design a POJO Converter": [[27, "design-a-pojo-converter"]], "Define POJO Object": [[27, "define-pojo-object"]], "Create PojoConverter": [[27, "create-pojoconverter"]], "Ready! Go!": [[27, "ready-go"]], "Converters": [[28, "converters"]], "Comparisons": [[28, "comparisons"], [36, "comparisons"], [48, "comparisons"]], "Inside Converters": [[28, "inside-converters"]], "Binding via Native": [[28, "binding-via-native"]], "Binding via Proxy": [[28, "binding-via-proxy"]], "Null Safety": [[28, "null-safety"]], "Functions and Objects": [[28, "functions-and-objects"]], "Circular Structure": [[28, "circular-structure"]], "When does the Config Take Effect?": [[28, "when-does-the-config-take-effect"]], "Can Built-in Converter be Ignored?": [[28, "can-built-in-converter-be-ignored"]], "Object Converter": [[29, "object-converter"], [64, "object-converter"]], "From Java to JavaScript": [[29, "from-java-to-javascript"], [30, "from-java-to-javascript"]], "From JavaScript to Java": [[29, "from-javascript-to-java"], [30, "from-javascript-to-java"]], "Register Custom Objects": [[29, "register-custom-objects"]], "Enhance the Custom Object": [[29, "enhance-the-custom-object"]], "Register the Custom Object": [[29, "register-the-custom-object"]], "How does It Work?": [[29, "how-does-it-work"]], "Primitive Converter": [[30, "primitive-converter"]], "Proxy Converter": [[31, "proxy-converter"]], "Instance: File": [[31, "instance-file"]], "Instance: Map": [[31, "instance-map"]], "Instance: Path": [[31, "instance-path"]], "Static: StringBuilder": [[31, "static-stringbuilder"]], "Static: Pattern": [[31, "static-pattern"]], "Static: Enum": [[31, "static-enum"]], "Static: Interface": [[31, "static-interface"]], "Dynamic: Anonymous Function": [[31, "dynamic-anonymous-function"]], "Dynamic: Anonymous Object for Interface": [[31, "dynamic-anonymous-object-for-interface"]], "Dynamic: Anonymous Object for Class": [[31, "dynamic-anonymous-object-for-class"]], "Features": [[31, "features"]], "@V8Convert::mode": [[31, "v8convert-mode"]], "@V8Property::name": [[31, "v8property-name"]], "@V8Function::name": [[31, "v8function-name"]], "How does JavetProxyConverter Work?": [[31, "how-does-javetproxyconverter-work"]], "How to Customize JavetProxyConverter?": [[31, "how-to-customize-javetproxyconverter"]], "Reference": [[32, "reference"]], "API Reference": [[33, "api-reference"]], "Resource Management": [[34, "resource-management"], [39, "resource-management"], [48, "resource-management"]], "Load and Unload": [[35, "load-and-unload"]], "Can Javet Native Library be Loaded or Unloaded On-demand?": [[35, "can-javet-native-library-be-loaded-or-unloaded-on-demand"]], "Unload": [[35, "unload"]], "Load": [[35, "load"]], "Can Javet Native Library be Deployed to a Custom Location?": [[35, "can-javet-native-library-be-deployed-to-a-custom-location"]], "Can Javet Native Library Deployment be Skipped?": [[35, "can-javet-native-library-deployment-be-skipped"]], "Can already loaded in another classloader be Suppressed?": [[35, "can-already-loaded-in-another-classloader-be-suppressed"]], "Can Javet Lib Loading Listener Take Environment Variables?": [[35, "can-javet-lib-loading-listener-take-environment-variables"]], "Can Javet Libraries be Removed from the Jar File?": [[35, "can-javet-libraries-be-removed-from-the-jar-file"]], "Know the Lock": [[36, "know-the-lock"]], "What does Lock Mean in Javet?": [[36, "what-does-lock-mean-in-javet"]], "1. Implicit Mode": [[36, "implicit-mode"]], "2. Explicit Mode": [[36, "explicit-mode"]], "Performance": [[36, "performance"]], "Thread-safety": [[36, "thread-safety"]], "Coroutines or Virtual Threads": [[36, "coroutines-or-virtual-threads"]], "Memory Management": [[37, "memory-management"]], "3 Challenges in Memory Management": [[37, "challenges-in-memory-management"]], "JVM GC": [[37, "jvm-gc"]], "C++ Runtime": [[37, "c-runtime"]], "V8 GC": [[37, "v8-gc"]], "Recommended Options": [[37, "recommended-options"]], "Automatic Management with try-with-resource": [[37, "automatic-management-with-try-with-resource"]], "Automatically Manage with Weak Reference": [[37, "automatically-manage-with-weak-reference"]], "How to Escape from try-with-resource?": [[37, "how-to-escape-from-try-with-resource"]], "Usage 1 without V8 Runtime": [[37, "usage-1-without-v8-runtime"]], "Usage 2 with V8 Runtime": [[37, "usage-2-with-v8-runtime"]], "Alternative Option: ArrayBuffer": [[37, "alternative-option-arraybuffer"]], "GC": [[37, "gc"]], "Automatic GC": [[37, "automatic-gc"]], "Passive GC": [[37, "passive-gc"]], "Aggressive GC": [[37, "aggressive-gc"]], "Manual GC": [[37, "manual-gc"]], "V8Runtime.await()": [[37, "v8runtime-await"]], "V8Runtime.idleNotificationDeadline(long deadlineInMillis)": [[37, "v8runtime-idlenotificationdeadline-long-deadlineinmillis"]], "V8Runtime.lowMemoryNotification()": [[37, "v8runtime-lowmemorynotification"]], "Statistics": [[37, "statistics"]], "Modularization": [[38, "modularization"]], "Node.js Mode": [[38, "node-js-mode"], [72, "node-js-mode"]], "Example": [[38, "example"]], "Gaps between Javet Node.js Mode and Native Node.js": [[38, "gaps-between-javet-node-js-mode-and-native-node-js"]], "Deal with Native Modules": [[38, "deal-with-native-modules"]], "Patch ELF Native Modules on Linux": [[38, "patch-elf-native-modules-on-linux"]], "Rebuild Native Modules on Windows": [[38, "rebuild-native-modules-on-windows"]], "Manual Patch Native Modules on Windows": [[38, "manual-patch-native-modules-on-windows"]], "Dynamically Import Built-in Modules": [[38, "dynamically-import-built-in-modules"]], "V8 Mode": [[38, "v8-mode"], [72, "v8-mode"]], "Pre-load": [[38, "pre-load"]], "On-demand": [[38, "on-demand"]], "Synthetic Module": [[38, "synthetic-module"]], "Internals": [[38, "internals"]], "Best Practices": [[39, "best-practices"]], "Thread, Engine and Pool": [[39, "thread-engine-and-pool"]], "Security": [[39, "security"]], "Tips": [[40, "tips"], [48, "tips"]], "TODO List": [[41, "todo-list"]], "Error Codes": [[42, "error-codes"]], "Why Error Codes?": [[42, "why-error-codes"]], "Backward Compatibility": [[42, "backward-compatibility"]], "Logging": [[44, "logging"]], "Step 1: Implement IJavetLogger": [[44, "step-1-implement-ijavetlogger"]], "Step 2: Inject the Logger": [[44, "step-2-inject-the-logger"]], "Termination": [[45, "termination"]], "Automatic Termination with Pool and Engine": [[45, "automatic-termination-with-pool-and-engine"]], "Manual Termination": [[45, "manual-termination"]], "How about Debug Mode?": [[45, "how-about-debug-mode"]], "V8 Values": [[46, "v8-values"]], "V8 Collection": [[47, "v8-collection"]], "Collection in V8": [[47, "collection-in-v8"]], "V8ValueArray": [[47, "v8valuearray"]], "V8ValueSet": [[47, "v8valueset"]], "V8ValueMap": [[47, "v8valuemap"]], "V8 Function": [[48, "v8-function"]], "Function Types": [[48, "function-types"]], "Function Interception": [[48, "function-interception"]], "Automatic Registration": [[48, "automatic-registration"]], "bind()": [[48, "bind"]], "How about Object Type Conversion?": [[48, "how-about-object-type-conversion"]], "Can this be Passed in?": [[48, "can-this-be-passed-in"]], "Can Symbol Properties be Intercepted?": [[48, "can-symbol-properties-be-intercepted"]], "How to Disable Properties or Functions?": [[48, "how-to-disable-properties-or-functions"]], "How to Unregister Properties or Functions?": [[48, "how-to-unregister-properties-or-functions"]], "Can Both JavaScript Function and Property Map to One Java Function?": [[48, "can-both-javascript-function-and-property-map-to-one-java-function"]], "Can 2 Java Functions Map to One JavaScript Function and Property?": [[48, "can-2-java-functions-map-to-one-javascript-function-and-property"]], "Manual Registration": [[48, "manual-registration"]], "boolean bindFunction(String functionName, JavetCallbackContext javetCallbackContext)": [[48, "boolean-bindfunction-string-functionname-javetcallbackcontext-javetcallbackcontext"]], "boolean set(String key, V8Value value)": [[48, "boolean-set-string-key-v8value-value"]], "boolean bindFunction(String functionName, String codeString)": [[48, "boolean-bindfunction-string-functionname-string-codestring"]], "Type Mismatch": [[48, "type-mismatch"]], "Summary": [[48, "summary"]], "Change a User Defined JavaScript Function on the Fly": [[48, "change-a-user-defined-javascript-function-on-the-fly"]], "Why is Changing a User Defined JavaScript Function Important?": [[48, "why-is-changing-a-user-defined-javascript-function-important"]], "How to Change a User Defined JavaScript Function on the Fly?": [[48, "how-to-change-a-user-defined-javascript-function-on-the-fly"]], "What is the Source Code of a Function in V8?": [[48, "what-is-the-source-code-of-a-function-in-v8"]], "Automatic Type Conversion": [[48, "automatic-type-conversion"]], "Call vs. Invoke": [[48, "call-vs-invoke"]], "Call": [[48, "call"]], "Invoke": [[48, "invoke"]], "How about Bind?": [[48, "how-about-bind"]], "Context and Scope Info": [[48, "context-and-scope-info"]], "How to Avoid Argument Type Mismatches?": [[48, "how-to-avoid-argument-type-mismatches"]], "How to Handle Argument Count Mismatches?": [[48, "how-to-handle-argument-count-mismatches"]], "V8 Promise": [[49, "v8-promise"]], "Promise and Resolver": [[49, "promise-and-resolver"]], "Lifecycle": [[49, "lifecycle"]], "Register a Callback": [[49, "register-a-callback"]], "Example fs.readFileAsync()": [[49, "example-fs-readfileasync"]], "Unhandled Rejection": [[49, "unhandled-rejection"]], "Release Notes": [[50, "release-notes"]], "Release Notes 0.7.x": [[51, "release-notes-0-7-x"]], "0.7.4 Live Debug": [[51, "live-debug"]], "0.7.3 Locker": [[51, "locker"]], "0.7.2 Engine Guard": [[51, "engine-guard"]], "0.7.1 Bug Fixes": [[51, "bug-fixes"]], "0.7.0 Birth with V8 v8.9": [[51, "birth-with-v8-v8-9"]], "Release Notes 0.8.x": [[52, "release-notes-0-8-x"]], "0.8.10 Index in forEach": [[52, "index-in-foreach"]], "0.8.9 Declarative Property Interception": [[52, "declarative-property-interception"]], "0.8.8 Hotfix the Source Code": [[52, "hotfix-the-source-code"]], "0.8.7 Native Modules for Node.js": [[52, "native-modules-for-node-js"]], "0.8.6 Event Loop for Node.js": [[52, "event-loop-for-node-js"]], "0.8.5 Error Codes": [[52, "error-codes"]], "0.8.4 V8 v9.0": [[52, "v8-v9-0"]], "0.8.3 GC": [[52, "gc"]], "0.8.2 Conversion for Primitive": [[52, "conversion-for-primitive"]], "0.8.1 Declarative Function Interception": [[52, "declarative-function-interception"]], "0.8.0 First Time with Node.js": [[52, "first-time-with-node-js"]], "Release Notes 0.9.x": [[53, "release-notes-0-9-x"]], "0.9.14 V8 Scope": [[53, "v8-scope"]], "0.9.13 V8 v9.4": [[53, "v8-v9-4"]], "0.9.12 Private Properties": [[53, "private-properties"]], "0.9.11 V8 v9.3": [[53, "v8-v9-3"]], "0.9.10 Polyfill Java Interfaces": [[53, "polyfill-java-interfaces"]], "0.9.9 Mac OS x86_64": [[53, "mac-os-x86-64"]], "0.9.8 Empower the Promise": [[53, "empower-the-promise"]], "0.9.7 Proxy Converter v2": [[53, "proxy-converter-v2"]], "0.9.6 Proxy Converter v1": [[53, "proxy-converter-v1"]], "0.9.5 V8 v9.2": [[53, "v8-v9-2"]], "0.9.4 Multi-process Safe": [[53, "multi-process-safe"]], "0.9.3 Module Resolver": [[53, "module-resolver"]], "0.9.2 Anonymous Functions in Converter": [[53, "anonymous-functions-in-converter"]], "0.9.1 V8 in Classloader": [[53, "v8-in-classloader"]], "0.9.0 V8 v9.1": [[53, "v8-v9-1"]], "Release Notes 1.0.x": [[54, "release-notes-1-0-x"]], "1.0.7 V8 v9.7": [[54, "v8-v9-7"]], "1.0.6 Mac OS (arm64)": [[54, "mac-os-arm64"]], "1.0.5 Javet Core": [[54, "javet-core"]], "1.0.4 V8 9.6": [[54, "v8-9-6"]], "1.0.3 Android ABI 21": [[54, "android-abi-21"]], "1.0.2 First Time with Android": [[54, "first-time-with-android"]], "1.0.1 Custom Library Loading": [[54, "custom-library-loading"]], "1.0.0 First Time with Node.js v16": [[54, "first-time-with-node-js-v16"]], "Release Notes 1.1.x": [[55, "release-notes-1-1-x"]], "1.1.7 V8 v10.5": [[55, "v8-v10-5"]], "1.1.6 V8 v10.4": [[55, "v8-v10-4"]], "1.1.5 V8 v10.3": [[55, "v8-v10-3"]], "1.1.4 V8 v10.2": [[55, "v8-v10-2"]], "1.1.3 V8 v10.1": [[55, "v8-v10-1"]], "1.1.2 V8 v10.0": [[55, "v8-v10-0"]], "1.1.1 V8 v9.9": [[55, "v8-v9-9"]], "1.1.0 V8 v9.8": [[55, "v8-v9-8"]], "Release Notes 2.0.x": [[56, "release-notes-2-0-x"]], "2.0.4 V8 v11.0": [[56, "v8-v11-0"]], "2.0.3 V8 v10.9": [[56, "v8-v10-9"]], "2.0.2 V8 v10.8": [[56, "v8-v10-8"]], "2.0.1 V8 v10.7": [[56, "v8-v10-7"]], "2.0.0 Node.js v18.10": [[56, "node-js-v18-10"]], "Release Notes 2.1.x": [[57, "release-notes-2-1-x"]], "2.1.2 V8 v11.3": [[57, "v8-v11-3"]], "2.1.1 V8 v11.2": [[57, "v8-v11-2"]], "2.1.0 V8 v11.1": [[57, "v8-v11-1"]], "Release Notes 2.2.x": [[58, "release-notes-2-2-x"]], "2.2.3 V8 v11.7": [[58, "v8-v11-7"]], "2.2.2 V8 v11.6": [[58, "v8-v11-6"]], "2.2.1 V8 v11.5": [[58, "v8-v11-5"]], "2.2.0 V8 v11.4": [[58, "v8-v11-4"]], "Release Notes 3.0.x": [[59, "release-notes-3-0-x"]], "3.0.2 V8 v12.0": [[59, "v8-v12-0"]], "3.0.1 V8 v11.9": [[59, "v8-v11-9"]], "3.0.0 V8 v11.8": [[59, "v8-v11-8"]], "Expose JsonNode in V8": [[60, "expose-jsonnode-in-v8"]], "2 Approaches": [[60, "approaches"]], "Java Flavor (Direct Exposure)": [[60, "java-flavor-direct-exposure"]], "JS Flavor (Wrapped Exposure)": [[60, "js-flavor-wrapped-exposure"]], "Test": [[60, "test"], [69, "test"]], "Conclusion": [[60, "conclusion"]], "Advanced": [[61, "advanced"]], "Interact with Node.js": [[62, "interact-with-node-js"]], "Is That Possible?": [[62, "is-that-possible"]], "How?": [[62, "how"]], "Step 1: JavaScript Server": [[62, "step-1-javascript-server"]], "Step 2: Worker Thread for the JavaScript Server": [[62, "step-2-worker-thread-for-the-javascript-server"]], "Step 3: Main Thread for the Interaction": [[62, "step-3-main-thread-for-the-interaction"]], "What If Node.js Hangs during Close()?": [[62, "what-if-node-js-hangs-during-close"]], "Java and JavaScript Interop": [[63, "java-and-javascript-interop"]], "Inject a Static Class": [[63, "inject-a-static-class"]], "Inject an Enum": [[63, "inject-an-enum"]], "Inject a Pattern": [[63, "inject-a-pattern"]], "Inject a StringBuilder": [[63, "inject-a-stringbuilder"]], "Array": [[64, "array"]], "List": [[64, "list"]], "Map": [[64, "map"]], "Motivation": [[65, "motivation"]], "Goals": [[65, "goals"]], "Print Hello Javet in V8 Mode": [[66, "print-hello-javet-in-v8-mode"]], "Print 1 + 1 in Node.js Mode": [[66, "print-1-1-in-node-js-mode"]], "Basic": [[67, "basic"]], "Installation": [[68, "installation"]], "OS Compatibility": [[68, "os-compatibility"]], "Windows": [[68, "windows"]], "Linux": [[68, "linux"]], "Mac OS": [[68, "mac-os"]], "Android": [[68, "android"]], "Sample": [[69, "sample"]], "@V8Property and @V8Function": [[69, "v8property-and-v8function"]], "Javet Shell": [[70, "javet-shell"]], "Node.js Mode and V8 Mode": [[71, "node-js-mode-and-v8-mode"]], "Co-existence": [[71, "co-existence"]], "V8Host": [[71, "v8host"]], "Pool": [[71, "pool"]], "Polyfill": [[72, "polyfill"]], "decimal.js": [[72, "decimal-js"]], "Spring Integration": [[73, "spring-integration"]], "Configuration": [[73, "configuration"]], "Injection": [[73, "injection"]], "Tutorial": [[74, "tutorial"]], "Migration Guides": [[75, "migration-guides"], [76, "migration-guides"]], "Migrate from J2V8": [[76, "migrate-from-j2v8"]], "Why Migrate from J2V8 to Javet?": [[76, "why-migrate-from-j2v8-to-javet"]], "V8 \u27f6 V8Runtime": [[76, "v8-v8runtime"]], "Primitive Types": [[76, "primitive-types"]], "registerJavaMethod() \u27f6 @V8Function": [[76, "registerjavamethod-v8function"]], "V8Locker": [[76, "v8locker"]], "Type Conversion": [[76, "type-conversion"]], "Node.js and V8": [[76, "node-js-and-v8"]], "ES6 Module": [[76, "es6-module"]], "Blessing": [[76, "blessing"]]}, "indexentries": {}}) \ No newline at end of file +Search.setIndex({"docnames": ["development/build", "development/build_javet_from_scratch", "development/build_javet_with_docker", "development/debug_with_chrome_developer_tools", "development/design", "development/index", "development/performance", "development/test", "development/tools", "faq/background/history_with_j2v8", "faq/background/index", "faq/background/what_is_the_motivation", "faq/development/how_to_think_in_javet", "faq/development/index", "faq/development/where_are_es6_api_in_v8_mode", "faq/development/where_are_the_examples", "faq/development/why_is_the_inspector_disabled_in_node_js_mode", "faq/environment/can_javet_support_legacy_linux", "faq/environment/index", "faq/index", "faq/troubleshooting/a_dynamic_link_library_dll_initialization_routine_failed", "faq/troubleshooting/can_i18n_be_supported", "faq/troubleshooting/can_i_debug_javet_in_chrome_dev_tools", "faq/troubleshooting/index", "faq/troubleshooting/sigsegv_at_createv8runtime_in_v8_mode_on_aws", "faq/troubleshooting/why_node_js_crashes_when_being_closed", "index", "reference/converters/bridge_converter", "reference/converters/custom_converter", "reference/converters/index", "reference/converters/object_converter", "reference/converters/primitive_converter", "reference/converters/proxy_converter", "reference/index", "reference/javadoc/index", "reference/resource_management/index", "reference/resource_management/load_and_unload", "reference/resource_management/lock", "reference/resource_management/memory_management", "reference/resource_management/modularization", "reference/resource_management/snapshot", "reference/tips/best_practices", "reference/tips/index", "reference/todo_list", "reference/troubleshooting/error_codes", "reference/troubleshooting/index", "reference/troubleshooting/logging", "reference/troubleshooting/termination", "reference/v8_values/index", "reference/v8_values/v8_collection", "reference/v8_values/v8_function", "reference/v8_values/v8_promise", "release_notes/index", "release_notes/release_notes_0_7", "release_notes/release_notes_0_8", "release_notes/release_notes_0_9", "release_notes/release_notes_1_0", "release_notes/release_notes_1_1", "release_notes/release_notes_2_0", "release_notes/release_notes_2_1", "release_notes/release_notes_2_2", "release_notes/release_notes_3_0", "tutorial/advanced/access_the_whole_jvm", "tutorial/advanced/expose_json_node_in_v8", "tutorial/advanced/index", "tutorial/advanced/interact_with_node_js", "tutorial/advanced/java_and_javascript_interop", "tutorial/advanced/object_converter", "tutorial/basic/engine_pool", "tutorial/basic/hello_javet", "tutorial/basic/index", "tutorial/basic/installation", "tutorial/basic/interception", "tutorial/basic/javet_shell", "tutorial/basic/node_js_mode_and_v8_mode", "tutorial/basic/polyfill", "tutorial/basic/spring_integration", "tutorial/index", "tutorial/migration_guides/index", "tutorial/migration_guides/migrate_from_j2v8"], "filenames": ["development/build.rst", "development/build_javet_from_scratch.rst", "development/build_javet_with_docker.rst", "development/debug_with_chrome_developer_tools.rst", "development/design.rst", "development/index.rst", "development/performance.rst", "development/test.rst", "development/tools.rst", "faq/background/history_with_j2v8.rst", "faq/background/index.rst", "faq/background/what_is_the_motivation.rst", "faq/development/how_to_think_in_javet.rst", "faq/development/index.rst", "faq/development/where_are_es6_api_in_v8_mode.rst", "faq/development/where_are_the_examples.rst", "faq/development/why_is_the_inspector_disabled_in_node_js_mode.rst", "faq/environment/can_javet_support_legacy_linux.rst", "faq/environment/index.rst", "faq/index.rst", "faq/troubleshooting/a_dynamic_link_library_dll_initialization_routine_failed.rst", "faq/troubleshooting/can_i18n_be_supported.rst", "faq/troubleshooting/can_i_debug_javet_in_chrome_dev_tools.rst", "faq/troubleshooting/index.rst", "faq/troubleshooting/sigsegv_at_createv8runtime_in_v8_mode_on_aws.rst", "faq/troubleshooting/why_node_js_crashes_when_being_closed.rst", "index.rst", "reference/converters/bridge_converter.rst", "reference/converters/custom_converter.rst", "reference/converters/index.rst", "reference/converters/object_converter.rst", "reference/converters/primitive_converter.rst", "reference/converters/proxy_converter.rst", "reference/index.rst", "reference/javadoc/index.rst", "reference/resource_management/index.rst", "reference/resource_management/load_and_unload.rst", "reference/resource_management/lock.rst", "reference/resource_management/memory_management.rst", "reference/resource_management/modularization.rst", "reference/resource_management/snapshot.rst", "reference/tips/best_practices.rst", "reference/tips/index.rst", "reference/todo_list.rst", "reference/troubleshooting/error_codes.rst", "reference/troubleshooting/index.rst", "reference/troubleshooting/logging.rst", "reference/troubleshooting/termination.rst", "reference/v8_values/index.rst", "reference/v8_values/v8_collection.rst", "reference/v8_values/v8_function.rst", "reference/v8_values/v8_promise.rst", "release_notes/index.rst", "release_notes/release_notes_0_7.rst", "release_notes/release_notes_0_8.rst", "release_notes/release_notes_0_9.rst", "release_notes/release_notes_1_0.rst", "release_notes/release_notes_1_1.rst", "release_notes/release_notes_2_0.rst", "release_notes/release_notes_2_1.rst", "release_notes/release_notes_2_2.rst", "release_notes/release_notes_3_0.rst", "tutorial/advanced/access_the_whole_jvm.rst", "tutorial/advanced/expose_json_node_in_v8.rst", "tutorial/advanced/index.rst", "tutorial/advanced/interact_with_node_js.rst", "tutorial/advanced/java_and_javascript_interop.rst", "tutorial/advanced/object_converter.rst", "tutorial/basic/engine_pool.rst", "tutorial/basic/hello_javet.rst", "tutorial/basic/index.rst", "tutorial/basic/installation.rst", "tutorial/basic/interception.rst", "tutorial/basic/javet_shell.rst", "tutorial/basic/node_js_mode_and_v8_mode.rst", "tutorial/basic/polyfill.rst", "tutorial/basic/spring_integration.rst", "tutorial/index.rst", "tutorial/migration_guides/index.rst", "tutorial/migration_guides/migrate_from_j2v8.rst"], "titles": ["Build Javet", "Build Javet from Scratch", "Build Javet with Docker", "Debug with Chrome Developer Tools", "Javet Design", "Development", "Javet Performance", "Test Javet", "Development Tools", "History with J2V8", "Background", "What is the Motivation?", "How to Think in Javet?", "Development", "Where are ES6 API in V8 Mode?", "Where are the Examples?", "Why is the Inspector Disabled in Node.js Mode?", "Can Javet Support Legacy Linux?", "Environment", "FAQ", "A dynamic link library (DLL) initialization routine failed", "Can i18n be Supported?", "Can I Debug Javet in Chrome DevTools?", "Troubleshooting", "SIGSEGV at createV8Runtime() in V8 Mode on AWS", "Why Node.js Crashes When being Closed?", "Javet", "Bridge Converter", "Custom Converter", "Converters", "Object Converter", "Primitive Converter", "Proxy Converter", "Reference", "API Reference", "Resource Management", "Load and Unload", "Know the Lock", "Memory Management", "Modularization", "Snapshot", "Best Practices", "Tips", "TODO List", "Error Codes", "Troubleshooting", "Logging", "Termination", "V8 Values", "V8 Collection", "V8 Function", "V8 Promise", "Release Notes", "Release Notes 0.7.x", "Release Notes 0.8.x", "Release Notes 0.9.x", "Release Notes 1.0.x", "Release Notes 1.1.x", "Release Notes 2.0.x", "Release Notes 2.1.x", "Release Notes 2.2.x", "Release Notes 3.0.x", "Access the Whole JVM", "Expose JsonNode in V8", "Advanced", "Interact with Node.js", "Java and JavaScript Interop", "Object Converter", "Javet Engine Pool", "Hello Javet", "Basic", "Installation", "Interception", "Javet Shell", "Node.js Mode and V8 Mode", "Polyfill", "Spring Integration", "Tutorial", "Migration Guides", "Migrate from J2V8"], "terms": {"It": [0, 2, 4, 6, 9, 12, 16, 21, 26, 28, 29, 32, 37, 38, 39, 40, 41, 50, 68, 73, 74, 79], "": [0, 2, 4, 6, 9, 11, 24, 25, 28, 32, 37, 38, 39, 40, 41, 44, 50, 51, 62, 63, 65, 67, 74, 79], "quit": [0, 4, 6, 11, 12, 24, 29, 32, 38, 46, 47, 50, 63, 65, 68, 79], "hard": [0, 9, 51, 79], "develop": [0, 16, 19, 22, 26, 40, 44, 51, 53, 63, 79], "successfulli": [0, 2, 3, 24], "variou": [0, 60, 79], "reason": [0, 4, 9, 21, 25, 44, 51, 65, 79], "node": [0, 2, 5, 7, 9, 13, 14, 19, 20, 21, 23, 26, 36, 37, 38, 40, 43, 44, 50, 51, 52, 55, 57, 59, 60, 61, 62, 63, 64, 68, 70, 71, 73, 76, 77], "j": [0, 2, 5, 7, 9, 13, 14, 19, 20, 21, 23, 26, 36, 37, 38, 40, 43, 44, 50, 51, 52, 53, 55, 57, 59, 60, 61, 62, 64, 68, 70, 71, 77], "need": [0, 3, 6, 9, 28, 29, 30, 32, 37, 38, 39, 50, 51, 63, 66, 71, 79], "built": [0, 2, 3, 6, 7, 27, 30, 38, 40, 44, 47, 50, 51, 54, 55, 59, 62, 63, 79], "static": [0, 1, 16, 24, 28, 40, 50, 55, 57, 65], "librari": [0, 2, 3, 4, 7, 12, 19, 21, 23, 39, 44, 46, 50, 55, 62], "monolith": 0, "everi": [0, 4, 12, 29, 37, 38, 50], "o": [0, 2, 4, 26, 37, 40, 44, 50, 63, 79], "platform": [0, 5, 40], "ha": [0, 2, 4, 6, 8, 9, 12, 16, 28, 30, 32, 36, 38, 39, 46, 49, 50, 51, 54, 63, 79], "its": [0, 4, 9, 32, 37, 38, 39, 50, 51], "own": [0, 4, 9, 28, 30, 32, 36, 38, 39, 50, 51], "pitfal": 0, "which": [0, 3, 4, 6, 7, 9, 12, 15, 17, 25, 26, 29, 30, 32, 36, 38, 39, 40, 47, 50, 62, 63, 66, 72, 74, 75, 79], "usual": [0, 28, 32, 39, 47, 50, 51, 62, 65], "make": [0, 1, 2, 16, 29, 30, 38, 39, 40, 51, 65, 75, 79], "frustrat": [0, 9], "even": [0, 9, 79], "desper": 0, "here": [0, 3, 4, 6, 9, 11, 16, 28, 32, 36, 38, 39, 50, 51, 65, 66, 67], "ar": [0, 1, 2, 3, 4, 6, 8, 9, 12, 13, 16, 17, 19, 25, 26, 27, 28, 29, 30, 31, 32, 36, 37, 38, 39, 40, 41, 44, 47, 50, 51, 53, 54, 55, 62, 63, 65, 66, 67, 71, 72, 74, 79], "3": [0, 1, 5, 6, 9, 16, 17, 25, 26, 27, 32, 36, 39, 40, 49, 50, 52, 62, 69, 71, 72, 73], "wai": [0, 4, 12, 25, 26, 27, 28, 32, 36, 38, 39, 40, 41, 47, 50, 51, 55, 63, 65, 68, 72, 76], "docker": [0, 3, 5, 9], "from": [0, 2, 4, 5, 6, 9, 11, 15, 16, 17, 24, 25, 29, 32, 37, 39, 40, 41, 44, 47, 50, 51, 54, 55, 56, 57, 62, 63, 65, 66, 68, 69, 72, 73, 77, 78], "scratch": [0, 5, 11, 40], "all": [0, 1, 3, 4, 9, 25, 27, 28, 30, 32, 36, 38, 39, 40, 50, 54, 56, 62, 63, 65, 67, 79], "them": [0, 3, 32, 38, 39, 50, 63], "share": [0, 1, 4, 37, 39, 50, 51, 65, 79], "same": [0, 4, 16, 37, 38, 39, 41, 50, 51, 63, 79], "next": [0, 29, 50], "section": [0, 39, 40, 50], "ubuntu": [0, 2, 17, 39, 54, 57, 61, 71], "20": [0, 2, 25, 54, 56, 57, 58, 59, 60, 61, 71], "04": [0, 2, 17, 53, 54, 57, 59, 61, 71], "cmake": [0, 1, 9], "25": [0, 56, 58, 61, 71], "1": [0, 4, 6, 9, 12, 17, 26, 27, 28, 30, 32, 36, 39, 40, 41, 47, 49, 50, 52, 62, 63, 66, 67, 71, 72, 73, 74, 75, 79], "jdk": [0, 5, 28, 46, 63], "8": [0, 3, 5, 6, 9, 17, 28, 38, 52, 56, 59, 62, 63, 65, 71], "gradl": [0, 1, 2, 5, 9, 32], "2": [0, 6, 8, 9, 12, 17, 26, 27, 30, 32, 36, 39, 40, 41, 47, 49, 52, 62, 66, 69, 71, 72, 73, 74, 75, 79], "gcc": [0, 17, 54, 61], "11": [0, 26, 28, 56, 57, 58, 61], "python": [0, 1, 5], "9": [0, 9, 17, 52, 62, 65], "catalina": [0, 71], "latest": [0, 2, 74], "brew": 0, "xcode": 0, "4": [0, 6, 9, 32, 36, 38, 39, 49, 50, 52, 62, 65, 71, 72, 73], "16": [0, 6, 17, 38, 54, 55, 57, 58, 59, 60, 71], "10": [0, 2, 6, 32, 38, 47, 56, 61, 63, 71], "visual": [0, 5, 58, 59], "studio": [0, 5, 58, 59], "2022": [0, 5, 57, 58, 59], "commun": [0, 3, 5, 9, 16, 26], "24": [0, 54, 59, 61, 71], "come": [0, 4, 6, 37, 39], "sdk": [0, 46, 76], "windbg": 0, "wsl2": [0, 2], "option": [0, 5, 16, 31, 39, 40, 41, 50, 55, 57, 61, 62, 63, 72, 74], "ndk": [0, 57], "r25b": 0, "30": [0, 58], "javet_hom": [0, 1], "i": [0, 1, 2, 4, 6, 7, 8, 9, 10, 12, 13, 14, 15, 17, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 36, 37, 38, 39, 40, 41, 44, 46, 47, 49, 51, 54, 55, 62, 63, 66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 79], "home": 0, "directori": [0, 4, 39, 75], "node_hom": [0, 1], "v8_home": [0, 1], "depot_tools_hom": [0, 1], "googl": [0, 3], "depot": 0, "tool": [0, 1, 2, 5, 16, 17, 22, 26, 40, 53], "android_ndk_hom": [0, 1], "android_sdk_hom": 0, "descript": [0, 32, 38], "custom": [0, 4, 5, 29, 39, 40, 41, 50, 54, 55, 57], "libcxx": 0, "off": [0, 1, 3, 4, 38], "The": [0, 1, 2, 3, 4, 6, 7, 9, 12, 15, 16, 20, 24, 25, 27, 28, 29, 32, 36, 37, 38, 39, 40, 44, 47, 50, 51, 62, 63, 65, 66, 71, 72, 73, 74, 79], "offici": [0, 1, 9, 15, 17, 26, 39], "releas": [0, 1, 4, 6, 9, 26, 38, 44, 79], "doesn": [0, 3, 4, 9, 30, 32, 36, 37, 38, 39, 44, 46, 47, 50, 76, 79], "t": [0, 3, 4, 9, 16, 24, 25, 26, 28, 29, 30, 32, 36, 37, 38, 39, 40, 44, 46, 47, 50, 73, 74, 76, 79], "support": [0, 1, 2, 4, 8, 9, 16, 18, 19, 23, 26, 30, 31, 32, 36, 38, 39, 40, 44, 47, 49, 50, 54, 55, 56, 57, 58, 60, 61, 71, 74, 79], "debug": [0, 4, 5, 16, 19, 23, 26, 46, 50], "extern": [0, 6, 38], "startup": [0, 40], "data": [0, 4, 29, 38, 39, 40, 50, 53, 58, 62], "i18n": [0, 1, 19, 23, 44, 57], "pleas": [0, 1, 2, 3, 4, 6, 11, 16, 17, 21, 22, 26, 29, 32, 36, 37, 38, 39, 41, 47, 50, 51, 52, 62, 63, 66, 67, 68, 69, 71, 72, 73, 75, 79], "contact": [0, 1, 9, 16, 17, 21, 52, 71, 79], "maintain": [0, 16, 17, 21, 52, 71, 79], "privat": [0, 16, 17, 21, 28, 30, 32, 50, 63, 71, 72], "thi": [0, 3, 4, 9, 11, 12, 17, 20, 24, 25, 26, 28, 29, 30, 32, 36, 37, 38, 39, 40, 51, 57, 63, 65, 66, 72, 74, 79], "pointer": [0, 38, 50], "compress": 0, "sandbox": 0, "snapshot": [0, 17, 35, 44, 58], "follow": [1, 2, 3, 4, 15, 17, 21, 24, 25, 26, 28, 30, 38, 39, 40, 41, 44, 46, 49, 50, 51, 62, 63, 65, 72, 74], "guid": [1, 26, 77], "If": [1, 2, 12, 25, 26, 29, 30, 31, 32, 38, 39, 40, 41, 47, 50, 71, 72, 73, 79], "you": [1, 2, 3, 8, 9, 12, 15, 22, 25, 26, 28, 32, 37, 38, 40, 46, 50, 51, 52, 62, 71, 75, 76, 79], "face": [1, 4], "ani": [1, 9, 29, 30, 31, 32, 39, 40, 44, 46, 47, 50, 79], "issu": [1, 3, 4, 11, 24, 25, 37, 38, 39, 41, 54, 55, 56, 59, 61], "mai": [1, 2, 3, 4, 6, 9, 12, 15, 24, 25, 26, 27, 29, 32, 36, 37, 38, 39, 40, 41, 46, 47, 50, 76], "sjtucaocao": [1, 2, 26], "clone": [1, 2, 58], "sourc": [1, 3, 16, 24, 29, 37, 39, 44, 47, 62, 63, 66, 67, 68, 69, 72, 73, 75, 79], "code": [1, 3, 4, 6, 9, 12, 16, 24, 28, 29, 30, 37, 38, 39, 40, 41, 45, 47, 51, 55, 56, 60, 62, 63, 66, 67, 68, 69, 72, 73, 75, 79], "checkout": 1, "proper": 1, "version": [1, 3, 4, 8, 11, 26, 32, 39, 40, 52, 71, 74], "also": [1, 2, 4, 6, 9, 11, 12, 29, 31, 32, 36, 37, 38, 39, 46, 50, 51, 65, 79], "sure": [1, 2, 9, 16, 29, 38, 39, 65, 75], "arg": [1, 24, 28, 50, 65], "gn": 1, "file": [1, 3, 4, 6, 9, 21, 38, 39, 40, 51, 62, 65, 75], "look": [1, 4, 9, 11, 39, 55], "like": [1, 3, 6, 9, 11, 12, 26, 32, 39, 40, 41, 44, 50, 57, 73], "is_debug": 1, "fals": [1, 16, 27, 29, 32, 36, 38, 39, 50, 62, 65, 66], "target_cpu": 1, "v8_monolith": 1, "true": [1, 11, 16, 27, 29, 32, 36, 38, 39, 40, 47, 50, 62, 63, 65, 66, 67, 71, 73], "v8_use_external_startup_data": 1, "is_component_build": 1, "v8_enable_i18n_support": 1, "v8_enable_pointer_compress": 1, "v8_static_librari": 1, "symbol_level": 1, "0": [1, 3, 9, 17, 24, 26, 27, 28, 30, 32, 38, 39, 40, 41, 47, 49, 50, 52, 62, 63, 65, 67, 71, 72, 75, 79], "use_custom_libcxx": 1, "v8_enable_sandbox": 1, "x64": [1, 39], "To": [1, 3, 9, 21, 29, 36, 43, 66], "enabl": [1, 2, 3, 6, 12, 16, 21, 32, 38, 40, 50, 51, 54, 55, 62, 66], "set": [1, 3, 4, 7, 9, 12, 27, 28, 29, 30, 36, 38, 39, 40, 46, 49, 51, 54, 60, 62, 63, 65, 66, 67, 72], "export": [1, 24, 39], "path": [1, 17, 36, 39, 44, 60, 65], "cd": [1, 2, 39], "ninja": 1, "c": [1, 32, 39, 50, 57, 58, 59, 63, 67], "out": [1, 24, 26, 38, 39, 44, 47, 62, 63, 65, 66, 67, 69, 72, 73, 79], "python3": [1, 9], "script": [1, 4, 9, 12, 26, 39, 41, 47, 50, 54, 58, 68, 73, 75], "patch_v8_build": 1, "py": 1, "p": [1, 32], "requir": [1, 6, 8, 12, 36, 39, 41, 47, 50, 51, 65], "depot_tools_win_toolchain": 1, "gen": 1, "id": [1, 3, 4, 44, 50, 71], "v": [1, 5, 9, 26, 39], "solut": [1, 11, 30, 50, 62], "dev": [1, 6], "v8gen": 1, "arm": [1, 26, 56, 71], "target_o": 1, "v8_target_cpu": 1, "ia32": 1, "x86": [1, 26, 55, 56, 71], "A": [1, 4, 19, 23, 24, 28, 39, 40, 50], "few": [1, 2, 3, 8, 9, 11, 12, 24, 28, 29, 32, 38, 50, 53, 54, 61, 62, 66, 67, 73], "certain": [1, 3, 4, 12, 40, 50, 51, 55], "warn": [1, 46, 54], "error": [1, 9, 36, 39, 45, 46, 50, 51, 55, 56, 57, 60], "so": [1, 2, 4, 6, 7, 9, 12, 14, 17, 24, 25, 27, 28, 29, 30, 32, 36, 37, 38, 39, 40, 41, 46, 50, 51, 58, 63, 65, 67, 71, 75, 76, 79], "msvc": [1, 39], "stop": [1, 9, 59], "compil": [1, 4, 6, 32, 39, 40, 44, 50, 61, 62, 66, 79], "turn": [1, 3, 4, 38, 54, 61], "those": [1, 3, 4, 12, 25, 38, 39, 50, 62], "lt": 1, "patch_node_build": 1, "configur": 1, "without": [1, 2, 3, 4, 25, 30, 32, 36, 37, 40, 50, 56, 60, 62, 63, 79], "intl": 1, "j4": 1, "first": [1, 3, 36, 38, 39, 50, 53, 79], "thin": 1, "disabl": [1, 3, 12, 13, 19, 24, 32, 38, 40, 41, 44, 47, 51, 58], "second": [1, 3, 15, 21, 39, 40, 47, 50], "mani": [1, 9, 11, 38, 40, 50, 79], "posit": [1, 6, 50], "independ": [1, 6], "link": [1, 19, 23, 38, 39], "phase": 1, "broken": [1, 9, 24, 38, 50], "fpic": 1, "usr": [1, 17], "bin": [1, 17], "ld": 1, "libnod": 1, "node_bind": 1, "reloc": 1, "r_x86_64_tpoff32": 1, "against": [1, 50], "_zn4nodel23thread_local_modpending": 1, "can": [1, 2, 3, 4, 6, 12, 18, 19, 23, 25, 30, 32, 38, 39, 40, 41, 51, 62, 65, 66, 74, 75, 76, 79], "us": [1, 3, 4, 6, 8, 11, 16, 24, 25, 29, 31, 36, 38, 39, 40, 41, 46, 50, 62, 68, 79], "when": [1, 4, 6, 9, 19, 20, 23, 32, 38, 39, 40, 41, 47, 50, 51, 57, 59, 79], "object": [1, 4, 12, 25, 38, 40, 41, 49, 54, 55, 56, 57, 61, 63, 64, 66, 68, 72, 77, 79], "recompil": 1, "vcbuild": 1, "bat": 1, "vs2022": 1, "onc": [1, 28, 29, 38, 39, 40, 44, 62, 65], "readi": 1, "navig": [1, 39], "cpp": [1, 40], "access": [1, 12, 32, 36, 38, 44, 50, 64, 77], "execut": [1, 3, 4, 6, 24, 32, 39, 40, 41, 44, 47, 49, 50, 51, 62, 63, 68, 69, 73], "correspond": [1, 2, 4, 25, 38, 39, 41, 50, 62], "command": [1, 40, 73], "sh": [1, 39], "dnode_dir": 1, "dv8_dir": 1, "maco": [1, 9, 26, 36, 71], "cmd": [1, 39], "after": [1, 3, 9, 30, 32, 36, 39, 40, 41, 47, 50, 51, 63, 79], "while": [1, 2, 32, 47, 65, 73], "place": [1, 4, 9, 25, 29, 38, 79], "folder": [1, 41, 65], "src": [1, 40], "main": [1, 24, 28, 32, 66], "resourc": [1, 4, 12, 15, 26, 29, 33, 37, 39, 44, 47, 51, 62, 63, 69, 72, 73, 76], "libjavet": [1, 36, 39], "dylib": 1, "dll": [1, 19, 23, 39], "arch": [1, 26, 40, 56, 71], "dcmake_android_ndk": 1, "dcmake_android_arch": 1, "jnilib": 1, "armeabi": 1, "v7a": 1, "v8a": 1, "mode": [1, 5, 7, 13, 17, 19, 20, 21, 23, 25, 26, 36, 38, 40, 41, 50, 51, 54, 55, 57, 60, 62, 68, 70, 71, 77, 79], "append": [1, 32, 62, 66], "denable_i18n": 1, "test": [1, 2, 4, 5, 6, 9, 15, 16, 17, 26, 32, 37, 39, 40, 50, 51, 53, 62, 65, 71, 75], "jar": [1, 3, 4, 9], "lib": [1, 39, 56], "aar": 1, "output": [1, 28, 50, 62, 63, 65, 66, 67], "As": [2, 3, 4, 12, 24, 27, 30, 32, 36, 38, 46, 50, 62, 76], "regard": [2, 3], "mac": [2, 9, 26, 79], "contributor": 2, "welcom": [2, 73], "interest": [2, 9], "Or": 2, "have": [2, 9, 16, 24, 26, 28, 30, 32, 38, 39, 40, 50, 51, 75, 79], "wait": [2, 3, 56, 65], "long": [2, 30, 31, 32, 37, 50, 63], "git": 2, "network": 2, "connect": [2, 3, 4, 68], "up": [2, 3, 4, 6, 12, 32, 37, 38, 39, 40, 55, 56, 62, 65], "run": [2, 4, 6, 28, 32, 37, 38, 39, 47, 75], "repositori": [2, 17], "imag": [2, 3, 9], "avail": [2, 3, 4, 20, 36, 40, 44, 50, 62, 74], "http": [2, 3, 4, 6, 26, 65], "com": [2, 6, 24, 26, 38, 39, 46, 71], "r": [2, 17, 66], "caoccao": [2, 6, 24, 26, 38, 39, 46, 71], "f": [2, 4, 39], "x86_64": [2, 24, 26, 39, 56, 71], "build_artifact": 2, "dockerfil": [2, 55, 59], "pull": 2, "5gb": 2, "actual": [2, 3, 4, 6, 9, 12, 29, 37, 38, 39, 44, 50, 63, 65], "take": [2, 4, 6, 9, 11, 25, 31, 32, 38, 39, 40, 50, 54, 56, 62, 63, 65, 68, 73, 79], "minut": [2, 4, 29], "includ": [2, 9, 27, 32, 36, 40, 50, 79], "depend": [2, 4, 6, 9, 32, 39, 40, 46, 50, 76], "maven": [2, 5, 32], "central": [2, 8], "instruct": [2, 38], "insid": [2, 3, 4, 24, 32, 38, 51], "perform": [2, 3, 4, 5, 9, 24, 25, 26, 27, 29, 30, 36, 38, 39, 41, 50, 53, 56, 60, 61, 63, 65, 68, 72, 79], "base_jvm": 2, "base": [2, 6, 7, 24, 32, 38, 50, 55, 57, 58, 63, 79], "jvm": [2, 4, 21, 26, 29, 32, 36, 37, 53, 64, 65, 67, 68, 74, 77, 79], "base_nod": 2, "base_v8": 2, "v8": [2, 3, 5, 7, 9, 11, 12, 13, 16, 19, 21, 23, 25, 26, 29, 30, 32, 33, 36, 37, 40, 41, 43, 44, 47, 52, 62, 64, 65, 66, 67, 68, 70, 71, 72, 73, 76, 77], "base_gradl": 2, "final": [2, 24, 28, 29, 30, 32, 38, 39, 44, 47, 50, 51, 62, 63], "artifact": 2, "base_all_in_on": 2, "build_all_in_on": 2, "updat": [2, 17, 36, 40, 50, 54, 55, 56, 57, 59], "daemon": [2, 38, 47], "json": [2, 3, 27, 32, 39, 63, 67], "storag": [2, 6, 24], "opt": 2, "dm": 2, "bases": 2, "120gb": 2, "size": [2, 4, 6, 21, 27, 30, 32, 36, 38, 44], "restart": [2, 79], "m": [2, 6, 63], "4g": 2, "roughli": 2, "5": [2, 3, 24, 25, 32, 38, 39, 40, 52, 62, 65, 71, 72, 73], "hour": [2, 9], "internet": 2, "stabl": 2, "dai": [2, 41], "just": [2, 3, 6, 9, 12, 28, 30, 36, 37, 38, 39, 50, 62, 66, 79], "fail": [2, 19, 23, 39, 44, 47, 50, 57], "forev": [2, 38], "larg": [2, 16], "60": 2, "gb": 2, "effici": [2, 15, 55], "push": [2, 32, 49, 50, 51, 60], "Of": [2, 32, 38, 39, 50, 62, 79], "cours": [2, 32, 38, 39, 50, 62, 79], "wise": [2, 17, 50, 63, 71], "workflow": 2, "11gb": 2, "process": [2, 3, 25, 28, 51], "been": [2, 8, 9, 25, 36, 50, 79], "significantli": [2, 40, 44], "chang": [2, 16, 24, 29, 30, 37, 39, 44, 55, 56, 60, 61, 66, 72], "sinc": [2, 9, 71], "v12": [2, 26], "That": [2, 4, 6, 9, 24, 25, 29, 36, 38, 39, 46, 47, 50, 62, 79], "result": [2, 3, 4, 6, 29, 37, 41, 51, 69, 73], "devtool": [3, 19, 23, 26], "aka": 3, "web": [3, 38, 41], "directli": [3, 32, 36, 38, 50, 63, 66, 79], "browser": [3, 41], "help": [3, 40, 41], "edit": [3, 50], "page": 3, "fly": 3, "diagnos": 3, "problem": [3, 6, 9, 28, 50], "quickli": 3, "ultim": 3, "build": [3, 4, 5, 8, 11, 16, 17, 21, 24, 26, 39, 40, 50, 54, 55, 59, 61, 71], "better": [3, 4, 6, 36, 37, 50, 61, 63], "websit": 3, "faster": [3, 40], "javet": [3, 5, 8, 9, 13, 14, 15, 16, 18, 19, 20, 23, 24, 25, 27, 28, 29, 30, 32, 38, 41, 43, 44, 46, 47, 49, 50, 51, 53, 55, 60, 62, 65, 66, 67, 70, 71, 72, 74, 75, 76, 77], "ship": 3, "applic": [3, 4, 6, 12, 16, 24, 25, 28, 29, 30, 32, 36, 37, 38, 39, 40, 47, 50, 51, 62, 65, 66, 68, 72, 73, 79], "demonstr": 3, "how": [3, 4, 7, 11, 13, 15, 19, 25, 26, 28, 36, 37, 39, 55, 62, 63, 79], "work": [3, 4, 9, 12, 24, 25, 26, 36, 37, 38, 39, 50, 51, 63, 65, 71, 79], "normal": [3, 38, 47, 65], "java": [3, 4, 5, 9, 14, 24, 26, 28, 29, 32, 36, 37, 38, 39, 51, 56, 62, 64, 65, 67, 72, 75, 77, 79], "consol": [3, 4, 28, 50, 51, 62, 63, 65, 68, 69, 72, 73], "an": [3, 4, 6, 9, 11, 12, 14, 24, 26, 27, 29, 32, 36, 37, 38, 39, 40, 41, 46, 47, 50, 51, 62, 67, 72, 73, 74], "interact": [3, 4, 26, 28, 54, 62, 64, 73, 77], "appear": [3, 50], "arbitrari": [3, 4, 12, 29, 30, 32, 62, 66, 79], "what": [3, 9, 10, 15, 19, 29, 38, 39, 63, 79], "done": [3, 79], "let": [3, 9, 25, 28, 32, 39, 40, 62, 63, 65, 73], "undefin": [3, 29, 32, 39, 50, 62, 63, 73], "b": [3, 27, 29, 32, 39, 40, 50, 62, 63, 66, 67, 73, 75], "7": [3, 6, 17, 38, 52, 62, 65, 71, 72, 73, 79], "inspect": [3, 16, 50], "remot": 3, "target": [3, 7, 29, 30, 40, 63, 79], "click": 3, "voil\u00e0": [3, 32, 65], "screenshot": 3, "show": [3, 4, 32, 38, 39, 50, 51, 62], "evalu": [3, 4, 39, 57, 79], "auto": [3, 17, 36, 54], "complet": [3, 4, 7, 30, 32, 38, 39, 41, 47, 50, 55, 56, 65, 66, 71, 79], "enjoi": 3, "listen": [3, 25, 38, 51, 65], "port": [3, 52, 65], "9229": 3, "default": [3, 4, 21, 24, 29, 30, 32, 36, 38, 39, 47, 50, 66, 72, 74], "becaus": [3, 4, 6, 8, 9, 16, 25, 26, 27, 28, 29, 30, 32, 36, 37, 38, 41, 44, 50, 51, 62, 63, 68, 74, 75, 79], "constantli": 3, "queri": [3, 62], "127": [3, 38], "list": [3, 6, 24, 26, 29, 30, 33, 50], "tell": [3, 25, 32, 36, 38, 39, 65, 72], "flavor": [3, 15, 50, 62, 73], "via": [3, 4, 32, 38, 39, 41, 47, 50, 51, 62, 65, 72], "websocket": 3, "address": [3, 25, 38, 39, 41, 50, 61, 65], "w": 3, "protocol": 3, "current": [3, 4, 9, 40, 44, 50, 71], "v1": [3, 52, 56, 71], "api": [3, 4, 9, 11, 12, 13, 19, 26, 28, 29, 32, 33, 36, 37, 38, 39, 46, 50, 51, 53, 54, 56, 60, 62, 63, 65, 67, 75, 79], "doc": [3, 6, 54, 56], "chromedevtool": 3, "github": [3, 6], "io": [3, 16, 62], "upgrad": [3, 8, 9, 11, 17, 43, 54, 55, 56, 57, 58, 59, 60, 61], "request": 3, "respons": [3, 36, 39, 40, 50], "accept": [3, 16, 29, 46, 50, 51, 55], "switch": [3, 26, 36, 37, 41, 54], "send": [3, 29, 38, 65], "messag": [3, 38, 44, 46], "method": [3, 12, 28, 30, 32, 44, 50, 63], "runtim": [3, 4, 17, 21, 32, 36, 37, 39, 40, 41, 44, 47, 50, 55, 56, 57, 59, 61, 62, 63, 65, 68, 69, 72, 73, 74, 79], "param": 3, "notif": [3, 38], "executioncontextcr": 3, "context": [3, 6, 12, 25, 37, 38, 39, 41, 44, 59], "origin": [3, 4, 50], "name": [3, 4, 12, 28, 30, 36, 39, 44, 46, 50, 56, 59, 62, 63, 72, 75, 76], "inspector": [3, 13, 19], "00000000": 3, "uniqueid": 3, "debugg": [3, 50], "maxscriptscaches": 3, "100000000": 3, "debuggerid": 3, "setpauseonexcept": 3, "state": [3, 40, 50], "none": [3, 50], "setasynccallstackdepth": 3, "maxdepth": [3, 44], "32": [3, 38], "profil": [3, 71], "6": [3, 8, 9, 39, 52, 58, 61, 62, 65, 71, 72, 73], "getisolateid": 3, "setblackboxpattern": 3, "pattern": [3, 12, 15, 30, 47], "runifwaitingfordebugg": 3, "pars": [3, 6], "expos": [3, 4, 26, 29, 30, 32, 38, 39, 43, 50, 51, 56, 62, 64, 77, 79], "callback": [3, 25, 38, 39, 44, 50, 54, 55, 56, 57, 59, 60, 65], "iv8inspectorlisten": 3, "rest": [3, 39], "refer": [3, 6, 11, 25, 26, 32, 36, 37, 39, 41, 44, 47, 50, 51, 59, 61, 62, 63, 66, 67, 68, 69, 71, 72, 73, 75, 79], "detail": [3, 4, 11, 16, 21, 22, 37, 47, 50, 51, 62, 63, 66, 67, 68, 69, 71, 72, 73, 74, 75, 79], "ye": [3, 4, 17, 22, 25, 29, 30, 32, 36, 37, 39, 49, 50, 71, 75], "feel": [3, 39, 40, 50], "free": [3, 4, 12, 30, 37, 38, 39, 50, 54, 68, 79], "server": [3, 6, 29, 71], "your": [3, 9, 17, 32, 36, 40, 41, 46, 76, 79], "environ": [3, 4, 5, 6, 17, 19, 26, 37, 39, 54, 56, 68], "creat": [3, 16, 21, 24, 27, 30, 32, 37, 38, 39, 44, 46, 47, 50, 51, 55, 60, 62, 63, 65, 66, 67, 68, 69, 72, 73, 76, 79], "showcas": 3, "further": [3, 6, 38], "some": [3, 4, 6, 9, 12, 14, 17, 20, 24, 25, 29, 36, 38, 40, 50, 51, 56, 60, 62, 63, 68, 75, 79], "tip": [3, 26, 33], "integr": [3, 9, 26, 46, 53, 70, 77], "embed": [3, 4, 6, 9, 21, 26, 40, 41], "jetti": 3, "Be": [3, 32, 38, 41, 51, 62], "care": [3, 31, 32, 37, 38, 39, 41, 51, 62], "host": [3, 4, 21, 36, 39, 62, 63, 65, 69, 72, 73], "togeth": [3, 40, 65], "otherwis": [3, 30, 31, 36, 37, 50], "refus": 3, "add": [3, 17, 24, 27, 28, 30, 32, 38, 39, 40, 49, 50, 51, 62, 67, 72, 75, 79], "intercept": [3, 5, 32, 38, 39, 53, 55, 70, 77], "event": [3, 41, 51, 65, 79], "In": [3, 4, 6, 12, 16, 25, 27, 29, 32, 36, 37, 38, 39, 41, 47, 50, 51, 63, 65, 79], "practic": [3, 4, 12, 42], "decent": [3, 6, 9, 49, 51], "jackson": [3, 63], "gson": [3, 63], "interpret": [3, 4], "why": [3, 12, 13, 19, 23, 24, 36, 38, 75], "breakpoint": 3, "befor": [3, 12, 24, 25, 29, 36, 38, 39, 62, 65], "right": [3, 36], "featur": [3, 4, 5, 8, 9, 12, 24, 30, 36, 38, 39, 44, 49, 50, 51, 52, 66, 71, 74, 75, 79], "enforc": [3, 62], "authent": 3, "author": 3, "among": [3, 6, 37, 50, 60, 79], "well": [3, 9, 25, 32, 38, 79], "though": [3, 8, 44, 50, 68, 79], "other": [3, 4, 12, 29, 36, 37, 38, 40, 41, 46, 50, 51, 54, 65, 67, 71, 74, 79], "visit": [3, 16, 22, 26, 75], "more": [3, 4, 6, 9, 16, 17, 30, 36, 38, 39, 40, 43, 44, 47, 50, 51, 55, 56, 68, 69, 72, 73, 74, 75, 79], "javetshel": [3, 26, 62], "provid": [3, 4, 6, 17, 25, 27, 28, 29, 30, 32, 39, 40, 49, 50, 62, 68, 72, 79], "either": [3, 4, 6, 7, 50], "There": [4, 9, 12, 17, 27, 28, 29, 36, 38, 39, 40, 44, 50, 62, 63, 74], "vagu": 4, "boundari": 4, "between": [4, 6, 9, 26, 29, 30, 38, 41, 50, 54, 63, 66], "definit": 4, "mixtur": 4, "both": [4, 6, 29, 36, 38, 40, 44, 51, 55, 62, 74, 79], "trade": 4, "No": [4, 9, 28, 29, 36, 39, 47, 49, 50, 65], "copi": [4, 32, 36, 38], "valu": [4, 26, 28, 29, 30, 31, 33, 36, 38, 39, 44, 49, 53, 54, 55, 56, 63, 72], "Not": [4, 40, 50, 71], "possibl": [4, 30, 37, 40, 41, 63], "weak": 4, "keep": [4, 29, 32, 37, 38, 41, 63], "footprint": 4, "jni": [4, 8, 36, 38, 50, 56, 57, 59], "recycl": [4, 6, 25, 29, 32, 38, 41, 69], "close": [4, 9, 12, 16, 19, 23, 32, 36, 38, 39, 41, 44, 47, 50, 54, 55, 59, 61, 62, 67, 68], "call": [4, 6, 9, 12, 16, 24, 25, 28, 29, 32, 36, 37, 38, 39, 41, 47, 51, 54, 62, 63, 65, 66, 72, 79], "old": [4, 9, 41, 51], "school": 4, "manag": [4, 9, 12, 15, 26, 33, 39, 54], "tri": [4, 9, 20], "hide": [4, 9], "kind": [4, 9, 28, 37, 50, 79], "tediou": [4, 12, 79], "try": [4, 9, 11, 24, 26, 28, 32, 37, 39, 40, 41, 47, 49, 50, 51, 62, 63, 65, 68, 69, 72, 73, 74, 75], "best": [4, 15, 42], "co": 4, "exist": [4, 11, 32, 39, 40, 63, 75], "one": [4, 7, 9, 11, 12, 16, 21, 27, 32, 36, 38, 39, 50, 63, 66, 72, 73, 74, 79], "word": [4, 38, 65], "thei": [4, 9, 30, 36, 38, 39, 41, 44, 51, 63, 74], "side": [4, 6, 16, 38], "don": [4, 9, 16, 26, 32, 39, 40, 46, 74, 76, 79], "interfer": 4, "each": [4, 38, 50, 74, 79], "diagram": [4, 50], "lazi": 4, "load": [4, 12, 20, 35, 40, 44, 75, 79], "dedic": [4, 38, 41, 65, 79], "classload": [4, 79], "comparison": [4, 5, 9, 26], "loadabl": 4, "high": [4, 29, 38], "ecosystem": [4, 74], "secur": [4, 6, 12, 39, 40, 75, 79], "low": 4, "unload": [4, 35, 39, 79], "One": [4, 29], "beauti": [4, 29, 50], "appli": [4, 24, 29, 32, 36, 39, 41, 47, 50, 57, 61, 65], "exampl": [4, 13, 19, 28, 66, 67], "e": [4, 6, 12, 14, 25, 27, 28, 29, 36, 38, 39, 47, 50, 51, 62, 63, 65, 72, 74, 75, 79], "g": [4, 6, 12, 14, 17, 25, 27, 29, 36, 38, 39, 50, 51, 62, 63, 65, 66, 72, 74, 75, 79], "net": [4, 32], "etc": [4, 11, 12, 14, 27, 29, 36, 38, 50, 62, 65, 75], "zero": [4, 38], "byte": [4, 30, 31, 32, 38, 40, 50, 62], "buffer": [4, 38], "achiev": [4, 9, 32, 37, 38, 50], "thread": [4, 6, 9, 16, 24, 38, 44, 47, 51, 54, 55, 62, 68, 79], "multipl": [4, 16, 21, 24, 37, 39, 41, 55, 79], "instanc": [4, 6, 12, 16, 27, 38, 39, 41, 46, 50, 66, 72], "onli": [4, 12, 14, 16, 21, 24, 29, 31, 32, 36, 39, 40, 41, 46, 50, 52, 63, 71, 79], "visibl": [4, 50], "beyond": 4, "allow": [4, 6, 9, 21, 27, 28, 29, 30, 32, 36, 39, 46, 50, 51, 54, 55, 56, 60, 62, 65, 66, 67, 68, 72, 79], "explicit": [4, 27, 79], "await": [4, 6, 41, 50, 51, 54, 58, 65], "control": [4, 25, 29, 39, 47, 50], "over": [4, 25, 29, 39, 50, 79], "async": [4, 6, 25, 51], "global": [4, 12, 24, 39, 50, 59, 62, 68, 79], "recommend": [4, 6, 8, 32, 41, 50, 51, 63, 68], "project": [4, 9, 11, 12, 14, 15, 26, 32, 39, 51, 62, 71, 75, 79], "increas": [4, 29, 44, 79], "align": 4, "chrome": [4, 5, 16, 19, 23, 26, 40, 53], "doe": [4, 16, 24, 25, 36, 38, 47, 50, 79], "bring": [4, 29, 36], "system": [4, 8, 11, 24, 26, 32, 36, 39, 44, 46, 62, 63, 65, 66, 67, 69, 71, 72, 73], "unfortun": [4, 9], "veri": [4, 24, 32, 39, 41, 50, 73, 74], "limit": [4, 12], "howev": [4, 6, 9, 11, 12, 25, 29, 30, 36, 38, 50, 63, 79], "bad": [4, 9], "leav": [4, 11, 30, 39, 62], "typic": [4, 39, 47, 50], "challeng": [4, 9, 12, 29], "sync": 4, "locat": [4, 39, 79], "interceptor": [4, 25, 50, 51, 62, 68, 72], "partial": 4, "know": [4, 7, 9, 25, 35, 39, 50, 79], "want": [4, 8, 9, 12, 25, 29, 36, 37, 38, 40, 44, 50, 51, 52, 62], "defin": [4, 29, 32], "es6": [4, 9, 13, 19, 39], "repres": [4, 12, 29, 38, 50, 79], "string": [4, 24, 28, 30, 31, 32, 39, 46, 51, 53, 63, 65, 67, 69, 72, 73, 75], "dure": [4, 24, 25, 29, 36, 38, 39, 40, 50, 54, 79], "url": 4, "whatev": [4, 25, 37, 38, 50, 51, 62], "store": [4, 24, 38, 39, 40, 50, 59], "map": [4, 27, 29, 30, 39, 49], "kei": [4, 24, 32, 39, 49, 63], "feed": [4, 39], "get": [4, 9, 12, 25, 27, 28, 30, 32, 36, 38, 39, 41, 46, 47, 49, 50, 51, 56, 57, 63, 65, 67, 68, 74, 75, 76, 79], "start": [4, 11, 16, 24, 29, 40, 47, 50, 56, 62, 65, 79], "excel": [4, 9], "articl": 4, "explain": 4, "concept": [4, 12, 51], "insight": 4, "summari": [4, 6], "vm": [4, 24, 41, 61], "heap": [4, 38, 40], "separ": [4, 6, 12, 32], "unrel": [4, 6], "javascript": [4, 6, 16, 25, 26, 29, 32, 37, 38, 39, 40, 51, 56, 62, 64, 67, 69, 72, 77, 79], "singl": [4, 6, 9, 37, 50, 65], "model": [4, 24, 37], "simplifi": [4, 50], "v8runtim": [4, 6, 24, 26, 27, 28, 30, 32, 37, 39, 40, 41, 47, 49, 50, 51, 53, 54, 55, 56, 58, 61, 62, 63, 66, 67, 68, 69, 72, 73, 74, 75], "resetisol": [4, 37, 54], "resetcontext": [4, 37, 41, 54], "alwai": [4, 28, 41, 50], "brand": 4, "new": [4, 6, 7, 9, 11, 24, 27, 28, 30, 32, 36, 37, 38, 39, 40, 46, 47, 49, 50, 51, 52, 62, 63, 65, 66, 67, 68, 72, 73, 74, 75, 76], "much": [4, 6, 9, 32, 38, 41, 50, 63, 73, 75, 79], "cheaper": 4, "oper": [4, 29], "good": [4, 26, 38, 72], "enough": [4, 28, 32], "term": [4, 47, 50, 63], "almost": [4, 9, 32, 38, 50, 65], "db": 4, "safe": [4, 25, 29, 37, 50], "NOT": [4, 37, 50], "lock": [4, 35, 38, 44, 47, 54, 61, 79], "violat": 4, "core": [4, 36, 37, 39, 41, 55], "dump": [4, 37, 41, 55, 56], "immedi": [4, 16, 21, 37, 38, 41, 47], "valid": [4, 38, 50, 62], "minim": [4, 30, 41, 68], "overhead": [4, 6, 12, 29, 30, 37, 38, 47, 68], "behind": [4, 6, 11, 12, 25, 62, 67], "scene": [4, 12, 25, 62, 67], "sampl": [4, 28, 32, 36, 38, 39, 50, 62, 65], "function": [4, 14, 16, 30, 36, 38, 39, 40, 48, 53, 56, 57, 58, 62, 63, 65, 66, 72, 79], "packag": [4, 6, 8, 9, 62], "automat": [4, 7, 29, 32, 36, 37, 39, 44, 59, 69, 72, 79], "per": [4, 32, 36, 37, 38, 39], "calcul": [4, 50], "unpack": 4, "system_temporary_directori": 4, "pid": 4, "deploi": [4, 55, 62], "avoid": [4, 12, 21, 29, 32, 36, 41, 61, 62], "race": [4, 37], "condit": [4, 30, 37], "initi": [4, 6, 19, 23, 38, 39, 40, 57, 61, 65, 68, 72], "purg": [4, 65], "legaci": [4, 9, 18, 19, 57], "least": [4, 9], "begin": 4, "nativ": [4, 20, 26, 27, 30, 37, 38, 41, 50, 53, 65, 79], "track": [4, 38, 60], "delet": [4, 27, 32, 49, 50, 62, 66, 72], "javetnativemonitor": 4, "unit": [4, 15], "case": [4, 6, 7, 9, 15, 29, 31, 36, 37, 38, 39, 50, 51, 53, 79], "fetch": [4, 6, 51], "compar": [4, 7, 37], "count": [4, 44, 47, 49, 62, 65], "verifi": [4, 39, 50], "unmanag": [4, 38], "properli": [4, 24, 62], "alloc": [4, 37, 50, 56], "freed": 4, "intellij": [5, 9], "flag": [5, 24, 38, 55, 57], "design": [5, 7, 15, 16, 26, 30, 32, 36, 37, 39, 50, 65, 74, 79], "architectur": [5, 9], "modul": [5, 20, 25, 40, 41, 43, 44, 50, 58, 59, 75], "engin": [5, 24, 26, 27, 38, 39, 40, 44, 56, 70, 76, 77], "pool": [5, 24, 26, 38, 46, 53, 56, 70, 76, 77], "cross": [5, 79], "memori": [5, 9, 11, 15, 24, 25, 29, 32, 35, 36, 40, 41, 44, 50, 54, 56, 61, 62, 63, 79], "leak": [5, 9, 11, 29, 32, 38, 41, 54, 56, 61, 62], "detect": [5, 28, 29, 44, 50, 55, 56], "wasm": 5, "benchmark": 5, "improv": [5, 9, 37, 38, 40, 56, 60, 61], "cdt": [5, 73], "shell": [5, 70, 77], "intern": [5, 32, 36, 37, 38, 50, 56, 57, 60, 71], "faq": [5, 26], "reset": [6, 41], "i7": [6, 9], "10700k": [6, 9], "window": [6, 11, 12, 20, 26, 53, 63, 79], "type": [6, 12, 27, 28, 29, 30, 32, 36, 37, 38, 39, 44, 53, 54, 56, 57, 63], "tp": [6, 9], "751": 6, "032": 6, "ad": [6, 9, 32, 37, 53, 54, 55, 56, 57, 58, 59, 60, 61], "hoc": [6, 9, 37, 55], "65": 6, "410": 6, "143": 6, "363": 6, "isol": [6, 12, 37, 38, 39, 41, 79], "51": 6, "263": [6, 38], "647": 6, "458": 6, "846": 6, "968": 6, "253": 6, "508": 6, "748": 6, "660": 6, "slightli": 6, "mainli": 6, "older": 6, "than": [6, 11, 29, 40, 47, 50, 75, 79], "dramat": [6, 50], "outperform": 6, "huge": [6, 21, 71], "serious": [6, 9], "slow": [6, 30], "down": [6, 79], "creation": [6, 38, 40, 68], "unless": [6, 38, 41, 79], "particular": [6, 9, 36, 39, 40], "linux": [6, 11, 18, 19, 24, 26, 53, 54, 55, 57, 59, 61, 79], "addit": [6, 17, 30, 37, 50, 71, 79], "emb": 6, "bind": [6, 32, 39, 51, 54, 67, 72, 79], "webassembli": 6, "concern": 6, "program": 6, "languag": [6, 38, 50], "gener": [6, 28, 32, 38, 40, 44, 50, 55, 63], "jul": 6, "13": [6, 56, 58, 59], "2023": [6, 24, 58, 59, 60, 61], "binarytre": 6, "672": 6, "2048": 6, "305": 6, "edigit": 6, "814": 6, "484": 6, "59": 6, "fannkuch": 6, "redux": 6, "1660": 6, "4639": 6, "279": 6, "fasta": 6, "512": [6, 38], "367": 6, "72": 6, "helloworld": 6, "mandelbrot": 6, "1411": 6, "1095": 6, "78": 6, "merkletre": 6, "1134": 6, "221": 6, "nbodi": 6, "546": 6, "472": 6, "86": 6, "nsiev": 6, "694": 6, "586": 6, "84": 6, "pidigit": 6, "4975": 6, "2761": 6, "55": 6, "spectral": 6, "norm": 6, "4198": 6, "4128": 6, "98": 6, "coro": 6, "prime": 6, "siev": 6, "796": 6, "105": [6, 44], "jit": 6, "optim": 6, "warm": 6, "could": [6, 9], "higher": 6, "And": [6, 9, 26, 65], "measur": [6, 63], "choos": [6, 25, 50], "technologi": 6, "accord": 6, "differ": [6, 9, 12, 30, 39, 41, 50, 51, 63], "signific": [6, 38], "algorithm": [6, 56], "awar": [6, 38, 41], "drawback": [6, 39, 63], "consider": [6, 17, 29, 47, 71], "written": [6, 29, 40], "rust": 6, "21": [6, 37, 55, 61, 71], "kb": 6, "amount": [6, 21, 71, 79], "time": [6, 9, 16, 30, 32, 36, 39, 40, 63, 68], "eventu": [6, 38, 62], "whole": [6, 32, 64, 77], "asynchron": 6, "mean": [6, 36, 39, 46, 50], "busi": [6, 56, 79], "logic": [6, 9, 29, 50, 51, 65, 79], "deal": [6, 28, 30, 38, 50], "promis": [6, 25, 41, 48, 65], "synchron": [6, 37, 79], "flexibl": [6, 39], "black": 6, "box": [6, 39], "impli": [6, 11, 16, 17, 25, 71, 79], "vulner": [6, 40, 41], "major": [6, 39, 53, 79], "javetperf": [6, 60], "reus": [7, 12], "do": [7, 9, 12, 22, 25, 26, 37, 38, 39, 41, 50, 51, 67], "suit": 7, "timestamp": 7, "newer": 7, "instal": [8, 9, 17, 36, 39, 65, 70, 75, 77], "drop": [8, 9, 39, 50], "heavili": [8, 28, 50, 79], "person": 8, "idea": [8, 9, 11, 38], "For": [8, 12, 32, 39, 50], "now": [8, 9, 28, 32, 39, 46, 50, 72], "v7": 8, "kotlin": [8, 32, 37], "dsl": [8, 32], "construct": [8, 50, 55], "14": [8, 9, 32, 56, 57, 58, 59, 60, 71], "17": [8, 55, 57, 60, 61], "v3": [8, 24, 39, 52, 71], "bundl": 8, "hasn": [9, 25, 50], "activ": [9, 25, 36, 39, 71], "2017": 9, "last": 9, "wa": [9, 39, 79], "2016": 9, "v4": 9, "fulli": [9, 28], "were": [9, 24], "around": [9, 39], "android": [9, 26, 36, 57, 58, 59], "year": [9, 79], "nearli": 9, "seriou": [9, 11], "fix": [9, 11, 20, 27, 38, 39, 52, 54, 55, 56, 57, 58, 59, 60, 61], "under": [9, 38, 41, 50, 62], "Its": [9, 38, 40, 79], "evolv": 9, "expect": [9, 24, 38, 44, 50], "chanc": 9, "implement": [9, 26, 30, 32, 36, 38, 39, 50, 51, 62, 63, 71], "obvious": [9, 39, 50, 63], "couldn": [9, 79], "easili": [9, 29, 38, 47, 76], "would": [9, 11, 16], "contribut": 9, "me": [9, 26], "had": [9, 11], "admit": 9, "think": [9, 11, 13, 15, 16, 19, 40], "mere": 9, "meanwhil": [9, 65], "ecmascript": [9, 39], "move": [9, 54, 55], "forward": [9, 39], "rapidli": 9, "caus": [9, 20, 21, 24, 36, 47, 50, 56, 79], "unexpect": [9, 29, 50], "someon": [9, 39], "team": 9, "realiti": 9, "cruel": 9, "unoffici": 9, "v6": 9, "110": 9, "2020": [9, 11], "temporarili": 9, "ve": [9, 11, 40], "j2v8_win32_x86_64": 9, "machin": 9, "cpu": [9, 24, 26, 63], "session": 9, "003": 9, "009": 9, "338": 9, "688": 9, "35": 9, "299": 9, "274": 9, "019": 9, "571": 9, "428": 9, "With": [9, 12, 39, 63], "stick": 9, "devic": [9, 26], "precis": [9, 29, 50], "mini": 9, "macbook": 9, "air": 9, "too": [9, 16, 39], "plan": 9, "bui": 9, "futur": 9, "donat": [9, 26], "joke": 9, "intend": [9, 12], "tl": 9, "dr": 9, "rel": 9, "easi": [9, 12, 26, 28, 50, 53, 63, 68, 73], "master": [9, 51], "didn": 9, "213": 9, "solvabl": 9, "revisit": 9, "remov": [9, 54, 55, 56, 57], "earli": [9, 41], "haven": 9, "got": [9, 11], "reviv": 9, "v2": [9, 52, 71], "far": 9, "lowest": [9, 71], "my": [9, 26], "eclips": 9, "plai": [9, 37, 39, 51, 63, 65], "hei": 9, "satisfi": 9, "luck": 9, "understand": 9, "suffer": 9, "nowadai": 9, "2019": [9, 59], "cmakelist": 9, "txt": 9, "still": [9, 40, 47, 50, 62, 79], "2015": [9, 39], "ag": 9, "surpris": 9, "deepli": 9, "gone": [9, 25], "step": [9, 12, 25, 27, 30, 32, 36, 38, 39, 50, 62, 66, 69, 72, 73], "sit": 9, "watch": 9, "break": [9, 29, 39, 50, 51, 63, 73], "made": [9, 11, 40], "full": [9, 24, 41, 50], "thought": [9, 11], "month": [9, 11], "pai": [9, 79], "python2": 9, "form": [9, 50], "outer": 9, "layer": [9, 79], "who": [9, 39], "spend": 9, "preciou": 9, "wish": [9, 79], "hair": 9, "guido": 9, "van": 9, "rossum": 9, "am": [9, 32, 50], "problemat": 9, "At": [9, 11, 50], "hack": [9, 12, 25], "pom": [9, 57], "xml": [9, 57], "uncertainti": 9, "someth": [9, 50], "roi": 9, "suppos": [9, 31, 36, 51], "sai": [9, 28], "x": [9, 26, 27, 30, 32, 39, 50, 52, 67], "later": [9, 11, 39], "255": [9, 38, 53, 66], "permiss": 9, "realli": [9, 51], "local": [9, 28, 38, 50], "histori": [10, 11, 19, 79], "j2v8": [10, 11, 12, 19, 77, 78], "motiv": [10, 19, 79], "find": [11, 50, 62], "compel": 11, "slowli": 11, "dy": 11, "sometim": [11, 24, 27, 28, 29, 32, 38, 40, 50, 51, 62], "lower": [11, 40], "cost": 11, "might": [11, 36, 40], "learn": [11, 15], "lot": [11, 68], "manual": [11, 17, 32], "end": [11, 32, 38, 41, 50, 69], "abl": [11, 12, 21, 25, 29, 39, 40, 47, 50, 65, 79], "write": [11, 28, 29, 38, 79], "inde": [11, 41], "folk": [12, 39], "migrat": [12, 26, 77], "experienc": 12, "perspect": [12, 38], "noth": 12, "globalthi": [12, 39, 79], "mix": 12, "longer": [12, 29, 32, 38, 41, 79], "getglobalobject": [12, 27, 28, 30, 32, 39, 47, 50, 51, 62, 63, 65, 66, 67, 68, 72, 75, 79], "top": [12, 39, 50, 79], "level": [12, 29, 37, 50], "globalobject": [12, 50], "invok": [12, 28, 54], "involv": 12, "common": [12, 17], "where": [12, 13, 19, 36, 39, 40, 63, 79], "thing": [12, 29, 30, 38, 39], "offer": [12, 14, 38], "builder": 12, "check": [12, 37, 39, 50, 55, 79], "ast": [12, 26], "scope": [12, 16, 38, 58], "duplic": 12, "regist": [12, 25, 39, 41, 44, 50, 58, 60, 62, 68, 72, 79], "decor": [12, 50, 55, 72, 79], "v8function": [12, 50, 51, 55, 56, 62], "v8properti": [12, 50, 54, 55, 56, 79], "back": [12, 29, 32, 38, 39, 50, 52], "leakag": [12, 44], "lifecycl": [12, 38, 41, 50], "convers": [12, 27, 29, 58, 67], "handl": [12, 25, 28, 32, 37, 39, 51, 55, 57, 68], "everyth": [12, 62], "goe": [12, 50], "smoothli": [12, 29], "experi": [12, 25, 32, 36, 39, 67, 68, 73], "littl": [12, 30], "bit": [12, 30, 38, 39], "spring": [12, 26, 53, 70, 77], "framework": [12, 76], "most": [12, 37, 39, 41, 50], "cover": [12, 28, 30, 38, 79], "express": [12, 32, 65, 71], "effect": [12, 36, 38, 39, 65], "basic": [14, 26, 31, 50, 68, 75, 77, 79], "absent": [14, 37, 50], "settimeout": [14, 65, 75, 79], "setinterv": [14, 65, 75], "javenod": [14, 15, 26, 51, 71, 75, 79], "extens": [14, 50, 68], "aim": [14, 39, 75, 79], "simul": [14, 39, 50, 75, 79], "singleton": 16, "fine": [16, 26, 29], "noderuntim": [16, 39, 54, 57, 65, 69, 74], "But": [16, 36, 37, 38, 39, 50, 51, 76], "crash": [16, 19, 21, 23, 36, 37, 50, 56, 59, 61], "serv": 16, "agent": 16, "check_eq": 16, "start_io_thread_async_initi": 16, "exchang": 16, "std": 16, "atomic_bool": 16, "flip": 16, "again": [16, 32, 36], "trigger": [16, 37, 38, 50], "workaround": [16, 39], "inevit": 16, "hacki": 16, "fundament": [16, 46, 76], "instead": [16, 29, 37, 38, 39, 40, 54, 59, 67, 79], "distribut": [17, 24, 57, 61, 71], "eg": 17, "18": [17, 56, 60, 71], "reli": [17, 38, 46, 62, 63, 76], "advanc": [17, 26, 51, 77], "chain": [17, 38], "download": [17, 39], "drive": [17, 39], "prepar": [17, 36, 39, 40, 50, 68], "sudo": [17, 39], "apt": [17, 39], "y": [17, 27, 30, 32, 67], "essenti": 17, "softwar": 17, "properti": [17, 29, 30, 32, 63, 71, 72, 76], "ppa": 17, "toolchain": 17, "altern": [17, 30], "90": 17, "slave": 17, "gcov": 17, "80": 17, "70": 17, "config": [17, 32, 46], "choic": [17, 26], "select": [17, 38, 50], "prioriti": [17, 56], "statu": [17, 47, 52], "effort": [17, 47, 71], "commit": [17, 24, 71], "background": [19, 26, 51], "troubleshoot": [19, 26, 33], "dynam": [19, 23, 26, 36, 40, 50, 54, 61], "routin": [19, 23, 39], "sigsegv": [19, 23], "createv8runtim": [19, 23, 26, 28, 39, 40, 47, 62, 63, 65, 69, 72, 73, 74], "aw": [19, 23, 38], "being": [19, 23, 32, 38, 39, 47, 50], "failur": [20, 56], "happen": [20, 25, 29, 32, 38, 51], "root": [20, 24, 28, 38, 39, 40], "napi": [20, 39], "symbol": [20, 27, 30, 32, 39, 44, 55, 57, 60], "cannot": [20, 29, 37, 38, 39, 40], "found": [20, 39, 44, 75], "modular": [20, 35, 41, 79], "By": [21, 36, 38, 72], "reduc": [21, 40], "relat": [21, 50], "attempt": 21, "meet": [24, 29, 39], "import": [24, 25, 46, 47, 51, 71, 79], "enum": 24, "jsruntimetyp": [24, 36, 39, 74, 76], "interop": [24, 26, 64, 77], "ijavetengin": [24, 39, 47, 68, 74, 75], "javetenginepool": [24, 39, 46, 54, 56, 68, 74, 76], "util": [24, 32], "arraylist": [24, 27, 30, 67], "public": [24, 28, 30, 32, 36, 46, 50, 51, 57, 62, 63, 65, 72, 75, 76], "class": [24, 28, 30, 39, 46, 50, 62, 63, 65, 72, 76], "testcrash": 24, "void": [24, 28, 30, 32, 46, 50, 51, 62, 63, 65, 72, 75], "throw": [24, 28, 29, 32, 39, 47, 50, 51, 63, 65, 75], "except": [24, 28, 32, 37, 38, 39, 41, 46, 47, 50, 54, 56, 57, 63, 79], "int": [24, 28, 30, 31, 32, 40, 47, 50, 63, 65, 72], "threadcount": 24, "length": [24, 27, 28, 30, 32, 38, 40], "integ": [24, 30, 31, 32, 38, 49, 50, 65], "parseint": 24, "println": [24, 26, 39, 62, 63, 65, 66, 67, 69, 72, 73], "els": [24, 28, 39, 50, 51, 63, 65, 71, 75, 79], "threadlist": 24, "enginepool": 24, "getconfig": [24, 32, 39, 62, 74], "setjsruntimetyp": [24, 39, 74, 76], "getengin": [24, 39, 47, 68, 74], "reach": [24, 29, 44], "catch": [24, 28, 47, 50, 51, 65, 73], "throwabl": [24, 46, 73], "printstacktrac": [24, 28, 47, 65], "err": [24, 73], "join": [24, 32, 62], "peacefulli": 24, "seem": 24, "protect": [24, 28, 37, 46, 47, 76], "specif": [24, 38, 51], "26": [24, 26, 56, 57, 61], "occur": [24, 25, 29, 32, 38], "small": 24, "forc": [24, 25, 32, 41, 68], "v8host": [24, 26, 28, 36, 38, 39, 40, 47, 54, 55, 56, 62, 63, 65, 69, 72, 73], "getv8inst": [24, 26, 38, 39, 47, 62, 63, 69, 72, 73, 74], "trick": [24, 65], "threadisol": 24, "fedora": 24, "kvm": 24, "cycl": [24, 38], "ensur": [24, 62], "patch": [24, 52, 61], "consum": [24, 49], "linx": 24, "kernel": 24, "user": [25, 29, 32, 39, 46, 68, 73, 76], "segfault": [25, 79], "82": 25, "loop": [25, 47, 51, 65, 73], "exit": [25, 73], "see": [25, 37, 39, 62, 63, 74], "hand": 25, "yet": 25, "resolv": [25, 32, 39, 40, 65, 79], "reject": [25, 41, 55], "land": 25, "lead": [25, 40, 41], "corrupt": 25, "peopl": [25, 79], "mostli": 25, "genuin": 25, "prevent": [25, 36, 38, 41], "fact": [25, 51], "won": [25, 29, 36], "standard": [25, 39, 59], "hit": [25, 47], "explicitli": [25, 32, 36, 38, 41, 68], "garbag": [25, 32, 36, 38, 62], "collect": [25, 27, 30, 36, 48, 53], "eight": 26, "awesom": [26, 74], "star": 26, "medium": 26, "blogspot": 26, "channel": 26, "discord": [26, 79], "retir": 26, "mail": 26, "great": 26, "thank": 26, "arm64": [26, 59, 61, 71], "v20": [26, 52, 61], "285": [26, 61], "prefer": 26, "polyfil": [26, 70, 77, 79], "exposur": [26, 53], "bigint": [26, 31, 38, 53], "date": [26, 31, 39, 53], "live": [26, 37, 38, 50], "analysi": [26, 39], "javetsanit": 26, "groupid": [26, 32, 71], "artifactid": [26, 32, 71], "getnodeinst": [26, 28, 38, 65, 69, 74], "getexecutor": [26, 27, 28, 30, 32, 39, 40, 47, 49, 50, 51, 62, 63, 65, 66, 67, 68, 69, 72, 73, 75], "executestr": [26, 27, 30, 32, 39, 50, 62, 66, 67, 69, 75], "hivemq": 26, "apach": 26, "graalj": [26, 32], "nashorn": 26, "elegantli": [26, 62, 63], "jsonnod": [26, 64, 77], "compromis": 26, "typescript": 26, "intro": 26, "tutori": [26, 62], "convert": [26, 33, 44, 50, 54, 56, 57, 62, 63, 64, 66, 77, 79], "todo": [26, 33], "note": [26, 32, 38, 39, 50], "javetproxyconvert": [27, 29, 38, 55, 56, 62, 63, 66, 79], "skip": [27, 29, 32, 55], "proxi": [27, 30, 56, 57, 61, 62, 63], "primit": [27, 28, 29, 30, 32, 41, 50, 53, 56, 57], "annoi": 27, "variabl": [27, 37, 39, 50, 56, 66, 67, 72], "accid": 27, "javetbridgeconvert": [27, 38, 56], "ident": [27, 39, 50, 72], "setconvert": [27, 28, 32, 62, 63, 66], "btrue": 27, "bfals": 27, "asserttru": [27, 32, 39, 40, 47, 49, 50, 51], "executeobject": [27, 32, 62, 66, 67], "assertfals": [27, 32, 39, 47, 49, 50], "assertequ": [27, 30, 32, 39, 40, 47, 49, 50], "tov8valu": [27, 28, 63], "executeinteg": [27, 30, 32, 39, 40, 47, 50, 62, 69], "toprimit": 27, "12345": 27, "12346": 27, "intarrai": 27, "assertarrayequ": [27, 32], "iter": [27, 32, 60], "integerlist": 27, "executevoid": [27, 28, 32, 39, 40, 47, 50, 62, 63, 65, 66, 67, 68, 72, 75], "longlist": 27, "unmodifiablelist": 27, "aslist": [27, 50], "1l": 27, "2l": 27, "stringifi": [27, 32, 67], "implicit": [27, 79], "given": [27, 38], "give": [27, 29, 38, 47, 50, 62], "ab": 27, "implicitli": [27, 56], "besid": [27, 50], "power": [28, 40], "simpl": [28, 32, 36, 38, 39, 40, 46, 50, 63, 65, 74], "about": [28, 37], "reflect": [28, 30, 32, 41, 50, 60], "tweak": 28, "pair": [28, 50], "null": [28, 30, 32, 39, 50, 51, 65, 72, 73], "getnam": [28, 30, 72, 76], "return": [28, 29, 30, 32, 36, 38, 39, 41, 47, 50, 51, 54, 63, 65, 66, 67, 72, 76], "setnam": [28, 30, 72], "getvalu": [28, 30, 49, 50, 63, 72], "setvalu": [28, 30, 50, 72], "Then": 28, "recurs": [28, 29, 55], "parent": [28, 41], "overrid": [28, 32, 36, 46, 50, 51, 63], "depth": [28, 29, 44, 55], "argument": [28, 30, 40, 79], "circular": [28, 44, 55], "structur": [28, 44, 55, 63], "increment": [28, 63], "suppresswarn": 28, "uncheck": 28, "extend": [28, 32, 39, 50], "javetobjectconvert": [28, 29, 30, 55, 79], "method_prefix_get": 28, "method_prefix_i": 28, "excluded_method": 28, "hashset": [28, 30, 50], "getmethod": [28, 50], "getparametercount": 28, "methodnam": [28, 44, 50], "startswith": 28, "v8valu": [28, 29, 51, 54, 55, 57, 63, 67, 73, 79], "javetexcept": [28, 50, 51, 63, 65, 75], "super": [28, 63], "isundefin": 28, "objectclass": 28, "getclass": 28, "v8valueobject": [28, 32, 38, 39, 50, 55, 57, 72, 75, 79], "createv8valueobject": [28, 38, 39, 50, 72], "canaccess": 28, "propertynam": 28, "contain": [28, 32, 39, 41, 50], "substr": 28, "tolowercas": 28, "v8valuetemp": 28, "line": [28, 37, 50, 73], "testpojo": 28, "pojoarrai": 28, "tom": 28, "ceo": 28, "jerri": 28, "cfo": 28, "log": [28, 38, 41, 45, 50, 51, 65, 68, 72], "transpar": [28, 32, 50, 79], "autom": [28, 38], "bridg": [29, 56], "arrai": [29, 30, 32, 38, 49, 50, 53], "famou": 29, "topic": [29, 51], "lang": [29, 36, 62], "nullpointerexcept": 29, "luckili": [29, 39], "inject": [29, 32, 36, 38, 40, 44, 50, 51, 55, 62, 63, 79], "javetconverterconfig": [29, 55, 61], "overridden": [29, 36], "differenti": 29, "introduc": [29, 38, 39, 56, 79], "ijavetentityfunct": [29, 30], "ijavetentitymap": [29, 30], "setskipfunctioninobject": 29, "boolean": [29, 30, 31, 36, 40], "setextractfunctionsourcecod": 29, "opportun": 29, "extract": 29, "ineffici": 29, "inconveni": [29, 36], "substanti": 29, "javetconverterexcept": 29, "maximum": 29, "cheap": 29, "unrealist": 29, "number": [29, 31, 38, 39], "stackoverflowerror": 29, "wors": 29, "block": [29, 37, 38, 44, 50, 69], "stack": [29, 50], "overflow": 29, "attack": [29, 47], "drain": [29, 38], "tini": 29, "behavior": [29, 32, 38, 41, 50], "fanci": 29, "read": [29, 38, 40, 44, 51], "setproxymapen": [29, 32], "wherea": [29, 38], "conveni": 29, "bi": [29, 67], "direction": [29, 67], "grain": 29, "worri": [29, 36, 39, 47, 65], "vice": 29, "versa": 29, "open": [30, 32, 41, 62], "subclass": [30, 32, 41, 51], "int8arrai": [30, 38], "char": [30, 31, 50], "doubl": [30, 31, 38, 50], "float64arrai": [30, 38], "float": [30, 31, 38, 50], "float32arrai": [30, 38], "int32arrai": [30, 38], "int64arrai": 30, "short": [30, 31, 38, 50], "int16arrai": [30, 38], "stream": [30, 50, 55, 57], "javetentitysymbol": 30, "ijavetmapp": [30, 55], "hashmap": [30, 67], "uint8arrai": [30, 38], "uint8clampedarrai": [30, 38], "uint16arrai": [30, 38], "uint32arrai": [30, 38], "bigint32arrai": 30, "bigint64arrai": [30, 38], "pojo": 30, "registercustomobject": [30, 55], "alien": 30, "match": [30, 32, 39, 66], "constructor": [30, 32, 56, 62, 75], "signatur": [30, 44, 50], "frommap": 30, "tomap": 30, "touchabl": 30, "easier": 30, "customobject": 30, "put": [30, 32, 41, 63, 67], "getter": [30, 32, 50, 55, 56, 72, 79], "setter": [30, 32, 50, 55, 72, 79], "snippet": [30, 38, 39, 62], "below": [30, 50], "getconvert": 30, "ones": 30, "upon": 30, "registr": [30, 44, 79], "customfrommap": 30, "customtomap": 30, "regular": [30, 37], "v8customobject": 30, "getobject": [30, 32], "assertnotnul": [30, 32, 40, 49], "pro": 30, "con": 30, "intrus": [30, 63], "carri": [30, 79], "inform": 30, "memor": 30, "complic": [30, 39], "relationship": 30, "javetprimitiveconvert": [31, 55, 57], "charact": 31, "biginteg": 31, "zoneddatetim": [31, 57, 58], "optionalint": 31, "optionaldoubl": 31, "optionallong": 31, "fall": 31, "rang": [31, 38], "danger": 32, "touch": [32, 37], "tmp": 32, "executeboolean": [32, 62], "isfil": 32, "isdirectori": 32, "canread": [32, 75], "canwrit": 32, "canexecut": 32, "lowmemorynotif": [32, 50, 51, 54, 62, 63, 68, 72, 79], "setproxylisten": [32, 61], "simplelist": 32, "assertsam": 32, "z": 32, "pop": 32, "tojson": 32, "unshift": 32, "shift": 32, "simplemap": 32, "getownpropertynam": [32, 49], "containskei": 32, "topath": 32, "tostr": [32, 39, 49, 50, 62, 63, 66, 73, 75], "newpath": 32, "toobject": 32, "abc": [32, 36, 50, 62, 66], "setproxyseten": 32, "simpleset": 32, "const": [32, 39, 40, 49, 50, 63, 65, 66, 67, 75], "def": [32, 50, 65], "n": [32, 39, 50, 66], "d": [32, 39, 66], "instanceof": [32, 50, 51, 63], "matcher": [32, 66], "123": [32, 50, 62, 66, 72, 75], "a123": 32, "smart": [32, 38], "javeterrortyp": 32, "assertthrow": 32, "javetexecutionexcept": [32, 39, 56], "field": 32, "should": [32, 47], "writabl": 32, "annot": [32, 50, 55, 62], "autoclos": 32, "ijavetclos": [32, 55], "isassignablefrom": 32, "special": [32, 39, 50], "known": [32, 38], "lambda": [32, 50], "istringjoin": 32, "two": [32, 38], "stringjoin": 32, "hold": [32, 38, 51], "joiner": 32, "getjoin": 32, "setjoin": 32, "v8valuefunct": [32, 39, 50, 54, 55, 65, 75], "orphan": 32, "callabl": 32, "outofmemoryerror": 32, "similar": [32, 41, 68], "enhanc": [32, 50, 54, 55, 56, 57, 60], "istringutil": 32, "hello": [32, 65, 66, 68, 70, 77], "split": 32, "stringutil": 32, "getutil": 32, "setutil": 32, "str": [32, 50], "toarrai": [32, 67], "aussi": 32, "non": [32, 41, 50, 62], "bytebuddi": [32, 58], "alreadi": [32, 44, 51], "referenc": [32, 38, 39], "buddi": [32, 62], "groovi": 32, "javetreflectionobjectfactori": [32, 62], "stai": [32, 36, 65, 79], "dynamicclass": [32, 62], "ijavetanonym": [32, 50, 55, 62], "setreflectionobjectfactori": [32, 62], "getinst": [32, 36, 62], "codestr": [32, 39, 53], "gc": [32, 36, 62, 63, 68, 72], "runfin": [32, 62], "collector": [32, 38, 62], "less": [32, 36], "go": [32, 39, 52], "period": [32, 43], "smartli": 32, "overload": 32, "vararg": [32, 50, 54, 57], "identifi": 32, "alter": 32, "v8allow": [32, 56], "v8block": [32, 56], "ignor": [32, 38, 50, 54], "v8getter": [32, 56], "v8setter": [32, 56], "treat": [32, 36, 38], "allowonli": 32, "blockonli": 32, "alia": 32, "virtual": [32, 39, 57], "document": [36, 50, 55], "assum": [36, 39, 50], "reload": 36, "setlibraryreload": 36, "unloadlibrari": [36, 55], "restor": [36, 50, 61], "prior": 36, "loadlibrari": [36, 55], "unstabl": 36, "risk": [36, 41], "temp": 36, "javetlibload": 36, "setlibloadinglisten": 36, "ijavetlibloadinglisten": [36, 56], "getlibpath": 36, "anywher": 36, "bypass": [36, 50], "isdeploi": 36, "must": [36, 38, 50, 75], "islibinsystempath": 36, "mavin": 36, "plug": 36, "osgi": 36, "repeatedli": 36, "regardless": [36, 37, 41], "unsatisfiedlinkerror": 36, "issuppressingerror": [36, 56], "javetlibloadinglisten": [36, 56], "mechan": [36, 37, 79], "djavet": 36, "unlock": [37, 63], "surround": 37, "v8locker": [37, 41, 53], "locker": 37, "getv8lock": 37, "nest": 37, "thrown": [37, 38, 41, 47, 50], "report": 37, "conflict": [37, 44], "slight": [37, 61], "sensit": [37, 38, 41, 53, 79], "extrem": [37, 50], "50": 37, "granular": [37, 39], "concurr": 37, "scenario": [37, 38, 41, 53, 79], "maxim": [37, 41], "incompat": 37, "chao": 37, "sequenc": 37, "newglobalref": 38, "javaobject": [38, 79], "until": 38, "deleteglobalref": 38, "across": 38, "raw": 38, "categor": 38, "within": 38, "persist": 38, "borrow": [38, 50], "rule": [38, 50], "wrap": 38, "outsid": 38, "setweak": [38, 41], "determin": [38, 50, 55], "javetstandardconsoleinterceptor": [38, 68, 72], "v8scope": [38, 41, 55], "setescap": 38, "getv8scop": 38, "binari": [38, 44, 59], "often": 38, "manipul": [38, 49], "content": [38, 51, 61], "dataview": 38, "format": [38, 39, 44, 50], "nio": 38, "bytebuff": [38, 57], "consid": [38, 50, 63], "idl": 38, "equival": [38, 40, 50], "128": 38, "complement": 38, "sign": 38, "int8_t": 38, "unsign": 38, "octet": 38, "uint8_t": 38, "clamp": 38, "32768": 38, "32767": 38, "int16_t": 38, "65535": 38, "uint16_t": 38, "2147483648": 38, "2147483647": 38, "int32_t": 38, "4294967295": 38, "uint32_t": 38, "38": 38, "1038": 38, "ieee": 38, "point": [38, 39], "digit": 38, "234567": 38, "unrestrict": 38, "324": 38, "10308": 38, "64": [38, 55], "23456789012345": 38, "int64_t": 38, "biguint64arrai": 38, "264": 38, "uint64_t": 38, "testv8valuetypedarrai": 38, "testv8valuedataview": 38, "frequenc": 38, "area": 38, "pace": 38, "zombi": 38, "notifi": [38, 63, 72], "space": 38, "v8notifi": 38, "setmemoryusagethresholdratio": [38, 54], "threshold": 38, "ratio": 38, "enablegcnotif": [38, 54], "ration": 38, "xms64m": 38, "xmx64m": 38, "pressur": [38, 79], "destroi": 38, "curv": 38, "smoother": 38, "exce": 38, "broadcast": 38, "schedul": [38, 56], "affect": 38, "worker": 38, "javetengineconfig": [38, 46, 54, 57, 76], "setautosendgcnotif": [38, 76], "light": 38, "weight": 38, "hint": [38, 50], "task": [38, 51, 54], "queue": [38, 51], "decis": 38, "millisecond": [38, 40, 47, 65], "disregard": 38, "aforement": 38, "noderuntimeopt": [38, 56], "v8_flag": 38, "setallownativessyntax": 38, "setexposegc": 38, "setexposeinspectorscript": 38, "setmaxheaps": 38, "768": 38, "setmaxoldspaces": 38, "setusestrict": 38, "settrackretainingpath": 38, "setcustomflag": 38, "max": [38, 44], "semi": [38, 50], "384": 38, "min": 38, "256": 38, "seal": 38, "modif": 38, "analyz": [38, 39], "getv8heapspacestatist": [38, 56], "getv8heapstatist": [38, 56], "getv8sharedmemorystatist": [38, 56], "esm": 39, "earlier": 39, "commonj": 39, "amd": [39, 63], "getv8runtim": [39, 47, 63, 68, 75], "workingdirectori": 39, "javetosutil": [39, 65, 75], "working_directori": [39, 65, 75], "node_modul": [39, 41, 65, 75], "getnodemodul": 39, "nodemodulemodul": 39, "setrequirerootdirectori": 39, "getlogg": [39, 46, 75], "loginfo": [39, 75], "23": [39, 54, 57, 58, 60, 71, 75], "34": [39, 71, 75], "decim": 39, "__dirnam": 39, "__filenam": 39, "scriptfil": 39, "scriptpath": 39, "scriptstr": 39, "iv8executor": [39, 58], "setresourcenam": 39, "resourcenam": 39, "setmodul": 39, "excit": 39, "potenti": [39, 55, 56], "piec": 39, "sqlite3": 39, "bother": 39, "electron": 39, "approach": [39, 50], "simpler": 39, "node_sqlite3": 39, "napi_create_error": 39, "patchelf": 39, "npm": [39, 65, 75], "node_module_fil": 39, "loadlibraryexw": 39, "unzip": 39, "somewher": 39, "replac": [39, 62, 63], "voluntarili": 39, "compat": [39, 56, 61], "through": [39, 50], "pretti": 39, "backup": 39, "rebuilt": [39, 54], "dumpbin": 39, "win32": 39, "delai": 39, "ex": [39, 40], "00000001": 39, "characterist": 39, "0000000180154a40": 39, "hmodul": 39, "0000000180154818": 39, "tabl": [39, 59], "000000018014f248": 39, "000000018014fa68": 39, "bound": 39, "0000000000000000": 39, "stamp": 39, "0000000180108724": 39, "424b": 39, "napi_create_funct": 39, "0000000180108ab5": 39, "4243": 39, "napi_create_buffer_copi": 39, "1801363d8": 39, "180166610": 39, "index": 39, "6096": 39, "napi_open_escapable_handle_scop": 39, "6072": 39, "napi_get_undefin": 39, "apart": 39, "swc": 39, "gyp": 39, "ppee": 39, "puppi": 39, "profession": 39, "pe": 39, "explor": 39, "cli": 39, "drag": 39, "directory_entry_delay_import": 39, "save": [39, 65], "resolut": [39, 60], "embedd": 39, "relai": [39, 56], "reachabl": 39, "javetbuiltinmoduleresolv": [39, 61], "setv8moduleresolv": 39, "existssync": 39, "getboolean": 39, "capabl": [39, 50, 62, 63], "gain": 39, "order": [39, 49], "launch": [39, 40, 41], "testfrommodul": 39, "assign": [39, 50, 55, 66], "v8modul": [39, 54, 58, 61], "compilemodul": 39, "containsmodul": 39, "getinteg": [39, 47], "heavi": 39, "v8modulereferr": 39, "equal": [39, 50, 53, 67, 73, 75], "compilev8modul": [39, 79], "cach": [39, 53, 57, 58], "propos": 39, "advantag": 39, "tradit": 39, "record": 39, "createv8valuefunct": [39, 50], "createv8modul": [39, 61], "issourcetextmodul": [39, 61], "issyntheticmodul": [39, 61], "invokeinteg": 39, "speed": 40, "popular": 40, "pre": 40, "cook": 40, "meal": 40, "re": [40, 54, 62, 65], "hungri": 40, "deploy": 40, "captur": [40, 73], "primari": 40, "usag": [40, 79], "smaller": 40, "mitig": 40, "harder": 40, "malici": [40, 41, 47], "subset": 40, "suitabl": [40, 72], "v8runtimeopt": [40, 56], "setcreatesnapshoten": [40, 61], "setsnapshotblob": [40, 61], "blob": 40, "snapshotblob1": 40, "snapshotblob2": 40, "createsnapshot": [40, 61], "usabl": 40, "subtract": 40, "technic": [40, 50, 74], "difficulti": 40, "toolkit": 40, "variant": 40, "label": 40, "extra": [40, 79], "1m": 40, "assembli": 40, "direct": 40, "298k": 40, "745k": 40, "28": [40, 55, 58, 61], "previou": [40, 50], "obtain": 41, "pass": [41, 55], "dangl": [41, 59], "ey": 41, "stage": 41, "prohibit": 41, "uncertain": 41, "acquir": [41, 44, 79], "eval": [41, 50], "impact": [41, 50], "unhandl": 41, "whose": 41, "style": 43, "statist": [43, 56], "101": 44, "osnotsupport": 44, "102": 44, "librarynotfound": 44, "103": 44, "librarynotload": 44, "104": 44, "notsupport": 44, "failedtoreadpath": 44, "201": 44, "compilationfailur": 44, "301": 44, "executionfailur": 44, "302": 44, "executiontermin": 44, "termin": [44, 45], "continu": 44, "401": 44, "callbacksignatureparametersizemismatch": 44, "mismatch": 44, "paramet": [44, 50], "expectedparameters": 44, "actualparameters": 44, "402": 44, "callbacksignatureparametertypemismatch": 44, "expectedparametertyp": 44, "actualparametertyp": 44, "403": 44, "callbackinjectionfailur": 44, "404": 44, "callbackregistrationfailur": 44, "405": 44, "callbackmethodfailur": 44, "406": 44, "callbackunknownfailur": 44, "unknown": 44, "407": [44, 55], "callbackunregistrationfailur": 44, "unregistr": 44, "408": [44, 60], "callbacktypenotsupport": [44, 60], "callbacktyp": 44, "501": 44, "converterfailur": 44, "502": 44, "convertercircularstructur": 44, "503": [44, 55], "convertersymbolnotbuiltin": 44, "601": 44, "modulenameempti": 44, "empti": 44, "602": [44, 55], "modulenotfound": 44, "modulenam": 44, "603": [44, 55], "modulepermissiondeni": 44, "deni": 44, "701": 44, "lockacquisitionfailur": 44, "702": 44, "lockreleasefailur": 44, "703": 44, "lockconflictthreadidmismatch": 44, "lockedthreadid": 44, "currentthreadid": 44, "801": 44, "runtimealreadyclos": 44, "802": 44, "runtimealreadyregist": 44, "803": 44, "runtimenotregist": 44, "804": 44, "runtimeleakagedetect": 44, "805": [44, 55], "runtimeclosefailur": 44, "806": [44, 56], "runtimeoutofmemori": 44, "heapstatist": 44, "807": 44, "runtimecreatesnapshotdis": [44, 61], "808": 44, "runtimecreatesnapshotblock": [44, 61], "callbackcontextcount": 44, "referencecount": 44, "v8modulecount": 44, "901": [44, 57], "enginenotavail": [44, 57], "hell": [46, 76], "3rd": [46, 50], "parti": [46, 50], "interfac": [46, 51, 79], "slf4j": 46, "org": [46, 71], "loggerfactori": 46, "myjavetlogg": [46, 76], "isdebugen": 46, "info": [46, 58], "isinfoen": 46, "iswarnen": 46, "javetlogg": 46, "testlogg": 46, "setjavetlogg": [46, 76], "ijavetengineguard": [47, 53], "ijavetenginepool": [47, 68, 76], "guard": 47, "getguard": 47, "10000": 47, "infinit": [47, 73], "javetterminatedexcept": 47, "mark": 47, "iscontinu": 47, "dead": 47, "afterward": [47, 51], "hang": 47, "till": 47, "timeout": [47, 51], "cancel": 47, "monitor": 47, "daemonthread": 47, "isinus": [47, 53], "timeunit": [47, 65], "sleep": [47, 65], "interruptedexcept": [47, 65], "terminateexecut": [47, 53, 79], "var": [47, 50, 65], "greater": 47, "javetengineguard": [47, 54], "interrupt": 47, "disableindebugmod": [47, 54], "enableindebugmod": [47, 54], "getlength": 49, "getsiz": 49, "getkei": 49, "getentri": 49, "foreach": [49, 53, 60], "biconsum": 49, "weakmap": 49, "weakset": 49, "atomicinteg": 49, "v8valueinteg": [49, 50, 63], "getandincr": 49, "popinteg": 49, "preserv": 49, "v8valuestr": [49, 63], "getjsfunctiontyp": [50, 54], "invis": 50, "stori": 50, "closur": 50, "goal": 50, "iv8valueobject": [50, 53, 54, 55, 58, 60], "caller": [50, 51], "scan": 50, "input": [50, 63, 67, 73], "receiv": [50, 51, 55, 63], "functioncallbackreceiv": 50, "tricki": 50, "charm": 50, "generatearraywithconvert": 50, "intrud": 50, "untouch": 50, "situat": 50, "v8runtimesett": 50, "generatearraywithoutconvert": 50, "declar": [50, 76, 79], "annotationbasedcallbackreceiv": 50, "stringvalu": 50, "getstringvalu": 50, "setstringvalu": 50, "echo": 50, "mathadd": 50, "recogn": [50, 63], "v8valuearrai": 50, "createv8valuearrai": 50, "staticecho": 50, "setv8runtim": 50, "tojsonstr": 50, "testopt": 50, "optionalstr": 50, "teststream": 50, "filter": 50, "thisobjectrequir": [50, 55], "specifi": [50, 79], "thisobject": 50, "bodi": [50, 63, 65], "especi": [50, 68, 79], "simpli": [50, 63], "symboltyp": 50, "v8valuesymboltyp": 50, "v8bindingenabl": [50, 55], "disabledfunct": 50, "disabledproperti": 50, "isv8bindingen": 50, "arbitrarymethod": 50, "whether": [50, 55], "refactor": [50, 54, 55, 56, 57], "friendli": [50, 79], "javetreflectionutil": [50, 55], "getmethodnamefromlambda": [50, 55], "getmethodnamesetfromlambda": [50, 55], "firstli": 50, "disabledfunctionset": 50, "supplier": 50, "serializ": 50, "secondli": 50, "est": 50, "tr\u00e8": 50, "bien": 50, "unbind": [50, 55, 79], "unbindproperti": [50, 55, 60], "unbindfunct": [50, 55, 60], "ijavetanonymous1": 50, "testfunct": 50, "testproperti": 50, "ijavetanonymous2": 50, "javetentityfunct": [50, 55], "jsfunctiontyp": 50, "userdefin": 50, "mockcallbackreceiv": 50, "blank": 50, "iscal": 50, "happi": 50, "mirror": 50, "anonym": [50, 62], "getsourcecod": [50, 54], "setsourcecod": [50, 54], "sourcecod": 50, "existingsourcecod": 50, "startposit": 50, "endposit": 50, "getposit": 50, "newsourcecod": 50, "setposit": 50, "len": 50, "radic": 50, "rough": 50, "layout": 50, "remain": 50, "accordingli": 50, "invoc": 50, "pseudo": [50, 51, 65], "originalsourcecod": 50, "getjsscopetyp": 50, "isclass": 50, "indic": 50, "callvoid": [50, 65], "isfunct": 50, "incorrect": 50, "malform": 50, "keyword": 50, "discard": 50, "createv8valuestr": [50, 54], "toclon": [50, 58], "abov": 50, "intvalu": 50, "valueof": 50, "createv8valueinteg": [50, 63], "safeti": 50, "sentenc": [50, 79], "belong": 50, "prototyp": 50, "combin": 50, "func": 50, "callobject": 50, "callprimit": 50, "callasconstructor": [50, 53, 75], "itself": 50, "invokevoid": [50, 63], "invokeobject": [50, 66], "invokeprimit": 50, "despit": 50, "deficit": 50, "quot": 50, "getcontext": [50, 56], "setcontext": 50, "copyscopeinfofrom": [50, 58], "anoth": [50, 62, 75], "setscriptsourc": [50, 58], "lexic": 50, "jsfunction": 50, "ecma": 50, "262": 50, "speak": 50, "parallel": 50, "slot": 50, "scope_info": 50, "describ": 50, "lookup": 50, "presenc": 50, "scopeinfo": [50, 58], "hascontextextensionslot": 50, "search": 50, "purpos": 50, "henc": 50, "sloppi": 50, "inner": [50, 56], "fast": 50, "harmoni": 50, "scriptcontext": 50, "rather": 50, "functioncontext": 50, "gather": 50, "scriptcontextt": 50, "toler": 50, "natur": [50, 51], "strongli": [50, 63], "conform": 50, "throughout": 50, "samplewithoutthi": 50, "samplewiththi": 50, "excess": 50, "behav": 50, "redund": 50, "fill": 50, "review": [50, 51], "due": 51, "multi": [51, 68, 79], "friend": 51, "iv8valuepromis": [51, 58], "ownership": 51, "chart": 51, "v8valuepromis": [51, 54, 55], "icallback": 51, "oncatch": 51, "v8valueerror": 51, "onfulfil": 51, "fulfil": 51, "onreject": 51, "manner": [51, 79], "filecont": 51, "filepath": 51, "v8valuepromiseresolv": 51, "createv8valuepromis": 51, "getpromis": 51, "getfilecont": 51, "getfilepath": 51, "createv8valueundefin": 51, "print": [51, 67, 73], "rais": 51, "setpromiserejectcallback": 51, "ijavetpromiserejectcallback": 51, "unhandledreject": 51, "handi": 51, "mainstream": 52, "v11": [52, 71], "mainten": [52, 55], "v18": [52, 59, 60], "v10": [52, 61], "v16": [52, 57], "v9": [52, 71], "v0": [52, 53, 54, 55, 71, 79], "v14": [52, 54, 55], "critic": 52, "bug": [52, 54, 56, 57, 58, 59, 60, 79], "deprec": [53, 54], "v8valueweakmap": 53, "v8valueweakset": 53, "setfunct": [53, 54], "functionnam": 53, "strictequ": 53, "samevalu": 53, "iv8valu": [53, 54, 58], "getidentityhash": 53, "iv8valuerefer": 53, "isdead": 53, "view": 53, "2021": [53, 54, 55, 56, 79], "02": [53, 54, 57, 58], "renam": [54, 55, 58, 60], "ijavetconsum": 54, "ijavetuniconsum": 54, "ijavetuniindexedconsum": 54, "ijavetbiindexedconsum": 54, "v8functioncallback": [54, 60], "bindfunct": [54, 60], "bindproperti": [54, 60], "checkreturnvalu": 54, "organ": 54, "iv8valuefunct": [54, 55, 58], "emit": 54, "univers": 54, "createv8valuedoubl": 54, "createv8valuezoneddatetim": 54, "javeterror": [54, 57, 61], "gcbeforeengineclos": 54, "javetcallbackexcept": 54, "isnullorundefin": 54, "06": [54, 55, 57, 60], "257": 54, "idlenotificationdeadlin": 54, "disablegcnotif": 54, "autosendgcnotif": 54, "javetcallbackcontext": [54, 60], "javetpromiserejectcallback": 54, "allowev": 54, "v8script": [54, 58], "v8bindenabl": 55, "v8virtualescapablevalu": 55, "146": [55, 56], "09": [55, 56, 58, 60, 61], "hasinternaltyp": 55, "isgeneratorobject": 55, "isgeneratorfunct": 55, "isasyncfunct": 55, "v8flag": 55, "v8valuesharedarraybuff": 55, "unregistercustomobject": 55, "javadoc": 55, "08": [55, 57, 60], "31": 55, "345": 55, "v8valuebuiltinsymbol": 55, "getownpropertysymbol": 55, "v8valuebuiltinobject": [55, 61], "createv8valuesymbol": 55, "javetvirtualobject": 55, "javetuniversalproxyhandl": 55, "isclos": 55, "07": [55, 57, 59, 60], "29": [55, 71], "staticclassen": 55, "ownkei": 55, "iv8valueproxi": 55, "v8valueproxi": 55, "gettarget": 55, "gethandl": 55, "isrevok": 55, "revok": 55, "createv8valueproxi": 55, "230": 55, "19": [55, 56], "getprototyp": 55, "setprototyp": 55, "01": [55, 56, 57, 58, 61], "iv8moduleresolv": 55, "nodemoduleprocess": 55, "getvers": 55, "15": [55, 57, 58, 59, 61], "05": [55, 57, 60], "269": 55, "12": [56, 58, 59, 60], "106": 56, "javetcompilationexcept": 56, "convent": 56, "agnost": 56, "getdetailedmessag": 56, "getstack": 56, "javetscriptingerror": 56, "adjust": 56, "capac": 56, "observ": 56, "v8runtimeobserveraveragecallbackcontextcount": 56, "v8runtimeobserveraveragereferencecount": 56, "v8runtimeobserveraveragev8modulecount": 56, "v8convert": 56, "180": 56, "javetoutofmemoryexcept": 56, "awai": 56, "haspendingexcept": 56, "haspendingmessag": 56, "hasscheduledexcept": 56, "promotescheduledexcept": 56, "reportpendingmessag": 56, "addgcepiloguecallback": 56, "addgcprologuecallback": 56, "removegcepiloguecallback": 56, "removegcprologuecallback": 56, "172": [56, 61], "22": [56, 61, 71], "v8intern": 56, "clean": [56, 62], "methodhandl": 56, "cast": 56, "mistakenli": 56, "218": 57, "handler": [57, 65], "132": 57, "improp": 57, "waitforenginemaxretrycount": 57, "174": 57, "pend": [57, 65], "andoird": 57, "v8valuebiginteg": 57, "154": 57, "ispurgeeventloopbeforeclos": 57, "setpurgeeventloopbeforeclos": [57, 65], "124": [57, 72], "03": [57, 58, 59], "139": 57, "115": 57, "createv8valuearraybuff": 57, "177": 57, "r23b": 57, "abi": [57, 59, 71], "libgcc": 57, "libstdc": 57, "cento": 57, "226": 58, "verifynostrongbaseobject": 58, "ilisten": 58, "v8awaitmod": 58, "194": 58, "compilev8valuefunct": 58, "getcacheddata": 58, "iswrap": 58, "getargu": 58, "cacheddata": 58, "v8stringexecutor": 58, "168": 58, "revis": 58, "getscopeinfo": 58, "getownpropertynamestr": 58, "referencecopi": 58, "193": 58, "javetuniversalproxi": 58, "javetdynamicproxi": [58, 60], "javetdynamicobjectfactori": 58, "copycontextfrom": 58, "getscriptsourc": 58, "setsourcecodeopt": 58, "iscompil": 58, "candiscardcompil": 58, "discardcompil": 58, "244": 59, "214": 59, "277": 59, "439": 60, "189": 60, "executor": 60, "nativecontext": 60, "150": 60, "ijavetdirectproxyhandl": [60, 63], "v8virtualiter": 60, "javetproxysymboliterableconvert": 60, "183": 60, "receivecallback": 60, "iv8valuemap": 60, "iv8valuearrai": 60, "batchget": 60, "javetcallbacktyp": 60, "ijavetdirectcal": 60, "redesign": 60, "javetreflectionproxi": 60, "2024": 61, "downgrad": 61, "temporari": 61, "knostdioiniti": 61, "knodefaultsignalhandl": 61, "basejavetconsoleinterceptor": 61, "javetjvminterceptor": [61, 62], "iscreatesnapshoten": 61, "getsnapshotblob": 61, "runtimeopt": 61, "isproxylisten": 61, "arrayutil": 61, "collectionutil": 61, "cdtshell": 61, "267": 61, "169": 61, "freez": 61, "sb": 62, "abc123": 62, "instanti": 62, "meta": 62, "javax": 62, "runnabl": 62, "coupl": 62, "necessari": [62, 68], "dispos": 62, "unregist": [62, 68, 72], "door": [62, 65], "hotfix": [62, 79], "leaf": 63, "elaps": 63, "leverag": 63, "verbos": [63, 79], "testjavaflavor": 63, "round": 63, "isobject": 63, "isint": 63, "asint": 63, "wrapper": 63, "neat": 63, "pure": 63, "testjsflavor": 63, "redirect": [63, 68], "proxyget": 63, "proxyset": 63, "jsonnodewrapp": 63, "requirenonnul": 63, "getjsonnod": 63, "childjsonnod": 63, "v8valueboolean": 63, "propertykei": 63, "propertyvalu": 63, "objectnod": 63, "createv8valueboolean": 63, "testnam": 63, "starttim": 63, "currenttimemilli": 63, "stoptim": 63, "100_000": 63, "interoper": 63, "testscriptjavaflavor": 63, "testscriptjsflavor": 63, "objectmapp": 63, "readtre": 63, "jsonstr": 63, "5950x": 63, "128gb": 63, "22h2": 63, "corretto": 63, "0_282": 63, "19464m": 63, "100000": 63, "5214m": 63, "370": 63, "underli": 63, "spent": 63, "hijack": 65, "seamlessli": 65, "parser": 65, "cooki": 65, "multer": 65, "app": 65, "req": 65, "8991": 65, "testexpress": 65, "codefil": 65, "tofil": 65, "atomicboolean": 65, "serverup": 65, "500": 65, "max_valu": 65, "1000": 65, "awaitmod": 65, "drain_the_task_queu": 65, "pause_the_event_loop": 65, "there_are_more_tasks_in_task_queu": 65, "sleep_a_whil": 65, "resume_the_event_loop": 65, "runonc": 65, "there_are_no_more_task": 65, "timer": 65, "gracefulli": 65, "color": 66, "pink": 66, "awt": 66, "175": 66, "stringarrai": 67, "represent": 67, "stringlist": 67, "assert": 67, "mapx": 67, "mapi": 67, "spawn": 68, "databas": 68, "javetengin": [68, 74], "javetconsoleinterceptor": 68, "famili": 71, "unix": 71, "activebydefault": 71, "operatingsystem": 71, "val": 71, "cpuarch": 71, "getproperti": 71, "ismacosx": 71, "islinux": 71, "aarch64": 71, "cent": 71, "glibc": 71, "mission": 71, "imposs": 71, "guess": 72, "increaseandget": 72, "testintercept": 72, "delta": 72, "testinterceptor": 72, "76": 72, "200": 72, "scanner": 73, "nextlin": 73, "getmessag": 73, "highlight": 74, "javetenginepoo": 74, "l": 74, "loadj": 75, "decimaljsfil": 75, "getabsolutepath": 75, "logerror": 75, "v8valuefunctiondecim": 75, "v8valueobjectdecim": 75, "45": 75, "hasownproperti": 75, "getstr": 75, "bigdecim": 75, "lack": [75, 79], "bean": 76, "propertysourc": 76, "classpath": 76, "configurationproperti": 76, "prefix": 76, "myjavetengineconfig": 76, "javetenginepoolnod": 76, "getjavetenginepoolnod": 76, "javetengineconfignod": 76, "setallowev": 76, "setdefaultengineguardtimeoutmilli": 76, "setengineguardcheckintervalmilli": 76, "setpooldaemoncheckintervalmilli": 76, "setpoolidletimeoutsecond": 76, "setpoolmins": 76, "setpoolmaxs": 76, "setpoolshutdowntimeoutsecond": 76, "setresetenginetimeoutsecond": 76, "javetenginepoolv8": 76, "getjavetenginepoolv8": 76, "javetengineconfigv8": 76, "frequent": 79, "ask": 79, "question": 79, "jan": 79, "publish": 79, "smooth": 79, "took": 79, "week": 79, "abandon": 79, "hierarchi": 79, "inconsist": 79, "repeat": 79, "attent": 79, "mental": 79, "role": 79, "inherit": 79, "liter": 79, "richer": 79, "v8valueprimit": 79, "v8data": 79, "consist": 79, "rich": 79, "pain": 79, "imper": 79, "never": 79, "deliv": 79, "elimin": 79, "rid": 79, "everywher": 79, "shut": 79, "success": 79}, "objects": {}, "objtypes": {}, "objnames": {}, "titleterms": {"build": [0, 1, 2, 9], "javet": [0, 1, 2, 4, 6, 7, 12, 17, 22, 26, 36, 37, 39, 40, 56, 68, 69, 73, 79], "environ": [0, 2, 18, 24, 36], "linux": [0, 1, 2, 9, 17, 39, 71], "maco": 0, "window": [0, 1, 2, 9, 39, 71], "android": [0, 1, 2, 56, 71], "variabl": [0, 24, 36], "v8": [0, 1, 4, 6, 14, 24, 38, 39, 48, 49, 50, 51, 53, 54, 55, 56, 57, 58, 59, 60, 61, 63, 69, 74, 75, 79], "featur": [0, 26, 32], "flag": 0, "from": [1, 12, 30, 31, 36, 38, 79], "scratch": 1, "prepar": [1, 27, 32, 66], "arm64": [1, 2, 56], "x86_64": [1, 55], "mac": [1, 55, 56, 71], "o": [1, 55, 56, 71], "why": [1, 9, 16, 25, 44, 50, 79], "patch": [1, 39], "node": [1, 3, 4, 6, 8, 16, 25, 39, 41, 54, 56, 58, 65, 69, 74, 75, 79], "j": [1, 3, 4, 6, 8, 16, 25, 39, 41, 54, 56, 58, 63, 65, 69, 74, 75, 79], "jni": 1, "librari": [1, 20, 36, 56], "docker": 2, "hub": 2, "github": 2, "express": 2, "full": 2, "multi": [2, 4, 55], "stage": 2, "all": 2, "one": 2, "file": [2, 32, 36], "deprec": 2, "debug": [3, 22, 47, 53], "chrome": [3, 22], "develop": [3, 5, 8, 13], "tool": [3, 8], "cdt": 3, "shell": [3, 73], "1": [3, 24, 37, 38, 46, 53, 54, 55, 56, 57, 58, 59, 60, 61, 65, 69], "run": 3, "2": [3, 24, 37, 38, 46, 50, 53, 54, 55, 56, 57, 58, 59, 60, 61, 63, 65], "script": 3, "3": [3, 8, 38, 53, 54, 55, 56, 57, 58, 59, 60, 61, 65], "open": 3, "4": [3, 53, 54, 55, 56, 57, 58, 60], "usual": 3, "intern": [3, 39], "handshak": 3, "custom": [3, 28, 30, 32, 36, 56], "faq": [3, 19], "doe": [3, 29, 30, 32, 37], "support": [3, 17, 21], "mode": [3, 4, 6, 14, 16, 24, 32, 37, 39, 47, 69, 74, 75], "i": [3, 11, 16, 22, 50, 65], "There": 3, "live": [3, 53], "demo": 3, "design": [4, 28], "architectur": 4, "primit": [4, 31, 54, 79], "refer": [4, 33, 34, 38], "type": [4, 50, 79], "v": [4, 6, 50], "modul": [4, 39, 54, 55, 79], "requir": 4, "import": [4, 39, 50], "virtual": [4, 37], "engin": [4, 41, 47, 53, 68], "pool": [4, 41, 47, 68, 74], "isol": 4, "context": [4, 50], "intercept": [4, 12, 50, 54, 72], "cross": 4, "platform": 4, "process": [4, 55], "safeti": [4, 29, 37], "memori": [4, 38], "leak": 4, "detect": 4, "perform": [6, 37], "comparison": [6, 29, 37, 50], "highlight": [6, 30], "java": [6, 27, 30, 31, 50, 55, 63, 66], "wasm": 6, "benchmark": 6, "improv": 6, "test": [7, 12, 63, 72], "jdk": 8, "intellij": 8, "gradl": [8, 26, 71], "maven": [8, 9, 26, 71], "option": [8, 38], "visual": 8, "studio": 8, "commun": 8, "2022": 8, "python": 8, "8": [8, 54, 55, 57, 58, 61], "histori": 9, "j2v8": [9, 79], "issu": 9, "latest": 9, "version": 9, "onli": 9, "autom": 9, "system": [9, 38], "deploi": [9, 36], "repositori": 9, "background": [10, 25], "what": [11, 37, 50, 65], "motiv": [11, 68], "how": [12, 27, 30, 32, 38, 40, 47, 50, 65], "think": 12, "v8runtim": [12, 38, 79], "v8valueglobalobject": 12, "executor": 12, "execut": 12, "declar": [12, 54], "function": [12, 29, 32, 50, 54, 55], "properti": [12, 50, 54, 55], "learn": 12, "unit": 12, "where": [14, 15], "ar": [14, 15], "es6": [14, 79], "api": [14, 34], "exampl": [15, 39, 51], "inspector": 16, "disabl": [16, 50], "can": [17, 21, 22, 29, 36, 50], "legaci": 17, "A": 20, "dynam": [20, 32, 39, 62], "link": 20, "dll": 20, "initi": [20, 24], "routin": 20, "fail": 20, "i18n": 21, "devtool": 22, "troubleshoot": [23, 45], "sigsegv": 24, "createv8runtim": 24, "aw": 24, "symptom": 24, "analysi": 24, "solut": [24, 25], "enforc": 24, "set": [24, 32, 50], "javet_disable_pku": 24, "crash": 25, "when": [25, 29], "being": 25, "close": [25, 65], "root": 25, "caus": 25, "event": [25, 54], "unhandledreject": 25, "noderuntim": 25, "await": [25, 38], "lowmemorynotif": [25, 38], "major": 26, "quick": 26, "start": 26, "depend": [26, 71], "kotlin": [26, 71], "dsl": [26, 71], "groovi": [26, 71], "hello": [26, 69], "sponsor": 26, "licens": 26, "blog": 26, "document": 26, "bridg": 27, "convert": [27, 28, 29, 30, 31, 32, 55, 67], "usag": [27, 30, 32, 38, 49, 68, 74], "boolean": [27, 50], "int": 27, "arrai": [27, 67], "integ": 27, "list": [27, 32, 43, 67], "long": [27, 38], "unmodifi": 27, "string": [27, 50], "cast": 27, "object": [27, 28, 29, 30, 32, 50, 62, 67], "javascript": [27, 30, 31, 50, 65, 66], "pojo": 28, "defin": [28, 50], "creat": [28, 40], "pojoconvert": 28, "readi": 28, "go": 28, "insid": 29, "bind": [29, 50], "via": [29, 40], "nativ": [29, 36, 39, 54], "proxi": [29, 32, 55], "null": 29, "circular": 29, "structur": 29, "config": 29, "take": [29, 36], "effect": 29, "built": [29, 39], "ignor": 29, "regist": [30, 51], "enhanc": 30, "It": 30, "work": [30, 32, 40], "instanc": 32, "map": [32, 50, 67], "path": 32, "static": [32, 66], "stringbuild": [32, 62, 66], "pattern": [32, 66], "enum": [32, 66], "interfac": [32, 55, 62], "anonym": [32, 55], "class": [32, 66], "v8convert": 32, "v8properti": [32, 72], "name": 32, "v8function": [32, 72, 79], "javetproxyconvert": 32, "resourc": [35, 38, 41, 50], "manag": [35, 38, 41, 50], "load": [36, 39, 56], "unload": 36, "On": [36, 39], "demand": [36, 39], "locat": 36, "deploy": 36, "skip": 36, "alreadi": 36, "anoth": 36, "classload": [36, 55], "suppress": 36, "lib": 36, "listen": 36, "remov": 36, "jar": 36, "know": 37, "lock": 37, "mean": 37, "implicit": 37, "explicit": 37, "thread": [37, 41, 65], "coroutin": 37, "challeng": 38, "jvm": [38, 62], "gc": [38, 54], "c": 38, "runtim": 38, "recommend": 38, "automat": [38, 47, 50], "try": 38, "weak": 38, "escap": 38, "without": 38, "altern": 38, "arraybuff": 38, "passiv": 38, "aggress": 38, "manual": [38, 39, 47, 50], "idlenotificationdeadlin": 38, "deadlineinmilli": 38, "runfin": 38, "v8flag": 38, "statist": 38, "modular": 39, "gap": 39, "between": 39, "deal": 39, "elf": 39, "rebuild": 39, "pre": 39, "synthet": 39, "snapshot": 40, "benefit": 40, "limit": 40, "mksnapshot": 40, "best": 41, "practic": 41, "secur": 41, "tip": [42, 50], "todo": 43, "error": [44, 54], "code": [44, 50, 54], "backward": 44, "compat": [44, 71], "log": 46, "step": [46, 65], "implement": 46, "ijavetlogg": 46, "inject": [46, 66, 76], "logger": 46, "termin": 47, "about": [47, 50], "valu": [48, 50], "collect": 49, "v8valuearrai": 49, "v8valueset": 49, "v8valuemap": 49, "registr": 50, "convers": [50, 54, 79], "thi": 50, "pass": 50, "symbol": 50, "unregist": 50, "both": 50, "One": 50, "bindfunct": 50, "functionnam": 50, "javetcallbackcontext": 50, "kei": 50, "v8valu": 50, "codestr": 50, "mismatch": 50, "summari": [50, 62], "chang": 50, "user": 50, "fly": 50, "sourc": [50, 54], "call": 50, "invok": 50, "scope": [50, 55], "info": 50, "avoid": 50, "argument": 50, "handl": 50, "count": 50, "promis": [51, 55], "resolv": [51, 55], "lifecycl": 51, "callback": 51, "f": 51, "readfileasync": 51, "unhandl": 51, "reject": 51, "releas": [52, 53, 54, 55, 56, 57, 58, 59, 60, 61], "note": [52, 53, 54, 55, 56, 57, 58, 59, 60, 61], "0": [53, 54, 55, 56, 57, 58, 59, 60, 61], "7": [53, 54, 55, 56, 57, 58, 60], "x": [53, 54, 55, 56, 57, 58, 59, 60, 61], "locker": 53, "guard": 53, "bug": 53, "fix": 53, "birth": 53, "9": [53, 54, 55, 56, 57, 58, 61], "10": [54, 55, 58], "index": 54, "foreach": 54, "hotfix": 54, "6": [54, 55, 56, 57, 60], "loop": 54, "5": [54, 55, 56, 57, 60], "v9": [54, 55, 56, 57], "first": [54, 56], "time": [54, 56], "14": 55, "13": 55, "12": 55, "privat": 55, "11": 55, "polyfil": [55, 75], "empow": 55, "v2": 55, "v1": 55, "safe": 55, "core": 56, "abi": 56, "21": 56, "v16": 56, "v10": [57, 58], "v11": [58, 59, 60, 61], "v18": 58, "v12": 61, "access": 62, "whole": 62, "plai": 62, "cleanup": 62, "expos": 63, "jsonnod": 63, "approach": 63, "flavor": 63, "direct": 63, "exposur": 63, "wrap": 63, "conclus": 63, "advanc": 64, "interact": 65, "That": 65, "possibl": 65, "server": 65, "worker": 65, "main": 65, "If": 65, "hang": 65, "dure": 65, "interop": 66, "an": 66, "goal": 68, "print": 69, "basic": 70, "instal": 71, "sampl": 72, "co": 74, "exist": 74, "v8host": 74, "decim": 75, "spring": 76, "integr": 76, "configur": 76, "tutori": 77, "migrat": [78, 79], "guid": [78, 79], "registerjavamethod": 79, "v8locker": 79, "bless": 79}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 60}, "alltitles": {"Build Javet": [[0, "build-javet"], [1, "build-javet"], [1, "id1"]], "Build Environment": [[0, "build-environment"], [2, "build-environment"]], "Linux Environment": [[0, "linux-environment"], [2, "linux-environment"]], "MacOS Environment": [[0, "macos-environment"]], "Windows Environment": [[0, "windows-environment"], [2, "windows-environment"]], "Android Environment": [[0, "android-environment"]], "Environment Variables": [[0, "environment-variables"]], "V8 Feature Flags": [[0, "v8-feature-flags"]], "Build Javet from Scratch": [[1, "build-javet-from-scratch"]], "Build V8": [[1, "build-v8"]], "Prepare V8": [[1, "prepare-v8"]], "Build V8 for Linux arm64": [[1, "build-v8-for-linux-arm64"]], "Build V8 for Linux x86_64": [[1, "build-v8-for-linux-x86-64"]], "Build V8 for Mac OS arm64": [[1, "build-v8-for-mac-os-arm64"]], "Build V8 for Mac OS x86_64": [[1, "build-v8-for-mac-os-x86-64"]], "Build V8 for Windows": [[1, "build-v8-for-windows"]], "Build V8 for Android": [[1, "build-v8-for-android"]], "Why Patching V8?": [[1, "why-patching-v8"]], "Build Node.js": [[1, "build-node-js"]], "Prepare Node.js": [[1, "prepare-node-js"]], "Build Node.js on Linux": [[1, "build-node-js-on-linux"]], "Why Patching Node.js?": [[1, "why-patching-node-js"]], "Build Node.js on Mac OS": [[1, "build-node-js-on-mac-os"]], "Build Node.js on Windows": [[1, "build-node-js-on-windows"]], "Build Javet JNI Library for Android": [[1, "build-javet-jni-library-for-android"]], "Build Javet for Linux, Mac OS and Windows": [[1, "build-javet-for-linux-mac-os-and-windows"]], "Build Javet for Android": [[1, "build-javet-for-android"]], "Build Javet with Docker": [[2, "build-javet-with-docker"]], "Docker Hub and Github": [[2, "docker-hub-and-github"]], "Build Javet for Linux on Linux or Windows": [[2, "build-javet-for-linux-on-linux-or-windows"]], "Express Build": [[2, "express-build"]], "Full Build - Multi-staged": [[2, "full-build-multi-staged"]], "Full Build - All-in-one": [[2, "full-build-all-in-one"]], "Build Javet for Windows on Windows": [[2, "build-javet-for-windows-on-windows"]], "Build Javet for Android on Linux or Windows": [[2, "build-javet-for-android-on-linux-or-windows"]], "Linux arm64 Docker Files Deprecated": [[2, "linux-arm64-docker-files-deprecated"]], "Debug with Chrome Developer Tools": [[3, "debug-with-chrome-developer-tools"]], "CDT Shell": [[3, "cdt-shell"]], "1. Run CDT Shell": [[3, "run-cdt-shell"]], "2. Run Script in CDT Shell": [[3, "run-script-in-cdt-shell"]], "3. Open CDT": [[3, "open-cdt"]], "4. Debug as Usual": [[3, "debug-as-usual"]], "Chrome Developer Tools Internals": [[3, "chrome-developer-tools-internals"]], "Handshake": [[3, "handshake"]], "Customization": [[3, "customization"]], "FAQs": [[3, "faqs"]], "Does it Support Node.js Mode?": [[3, "does-it-support-node-js-mode"]], "Is There a Live Demo?": [[3, "is-there-a-live-demo"]], "Javet Design": [[4, "javet-design"]], "Architecture": [[4, "architecture"]], "Primitive and Reference Types in Javet": [[4, "primitive-and-reference-types-in-javet"]], "Node.js Mode vs. V8 Mode": [[4, "node-js-mode-vs-v8-mode"]], "Module": [[4, "module"]], "require() vs. import()": [[4, "require-vs-import"]], "Module Virtualization": [[4, "module-virtualization"]], "Engine Pool": [[4, "engine-pool"]], "V8 Isolate and Context in Javet": [[4, "v8-isolate-and-context-in-javet"]], "Javet Engine Pool": [[4, "javet-engine-pool"], [68, "javet-engine-pool"]], "Interception": [[4, "interception"], [72, "interception"]], "Cross-platform": [[4, "cross-platform"]], "Multi-process Safety": [[4, "multi-process-safety"]], "Memory Leak Detection": [[4, "memory-leak-detection"]], "Development": [[5, "development"], [13, "development"]], "Javet Performance": [[6, "javet-performance"]], "Performance Comparisons of Node.js Mode and V8 Mode": [[6, "performance-comparisons-of-node-js-mode-and-v8-mode"]], "Highlights": [[6, "highlights"], [30, "highlights"]], "Java VS Wasm Benchmarks": [[6, "java-vs-wasm-benchmarks"]], "Javet Performance Improvements": [[6, "javet-performance-improvements"]], "Test Javet": [[7, "test-javet"]], "Development Tools": [[8, "development-tools"]], "JDK": [[8, "jdk"]], "IntelliJ": [[8, "intellij"]], "Gradle": [[8, "gradle"]], "Node.js": [[8, "node-js"], [41, "node-js"]], "Maven (Optional)": [[8, "maven-optional"]], "Visual Studio Community 2022 (Optional)": [[8, "visual-studio-community-2022-optional"]], "Python 3.8+ (Optional)": [[8, "python-3-8-optional"]], "History with J2V8": [[9, "history-with-j2v8"]], "J2V8 Issues": [[9, "j2v8-issues"]], "J2V8 Latest Version": [[9, "j2v8-latest-version"]], "Why Windows and Linux only?": [[9, "why-windows-and-linux-only"]], "Why not Automate the J2V8 Build System?": [[9, "why-not-automate-the-j2v8-build-system"]], "Why not Deploy J2V8 to Maven Repository?": [[9, "why-not-deploy-j2v8-to-maven-repository"]], "Background": [[10, "background"], [25, "background"]], "What is the Motivation?": [[11, "what-is-the-motivation"]], "How to Think in Javet?": [[12, "how-to-think-in-javet"]], "V8Runtime and V8ValueGlobalObject": [[12, "v8runtime-and-v8valueglobalobject"]], "V8Runtime": [[12, "v8runtime"]], "V8ValueGlobalObject": [[12, "v8valueglobalobject"]], "Executor and Execute": [[12, "executor-and-execute"]], "Declarative Function and Property Interception": [[12, "declarative-function-and-property-interception"]], "Learn from Unit Test": [[12, "learn-from-unit-test"]], "Where are ES6 API in V8 Mode?": [[14, "where-are-es6-api-in-v8-mode"]], "Where are the Examples?": [[15, "where-are-the-examples"]], "Why is the Inspector Disabled in Node.js Mode?": [[16, "why-is-the-inspector-disabled-in-node-js-mode"]], "Can Javet Support Legacy Linux?": [[17, "can-javet-support-legacy-linux"]], "Environment": [[18, "environment"]], "FAQ": [[19, "faq"]], "A dynamic link library (DLL) initialization routine failed": [[20, "a-dynamic-link-library-dll-initialization-routine-failed"]], "Can i18n be Supported?": [[21, "can-i18n-be-supported"]], "Can I Debug Javet in Chrome DevTools?": [[22, "can-i-debug-javet-in-chrome-devtools"]], "Troubleshooting": [[23, "troubleshooting"], [45, "troubleshooting"]], "SIGSEGV at createV8Runtime() in V8 Mode on AWS": [[24, "sigsegv-at-createv8runtime-in-v8-mode-on-aws"]], "Symptoms": [[24, "symptoms"]], "Analysis": [[24, "analysis"]], "Solutions": [[24, "solutions"]], "Solution 1: Enforce the Initialization": [[24, "solution-1-enforce-the-initialization"]], "Solution 2: Set Environment Variable JAVET_DISABLE_PKU": [[24, "solution-2-set-environment-variable-javet-disable-pku"]], "Why Node.js Crashes When being Closed?": [[25, "why-node-js-crashes-when-being-closed"]], "Root Cause": [[25, "root-cause"]], "Solution": [[25, "solution"]], "Event unhandledRejection": [[25, "event-unhandledrejection"]], "NodeRuntime.await()": [[25, "noderuntime-await"]], "NodeRuntime.lowMemoryNotification()": [[25, "noderuntime-lowmemorynotification"]], "Javet": [[26, "javet"]], "Major Features": [[26, "major-features"]], "Quick Start": [[26, "quick-start"]], "Dependency": [[26, "dependency"], [71, "dependency"]], "Maven": [[26, "maven"], [71, "maven"]], "Gradle Kotlin DSL": [[26, "gradle-kotlin-dsl"], [71, "gradle-kotlin-dsl"]], "Gradle Groovy DSL": [[26, "gradle-groovy-dsl"], [71, "gradle-groovy-dsl"]], "Hello Javet": [[26, "hello-javet"], [69, "hello-javet"]], "Sponsors": [[26, "sponsors"]], "License": [[26, "license"]], "Blog": [[26, "blog"]], "Documents": [[26, "documents"]], "Bridge Converter": [[27, "bridge-converter"]], "Usage": [[27, "usage"], [30, "usage"], [32, "usage"], [49, "usage"], [68, "usage"], [74, "usage"]], "Preparation": [[27, "preparation"], [32, "preparation"], [66, "preparation"]], "Boolean": [[27, "boolean"]], "int": [[27, "int"]], "int Array": [[27, "int-array"]], "Integer List": [[27, "integer-list"]], "Long Unmodifiable List": [[27, "long-unmodifiable-list"]], "String Array": [[27, "string-array"]], "How to Cast Java Objects to JavaScript Objects?": [[27, "how-to-cast-java-objects-to-javascript-objects"]], "Custom Converter": [[28, "custom-converter"]], "Design a POJO Converter": [[28, "design-a-pojo-converter"]], "Define POJO Object": [[28, "define-pojo-object"]], "Create PojoConverter": [[28, "create-pojoconverter"]], "Ready! Go!": [[28, "ready-go"]], "Converters": [[29, "converters"]], "Comparisons": [[29, "comparisons"], [37, "comparisons"], [50, "comparisons"]], "Inside Converters": [[29, "inside-converters"]], "Binding via Native": [[29, "binding-via-native"]], "Binding via Proxy": [[29, "binding-via-proxy"]], "Null Safety": [[29, "null-safety"]], "Functions and Objects": [[29, "functions-and-objects"]], "Circular Structure": [[29, "circular-structure"]], "When does the Config Take Effect?": [[29, "when-does-the-config-take-effect"]], "Can Built-in Converter be Ignored?": [[29, "can-built-in-converter-be-ignored"]], "Object Converter": [[30, "object-converter"], [67, "object-converter"]], "From Java to JavaScript": [[30, "from-java-to-javascript"], [31, "from-java-to-javascript"]], "From JavaScript to Java": [[30, "from-javascript-to-java"], [31, "from-javascript-to-java"]], "Register Custom Objects": [[30, "register-custom-objects"]], "Enhance the Custom Object": [[30, "enhance-the-custom-object"]], "Register the Custom Object": [[30, "register-the-custom-object"]], "How does It Work?": [[30, "how-does-it-work"]], "Primitive Converter": [[31, "primitive-converter"]], "Proxy Converter": [[32, "proxy-converter"]], "Instance: File": [[32, "instance-file"]], "Instance: List": [[32, "instance-list"]], "Instance: Map": [[32, "instance-map"]], "Instance: Path": [[32, "instance-path"]], "Instance: Set": [[32, "instance-set"]], "Static: StringBuilder": [[32, "static-stringbuilder"]], "Static: Pattern": [[32, "static-pattern"]], "Static: Enum": [[32, "static-enum"]], "Static: Interface": [[32, "static-interface"]], "Dynamic: Anonymous Function": [[32, "dynamic-anonymous-function"]], "Dynamic: Anonymous Object for Interface": [[32, "dynamic-anonymous-object-for-interface"]], "Dynamic: Anonymous Object for Class": [[32, "dynamic-anonymous-object-for-class"]], "Features": [[32, "features"]], "@V8Convert::mode": [[32, "v8convert-mode"]], "@V8Property::name": [[32, "v8property-name"]], "@V8Function::name": [[32, "v8function-name"]], "How does JavetProxyConverter Work?": [[32, "how-does-javetproxyconverter-work"]], "How to Customize JavetProxyConverter?": [[32, "how-to-customize-javetproxyconverter"]], "Reference": [[33, "reference"]], "API Reference": [[34, "api-reference"]], "Resource Management": [[35, "resource-management"], [41, "resource-management"], [50, "resource-management"]], "Load and Unload": [[36, "load-and-unload"]], "Can Javet Native Library be Loaded or Unloaded On-demand?": [[36, "can-javet-native-library-be-loaded-or-unloaded-on-demand"]], "Unload": [[36, "unload"]], "Load": [[36, "load"]], "Can Javet Native Library be Deployed to a Custom Location?": [[36, "can-javet-native-library-be-deployed-to-a-custom-location"]], "Can Javet Native Library Deployment be Skipped?": [[36, "can-javet-native-library-deployment-be-skipped"]], "Can already loaded in another classloader be Suppressed?": [[36, "can-already-loaded-in-another-classloader-be-suppressed"]], "Can Javet Lib Loading Listener Take Environment Variables?": [[36, "can-javet-lib-loading-listener-take-environment-variables"]], "Can Javet Libraries be Removed from the Jar File?": [[36, "can-javet-libraries-be-removed-from-the-jar-file"]], "Know the Lock": [[37, "know-the-lock"]], "What does Lock Mean in Javet?": [[37, "what-does-lock-mean-in-javet"]], "1. Implicit Mode": [[37, "implicit-mode"]], "2. Explicit Mode": [[37, "explicit-mode"]], "Performance": [[37, "performance"]], "Thread-safety": [[37, "thread-safety"]], "Coroutines or Virtual Threads": [[37, "coroutines-or-virtual-threads"]], "Memory Management": [[38, "memory-management"]], "3 Challenges in Memory Management": [[38, "challenges-in-memory-management"]], "JVM GC": [[38, "jvm-gc"]], "C++ Runtime": [[38, "c-runtime"]], "V8 GC": [[38, "v8-gc"]], "Recommended Options": [[38, "recommended-options"]], "Automatic Management with try-with-resource": [[38, "automatic-management-with-try-with-resource"]], "Automatically Manage with Weak Reference": [[38, "automatically-manage-with-weak-reference"]], "How to Escape from try-with-resource?": [[38, "how-to-escape-from-try-with-resource"]], "Usage 1 without V8 Runtime": [[38, "usage-1-without-v8-runtime"]], "Usage 2 with V8 Runtime": [[38, "usage-2-with-v8-runtime"]], "Alternative Option: ArrayBuffer": [[38, "alternative-option-arraybuffer"]], "GC": [[38, "gc"]], "Automatic GC": [[38, "automatic-gc"]], "Passive GC": [[38, "passive-gc"]], "Aggressive GC": [[38, "aggressive-gc"]], "Manual GC": [[38, "manual-gc"]], "V8Runtime.await()": [[38, "v8runtime-await"]], "V8Runtime.idleNotificationDeadline(long deadlineInMillis)": [[38, "v8runtime-idlenotificationdeadline-long-deadlineinmillis"]], "V8Runtime.lowMemoryNotification()": [[38, "v8runtime-lowmemorynotification"]], "System.gc() and System.runFinalization()": [[38, "system-gc-and-system-runfinalization"]], "V8 Options and V8Flags": [[38, "v8-options-and-v8flags"]], "Statistics": [[38, "statistics"]], "Modularization": [[39, "modularization"]], "Node.js Mode": [[39, "node-js-mode"], [75, "node-js-mode"]], "Example": [[39, "example"]], "Gaps between Javet Node.js Mode and Native Node.js": [[39, "gaps-between-javet-node-js-mode-and-native-node-js"]], "Deal with Native Modules": [[39, "deal-with-native-modules"]], "Patch ELF Native Modules on Linux": [[39, "patch-elf-native-modules-on-linux"]], "Rebuild Native Modules on Windows": [[39, "rebuild-native-modules-on-windows"]], "Manual Patch Native Modules on Windows": [[39, "manual-patch-native-modules-on-windows"]], "Dynamically Import Built-in Modules": [[39, "dynamically-import-built-in-modules"]], "V8 Mode": [[39, "v8-mode"], [75, "v8-mode"]], "Pre-load": [[39, "pre-load"]], "On-demand": [[39, "on-demand"]], "Synthetic Module": [[39, "synthetic-module"]], "Internals": [[39, "internals"]], "Snapshot": [[40, "snapshot"]], "How Snapshot Works": [[40, "how-snapshot-works"]], "Benefits": [[40, "benefits"]], "Limitations": [[40, "limitations"]], "How to Create a Snapshot": [[40, "how-to-create-a-snapshot"]], "Create a Snapshot in Javet": [[40, "create-a-snapshot-in-javet"]], "Create a Snapshot via mksnapshot": [[40, "create-a-snapshot-via-mksnapshot"]], "Best Practices": [[41, "best-practices"]], "Thread, Engine and Pool": [[41, "thread-engine-and-pool"]], "Security": [[41, "security"]], "Tips": [[42, "tips"], [50, "tips"]], "TODO List": [[43, "todo-list"]], "Error Codes": [[44, "error-codes"]], "Why Error Codes?": [[44, "why-error-codes"]], "Backward Compatibility": [[44, "backward-compatibility"]], "Logging": [[46, "logging"]], "Step 1: Implement IJavetLogger": [[46, "step-1-implement-ijavetlogger"]], "Step 2: Inject the Logger": [[46, "step-2-inject-the-logger"]], "Termination": [[47, "termination"]], "Automatic Termination with Pool and Engine": [[47, "automatic-termination-with-pool-and-engine"]], "Manual Termination": [[47, "manual-termination"]], "How about Debug Mode?": [[47, "how-about-debug-mode"]], "V8 Values": [[48, "v8-values"]], "V8 Collection": [[49, "v8-collection"]], "Collection in V8": [[49, "collection-in-v8"]], "V8ValueArray": [[49, "v8valuearray"]], "V8ValueSet": [[49, "v8valueset"]], "V8ValueMap": [[49, "v8valuemap"]], "V8 Function": [[50, "v8-function"]], "Function Types": [[50, "function-types"]], "Function Interception": [[50, "function-interception"]], "Automatic Registration": [[50, "automatic-registration"]], "bind()": [[50, "bind"]], "How about Object Type Conversion?": [[50, "how-about-object-type-conversion"]], "Can this be Passed in?": [[50, "can-this-be-passed-in"]], "Can Symbol Properties be Intercepted?": [[50, "can-symbol-properties-be-intercepted"]], "How to Disable Properties or Functions?": [[50, "how-to-disable-properties-or-functions"]], "How to Unregister Properties or Functions?": [[50, "how-to-unregister-properties-or-functions"]], "Can Both JavaScript Function and Property Map to One Java Function?": [[50, "can-both-javascript-function-and-property-map-to-one-java-function"]], "Can 2 Java Functions Map to One JavaScript Function and Property?": [[50, "can-2-java-functions-map-to-one-javascript-function-and-property"]], "Manual Registration": [[50, "manual-registration"]], "boolean bindFunction(String functionName, JavetCallbackContext javetCallbackContext)": [[50, "boolean-bindfunction-string-functionname-javetcallbackcontext-javetcallbackcontext"]], "boolean set(String key, V8Value value)": [[50, "boolean-set-string-key-v8value-value"]], "boolean bindFunction(String functionName, String codeString)": [[50, "boolean-bindfunction-string-functionname-string-codestring"]], "Type Mismatch": [[50, "type-mismatch"]], "Summary": [[50, "summary"], [62, "summary"]], "Change a User Defined JavaScript Function on the Fly": [[50, "change-a-user-defined-javascript-function-on-the-fly"]], "Why is Changing a User Defined JavaScript Function Important?": [[50, "why-is-changing-a-user-defined-javascript-function-important"]], "How to Change a User Defined JavaScript Function on the Fly?": [[50, "how-to-change-a-user-defined-javascript-function-on-the-fly"]], "What is the Source Code of a Function in V8?": [[50, "what-is-the-source-code-of-a-function-in-v8"]], "Automatic Type Conversion": [[50, "automatic-type-conversion"]], "Call vs. Invoke": [[50, "call-vs-invoke"]], "Call": [[50, "call"]], "Invoke": [[50, "invoke"]], "How about Bind?": [[50, "how-about-bind"]], "Context and Scope Info": [[50, "context-and-scope-info"]], "How to Avoid Argument Type Mismatches?": [[50, "how-to-avoid-argument-type-mismatches"]], "How to Handle Argument Count Mismatches?": [[50, "how-to-handle-argument-count-mismatches"]], "V8 Promise": [[51, "v8-promise"]], "Promise and Resolver": [[51, "promise-and-resolver"]], "Lifecycle": [[51, "lifecycle"]], "Register a Callback": [[51, "register-a-callback"]], "Example fs.readFileAsync()": [[51, "example-fs-readfileasync"]], "Unhandled Rejection": [[51, "unhandled-rejection"]], "Release Notes": [[52, "release-notes"]], "Release Notes 0.7.x": [[53, "release-notes-0-7-x"]], "0.7.4 Live Debug": [[53, "live-debug"]], "0.7.3 Locker": [[53, "locker"]], "0.7.2 Engine Guard": [[53, "engine-guard"]], "0.7.1 Bug Fixes": [[53, "bug-fixes"]], "0.7.0 Birth with V8 v8.9": [[53, "birth-with-v8-v8-9"]], "Release Notes 0.8.x": [[54, "release-notes-0-8-x"]], "0.8.10 Index in forEach": [[54, "index-in-foreach"]], "0.8.9 Declarative Property Interception": [[54, "declarative-property-interception"]], "0.8.8 Hotfix the Source Code": [[54, "hotfix-the-source-code"]], "0.8.7 Native Modules for Node.js": [[54, "native-modules-for-node-js"]], "0.8.6 Event Loop for Node.js": [[54, "event-loop-for-node-js"]], "0.8.5 Error Codes": [[54, "error-codes"]], "0.8.4 V8 v9.0": [[54, "v8-v9-0"]], "0.8.3 GC": [[54, "gc"]], "0.8.2 Conversion for Primitive": [[54, "conversion-for-primitive"]], "0.8.1 Declarative Function Interception": [[54, "declarative-function-interception"]], "0.8.0 First Time with Node.js": [[54, "first-time-with-node-js"]], "Release Notes 0.9.x": [[55, "release-notes-0-9-x"]], "0.9.14 V8 Scope": [[55, "v8-scope"]], "0.9.13 V8 v9.4": [[55, "v8-v9-4"]], "0.9.12 Private Properties": [[55, "private-properties"]], "0.9.11 V8 v9.3": [[55, "v8-v9-3"]], "0.9.10 Polyfill Java Interfaces": [[55, "polyfill-java-interfaces"]], "0.9.9 Mac OS x86_64": [[55, "mac-os-x86-64"]], "0.9.8 Empower the Promise": [[55, "empower-the-promise"]], "0.9.7 Proxy Converter v2": [[55, "proxy-converter-v2"]], "0.9.6 Proxy Converter v1": [[55, "proxy-converter-v1"]], "0.9.5 V8 v9.2": [[55, "v8-v9-2"]], "0.9.4 Multi-process Safe": [[55, "multi-process-safe"]], "0.9.3 Module Resolver": [[55, "module-resolver"]], "0.9.2 Anonymous Functions in Converter": [[55, "anonymous-functions-in-converter"]], "0.9.1 V8 in Classloader": [[55, "v8-in-classloader"]], "0.9.0 V8 v9.1": [[55, "v8-v9-1"]], "Release Notes 1.0.x": [[56, "release-notes-1-0-x"]], "1.0.7 V8 v9.7": [[56, "v8-v9-7"]], "1.0.6 Mac OS (arm64)": [[56, "mac-os-arm64"]], "1.0.5 Javet Core": [[56, "javet-core"]], "1.0.4 V8 9.6": [[56, "v8-9-6"]], "1.0.3 Android ABI 21": [[56, "android-abi-21"]], "1.0.2 First Time with Android": [[56, "first-time-with-android"]], "1.0.1 Custom Library Loading": [[56, "custom-library-loading"]], "1.0.0 First Time with Node.js v16": [[56, "first-time-with-node-js-v16"]], "Release Notes 1.1.x": [[57, "release-notes-1-1-x"]], "1.1.7 V8 v10.5": [[57, "v8-v10-5"]], "1.1.6 V8 v10.4": [[57, "v8-v10-4"]], "1.1.5 V8 v10.3": [[57, "v8-v10-3"]], "1.1.4 V8 v10.2": [[57, "v8-v10-2"]], "1.1.3 V8 v10.1": [[57, "v8-v10-1"]], "1.1.2 V8 v10.0": [[57, "v8-v10-0"]], "1.1.1 V8 v9.9": [[57, "v8-v9-9"]], "1.1.0 V8 v9.8": [[57, "v8-v9-8"]], "Release Notes 2.0.x": [[58, "release-notes-2-0-x"]], "2.0.4 V8 v11.0": [[58, "v8-v11-0"]], "2.0.3 V8 v10.9": [[58, "v8-v10-9"]], "2.0.2 V8 v10.8": [[58, "v8-v10-8"]], "2.0.1 V8 v10.7": [[58, "v8-v10-7"]], "2.0.0 Node.js v18.10": [[58, "node-js-v18-10"]], "Release Notes 2.1.x": [[59, "release-notes-2-1-x"]], "2.1.2 V8 v11.3": [[59, "v8-v11-3"]], "2.1.1 V8 v11.2": [[59, "v8-v11-2"]], "2.1.0 V8 v11.1": [[59, "v8-v11-1"]], "Release Notes 2.2.x": [[60, "release-notes-2-2-x"]], "2.2.3 V8 v11.7": [[60, "v8-v11-7"]], "2.2.2 V8 v11.6": [[60, "v8-v11-6"]], "2.2.1 V8 v11.5": [[60, "v8-v11-5"]], "2.2.0 V8 v11.4": [[60, "v8-v11-4"]], "Release Notes 3.0.x": [[61, "release-notes-3-0-x"]], "3.0.3 V8 v12.1": [[61, "v8-v12-1"]], "3.0.2 V8 v12.0": [[61, "v8-v12-0"]], "3.0.1 V8 v11.9": [[61, "v8-v11-9"]], "3.0.0 V8 v11.8": [[61, "v8-v11-8"]], "Access the Whole JVM": [[62, "access-the-whole-jvm"]], "Play with StringBuilder": [[62, "play-with-stringbuilder"]], "Play with Dynamic Interface": [[62, "play-with-dynamic-interface"]], "Play with Dynamic Object": [[62, "play-with-dynamic-object"]], "Cleanup": [[62, "cleanup"]], "Expose JsonNode in V8": [[63, "expose-jsonnode-in-v8"]], "2 Approaches": [[63, "approaches"]], "Java Flavor (Direct Exposure)": [[63, "java-flavor-direct-exposure"]], "JS Flavor (Wrapped Exposure)": [[63, "js-flavor-wrapped-exposure"]], "Test": [[63, "test"], [72, "test"]], "Conclusion": [[63, "conclusion"]], "Advanced": [[64, "advanced"]], "Interact with Node.js": [[65, "interact-with-node-js"]], "Is That Possible?": [[65, "is-that-possible"]], "How?": [[65, "how"]], "Step 1: JavaScript Server": [[65, "step-1-javascript-server"]], "Step 2: Worker Thread for the JavaScript Server": [[65, "step-2-worker-thread-for-the-javascript-server"]], "Step 3: Main Thread for the Interaction": [[65, "step-3-main-thread-for-the-interaction"]], "What If Node.js Hangs during Close()?": [[65, "what-if-node-js-hangs-during-close"]], "Java and JavaScript Interop": [[66, "java-and-javascript-interop"]], "Inject a Static Class": [[66, "inject-a-static-class"]], "Inject an Enum": [[66, "inject-an-enum"]], "Inject a Pattern": [[66, "inject-a-pattern"]], "Inject a StringBuilder": [[66, "inject-a-stringbuilder"]], "Array": [[67, "array"]], "List": [[67, "list"]], "Map": [[67, "map"]], "Motivation": [[68, "motivation"]], "Goals": [[68, "goals"]], "Print Hello Javet in V8 Mode": [[69, "print-hello-javet-in-v8-mode"]], "Print 1 + 1 in Node.js Mode": [[69, "print-1-1-in-node-js-mode"]], "Basic": [[70, "basic"]], "Installation": [[71, "installation"]], "OS Compatibility": [[71, "os-compatibility"]], "Windows": [[71, "windows"]], "Linux": [[71, "linux"]], "Mac OS": [[71, "mac-os"]], "Android": [[71, "android"]], "Sample": [[72, "sample"]], "@V8Property and @V8Function": [[72, "v8property-and-v8function"]], "Javet Shell": [[73, "javet-shell"]], "Node.js Mode and V8 Mode": [[74, "node-js-mode-and-v8-mode"]], "Co-existence": [[74, "co-existence"]], "V8Host": [[74, "v8host"]], "Pool": [[74, "pool"]], "Polyfill": [[75, "polyfill"]], "decimal.js": [[75, "decimal-js"]], "Spring Integration": [[76, "spring-integration"]], "Configuration": [[76, "configuration"]], "Injection": [[76, "injection"]], "Tutorial": [[77, "tutorial"]], "Migration Guides": [[78, "migration-guides"], [79, "migration-guides"]], "Migrate from J2V8": [[79, "migrate-from-j2v8"]], "Why Migrate from J2V8 to Javet?": [[79, "why-migrate-from-j2v8-to-javet"]], "V8 \u27f6 V8Runtime": [[79, "v8-v8runtime"]], "Primitive Types": [[79, "primitive-types"]], "registerJavaMethod() \u27f6 @V8Function": [[79, "registerjavamethod-v8function"]], "V8Locker": [[79, "v8locker"]], "Type Conversion": [[79, "type-conversion"]], "Node.js and V8": [[79, "node-js-and-v8"]], "ES6 Module": [[79, "es6-module"]], "Blessing": [[79, "blessing"]]}, "indexentries": {}}) \ No newline at end of file diff --git a/docs/tutorial/advanced/access_the_whole_jvm.html b/docs/tutorial/advanced/access_the_whole_jvm.html new file mode 100644 index 000000000..f89e06000 --- /dev/null +++ b/docs/tutorial/advanced/access_the_whole_jvm.html @@ -0,0 +1,477 @@ + + + + + + + + + Access the Whole JVM - Javet 3.0.3 documentation + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    + +
    +
    +
    + + + + + Back to top + +
    + +
    + +
    + +
    +
    +
    +

    Access the Whole JVM#

    +

    The built-in JavetJVMInterceptor allows JavaScript to access the whole JVM in both Node.js mode and V8 mode. JavetJVMInterceptor injects a global object javet which exposes some API for accessing Java packages and classes.

    +

    Let's see how to play with it.

    +
    +

    Play with StringBuilder#

    +
    // Step 1: Create a V8 runtime from V8 host in try-with-resource.
    +try (V8Runtime v8Runtime = V8Host.getV8Instance().createV8Runtime()) {
    +    // Step 2: Create a proxy converter.
    +    JavetProxyConverter javetProxyConverter = new JavetProxyConverter();
    +    // Step 3: Enable the dynamic object capability. (Optional)
    +    javetProxyConverter.getConfig().setReflectionObjectFactory(JavetReflectionObjectFactory.getInstance());
    +    // Step 4: Set the proxy converter to the V8 runtime.
    +    v8Runtime.setConverter(javetProxyConverter);
    +    // Step 5: Create and register the JVM interceptor.
    +    JavetJVMInterceptor javetJVMInterceptor = new JavetJVMInterceptor(v8Runtime);
    +    javetJVMInterceptor.register(v8Runtime.getGlobalObject());
    +    // Step 6: Create package 'java'.
    +    v8Runtime.getExecutor("let java = javet.package.java").executeVoid();
    +
    +    // Play with StringBuilder.
    +    System.out.println(v8Runtime.getExecutor("let sb = new java.lang.StringBuilder();" +
    +            "sb.append('abc').append(123);" +
    +            "sb.toString();").executeString());
    +    // Output: abc123
    +}
    +
    +
    +

    Once let java = javet.package.java is executed, the all the packages under java are open. Just instantiate whatever packages or classes you want to use, e.g. java.lang.StringBuilder, java.io.File, etc. There are a few API available for querying some meta data of those packages.

    +
    System.out.println(v8Runtime.getExecutor("java.lang['.name']").executeString());
    +// Output: java.lang
    +System.out.println(v8Runtime.getExecutor("java.lang.StringBuilder['.name']").executeString());
    +// Output: java.lang.StringBuilder
    +System.out.println(v8Runtime.getExecutor("java.io['.valid']").executeBoolean());
    +// Output: true
    +System.out.println(v8Runtime.getExecutor("java.abc['.valid']").executeBoolean());
    +// Output: false
    +System.out.println(v8Runtime.getExecutor("javet.package.javax.annotation['.name']").executeString());
    +// Output: javax.annotation
    +
    +
    +
    +
    +

    Play with Dynamic Interface#

    +

    JavetProxyConverter allows implementing Java interfaces dynamically with JavaScript functions. As the following sample code snippet shows, the JavaScript function () => { count++; } can be executed by java.lang.Thread and still can access V8. Behind the scene, Javet finds out the constructor of Thread takes an interface Runnable, then dynamically implements that interface by injecting the JavaScript function.

    +
    // Play with dynamic interface.
    +Thread thread = v8Runtime.getExecutor(
    +        "let count = 0;" +
    +        "let thread = new java.lang.Thread(() => { count++; });" +
    +        "thread.start();" +
    +        "thread; "
    +).executeObject();
    +thread.join();
    +System.out.println(v8Runtime.getExecutor("count").executeInteger());
    +// Output: 1
    +
    +
    +
    +
    +

    Play with Dynamic Object#

    +

    JavetReflectionObjectFactory allows implementing Java non-final objects dynamically with JavaScript objects. Be careful, it relies on library byte-buddy. Please refer to Proxy Converter for details. As the following sample code snippet shows, the JavaScript object { add: (a, b) => a + b } replaces the corresponding Java object DynamicClass by Javet.

    +
    // Play with dynamic object. (Optional)
    +IJavetAnonymous anonymous = new IJavetAnonymous() {
    +    @V8Function
    +    public void test(DynamicClass dynamicClass) {
    +        System.out.println(dynamicClass.add(1, 2));
    +    }
    +};
    +v8Runtime.getGlobalObject().set("a", anonymous);
    +v8Runtime.getExecutor("a.test({ add: (a, b) => a + b });").executeVoid();
    +v8Runtime.getGlobalObject().delete("a");
    +// Output: 3
    +
    +
    +
    +
    +

    Cleanup#

    +

    As the tutorial leaves a couple of Java objects in the V8 runtime and a couple of JavaScript objects in the JVM, properly cleaning up both V8 and JVM sometimes is necessary. The following code snippet shows how to elegantly clean up both V8 and JVM before closing the V8 runtime. Of course, these steps are optional because both Javet and JVM will eventually ensure there is no resource leak via the garbage collectors.

    +
    // Step 7: Dispose everything.
    +v8Runtime.getExecutor("java = sb = thread = undefined;").executeVoid();
    +// Step 8: Unregister the JVM interceptor.
    +javetJVMInterceptor.unregister(v8Runtime.getGlobalObject());
    +// Step 9: Enforce the GC to avoid memory leak. (Optional)
    +System.gc();
    +System.runFinalization();
    +v8Runtime.lowMemoryNotification();
    +
    +
    +
    +
    +

    Summary#

    +

    JavetJVMInterceptor gives V8 the capability of dynamically execute arbitrary Java code at runtime without compilation. That opens door to another project called JavetShell which is a console or application that provides Node.js flavored console interactions. That is usually used at a hotfix solution without re-compiling, re-deploying the Java applications.

    +

    Please refer to the source code for details.

    +
    +
    + +
    +
    + +
    + +
    +
    + + + + + + \ No newline at end of file diff --git a/docs/tutorial/advanced/access_the_whole_jvm.rst b/docs/tutorial/advanced/access_the_whole_jvm.rst new file mode 100644 index 000000000..e3f97c24a --- /dev/null +++ b/docs/tutorial/advanced/access_the_whole_jvm.rst @@ -0,0 +1,108 @@ +==================== +Access the Whole JVM +==================== + +The built-in ``JavetJVMInterceptor`` allows JavaScript to access the whole JVM in both Node.js mode and V8 mode. ``JavetJVMInterceptor`` injects a global object ``javet`` which exposes some API for accessing Java packages and classes. + +Let's see how to play with it. + +Play with StringBuilder +======================= + +.. code-block:: java + + // Step 1: Create a V8 runtime from V8 host in try-with-resource. + try (V8Runtime v8Runtime = V8Host.getV8Instance().createV8Runtime()) { + // Step 2: Create a proxy converter. + JavetProxyConverter javetProxyConverter = new JavetProxyConverter(); + // Step 3: Enable the dynamic object capability. (Optional) + javetProxyConverter.getConfig().setReflectionObjectFactory(JavetReflectionObjectFactory.getInstance()); + // Step 4: Set the proxy converter to the V8 runtime. + v8Runtime.setConverter(javetProxyConverter); + // Step 5: Create and register the JVM interceptor. + JavetJVMInterceptor javetJVMInterceptor = new JavetJVMInterceptor(v8Runtime); + javetJVMInterceptor.register(v8Runtime.getGlobalObject()); + // Step 6: Create package 'java'. + v8Runtime.getExecutor("let java = javet.package.java").executeVoid(); + + // Play with StringBuilder. + System.out.println(v8Runtime.getExecutor("let sb = new java.lang.StringBuilder();" + + "sb.append('abc').append(123);" + + "sb.toString();").executeString()); + // Output: abc123 + } + +Once ``let java = javet.package.java`` is executed, the all the packages under ``java`` are open. Just instantiate whatever packages or classes you want to use, e.g. ``java.lang.StringBuilder``, ``java.io.File``, etc. There are a few API available for querying some meta data of those packages. + +.. code-block:: java + + System.out.println(v8Runtime.getExecutor("java.lang['.name']").executeString()); + // Output: java.lang + System.out.println(v8Runtime.getExecutor("java.lang.StringBuilder['.name']").executeString()); + // Output: java.lang.StringBuilder + System.out.println(v8Runtime.getExecutor("java.io['.valid']").executeBoolean()); + // Output: true + System.out.println(v8Runtime.getExecutor("java.abc['.valid']").executeBoolean()); + // Output: false + System.out.println(v8Runtime.getExecutor("javet.package.javax.annotation['.name']").executeString()); + // Output: javax.annotation + +Play with Dynamic Interface +=========================== + +``JavetProxyConverter`` allows implementing Java interfaces dynamically with JavaScript functions. As the following sample code snippet shows, the JavaScript function ``() => { count++; }`` can be executed by ``java.lang.Thread`` and still can access V8. Behind the scene, Javet finds out the constructor of ``Thread`` takes an interface ``Runnable``, then dynamically implements that interface by injecting the JavaScript function. + +.. code-block:: java + + // Play with dynamic interface. + Thread thread = v8Runtime.getExecutor( + "let count = 0;" + + "let thread = new java.lang.Thread(() => { count++; });" + + "thread.start();" + + "thread; " + ).executeObject(); + thread.join(); + System.out.println(v8Runtime.getExecutor("count").executeInteger()); + // Output: 1 + +Play with Dynamic Object +======================== + +``JavetReflectionObjectFactory`` allows implementing Java non-final objects dynamically with JavaScript objects. Be careful, it relies on library ``byte-buddy``. Please refer to :doc:`../../reference/converters/proxy_converter` for details. As the following sample code snippet shows, the JavaScript object ``{ add: (a, b) => a + b }`` replaces the corresponding Java object ``DynamicClass`` by Javet. + +.. code-block:: java + + // Play with dynamic object. (Optional) + IJavetAnonymous anonymous = new IJavetAnonymous() { + @V8Function + public void test(DynamicClass dynamicClass) { + System.out.println(dynamicClass.add(1, 2)); + } + }; + v8Runtime.getGlobalObject().set("a", anonymous); + v8Runtime.getExecutor("a.test({ add: (a, b) => a + b });").executeVoid(); + v8Runtime.getGlobalObject().delete("a"); + // Output: 3 + +Cleanup +======= + +As the tutorial leaves a couple of Java objects in the V8 runtime and a couple of JavaScript objects in the JVM, properly cleaning up both V8 and JVM sometimes is necessary. The following code snippet shows how to elegantly clean up both V8 and JVM before closing the V8 runtime. Of course, these steps are optional because both Javet and JVM will eventually ensure there is no resource leak via the garbage collectors. + +.. code-block:: java + + // Step 7: Dispose everything. + v8Runtime.getExecutor("java = sb = thread = undefined;").executeVoid(); + // Step 8: Unregister the JVM interceptor. + javetJVMInterceptor.unregister(v8Runtime.getGlobalObject()); + // Step 9: Enforce the GC to avoid memory leak. (Optional) + System.gc(); + System.runFinalization(); + v8Runtime.lowMemoryNotification(); + +Summary +======= + +``JavetJVMInterceptor`` gives V8 the capability of dynamically execute arbitrary Java code at runtime without compilation. That opens door to another project called `JavetShell `_ which is a console or application that provides Node.js flavored console interactions. That is usually used at a hotfix solution without re-compiling, re-deploying the Java applications. + +Please refer to the :extsource3:`source code <../../../src/test/java/com/caoccao/javet/tutorial/TestAccessTheWholeJVM.java>` for details. diff --git a/docs/tutorial/advanced/expose_json_node_in_v8.html b/docs/tutorial/advanced/expose_json_node_in_v8.html index c0bd182e7..17050c9b8 100644 --- a/docs/tutorial/advanced/expose_json_node_in_v8.html +++ b/docs/tutorial/advanced/expose_json_node_in_v8.html @@ -3,10 +3,10 @@ - + - Expose JsonNode in V8 - Javet 3.0.2 documentation + Expose JsonNode in V8 - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/tutorial/advanced/index.html b/docs/tutorial/advanced/index.html index 950c64940..9a23ad9be 100644 --- a/docs/tutorial/advanced/index.html +++ b/docs/tutorial/advanced/index.html @@ -6,7 +6,7 @@ - Advanced - Javet 3.0.2 documentation + Advanced - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ @@ -358,7 +362,7 @@

    Advanced - + diff --git a/docs/tutorial/advanced/index.rst b/docs/tutorial/advanced/index.rst index 9423f719b..ea5d41e35 100644 --- a/docs/tutorial/advanced/index.rst +++ b/docs/tutorial/advanced/index.rst @@ -9,4 +9,5 @@ Advanced interact_with_node_js object_converter java_and_javascript_interop + access_the_whole_jvm expose_json_node_in_v8 diff --git a/docs/tutorial/advanced/interact_with_node_js.html b/docs/tutorial/advanced/interact_with_node_js.html index ecdf5f4b8..44d6f4713 100644 --- a/docs/tutorial/advanced/interact_with_node_js.html +++ b/docs/tutorial/advanced/interact_with_node_js.html @@ -6,7 +6,7 @@ - Interact with Node.js - Javet 3.0.2 documentation + Interact with Node.js - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/tutorial/advanced/java_and_javascript_interop.html b/docs/tutorial/advanced/java_and_javascript_interop.html index d344a5e42..e96665e58 100644 --- a/docs/tutorial/advanced/java_and_javascript_interop.html +++ b/docs/tutorial/advanced/java_and_javascript_interop.html @@ -3,10 +3,10 @@ - + - Java and JavaScript Interop - Javet 3.0.2 documentation + Java and JavaScript Interop - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ + diff --git a/docs/tutorial/advanced/object_converter.html b/docs/tutorial/advanced/object_converter.html index 968566dec..75128b7dc 100644 --- a/docs/tutorial/advanced/object_converter.html +++ b/docs/tutorial/advanced/object_converter.html @@ -6,7 +6,7 @@ - Object Converter - Javet 3.0.2 documentation + Object Converter - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/tutorial/basic/engine_pool.html b/docs/tutorial/basic/engine_pool.html index 2888cfd85..30d8a1c6f 100644 --- a/docs/tutorial/basic/engine_pool.html +++ b/docs/tutorial/basic/engine_pool.html @@ -6,7 +6,7 @@ - Javet Engine Pool - Javet 3.0.2 documentation + Javet Engine Pool - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/tutorial/basic/hello_javet.html b/docs/tutorial/basic/hello_javet.html index bf091998d..2d2f341e4 100644 --- a/docs/tutorial/basic/hello_javet.html +++ b/docs/tutorial/basic/hello_javet.html @@ -6,7 +6,7 @@ - Hello Javet - Javet 3.0.2 documentation + Hello Javet - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/tutorial/basic/index.html b/docs/tutorial/basic/index.html index ac9e68e61..3e4af4852 100644 --- a/docs/tutorial/basic/index.html +++ b/docs/tutorial/basic/index.html @@ -6,7 +6,7 @@ - Basic - Javet 3.0.2 documentation + Basic - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/tutorial/basic/installation.html b/docs/tutorial/basic/installation.html index 823dac823..8163e0848 100644 --- a/docs/tutorial/basic/installation.html +++ b/docs/tutorial/basic/installation.html @@ -6,7 +6,7 @@ - Installation - Javet 3.0.2 documentation + Installation - Javet 3.0.3 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 3.0.2 documentation + Javet 3.0.3 documentation @@ -176,6 +176,7 @@
  • Interact with Node.js
  • Object Converter
  • Java and JavaScript Interop
  • +
  • Access the Whole JVM
  • Expose JsonNode in V8
  • @@ -206,6 +207,7 @@
  • Know the Lock
  • Memory Management
  • Modularization
  • +
  • Snapshot
  • Troubleshooting
  • @@ -310,28 +313,28 @@

    Maven#< <dependency> <groupId>com.caoccao.javet</groupId> <artifactId>javet</artifactId> - <version>3.0.2</version> + <version>3.0.3</version> </dependency> <!-- Linux (arm64) --> <dependency> <groupId>com.caoccao.javet</groupId> <artifactId>javet-linux-arm64</artifactId> - <version>3.0.2</version> + <version>3.0.3</version> </dependency> <!-- Mac OS (x86_64 and arm64) --> <dependency> <groupId>com.caoccao.javet</groupId> <artifactId>javet-macos</artifactId> - <version>3.0.2</version> + <version>3.0.3</version> </dependency>

    <properties>
    -  <javet.version>3.0.2</javet.version>
    +  <javet.version>3.0.3</javet.version>
     </properties>
     
     <profiles>
    @@ -409,10 +412,10 @@ 

    Maven#<

    Gradle Kotlin DSL#

    -
    implementation("com.caoccao.javet:javet:3.0.2") // Linux and Windows (x86_64)
    -implementation("com.caoccao.javet:javet-linux-arm64:3.0.2") // Linux (arm64)
    -implementation("com.caoccao.javet:javet-macos:3.0.2") // Mac OS (x86_64 and arm64)
    -implementation("com.caoccao.javet:javet-android:3.0.2") // Android (arm, arm64, x86 and x86_64)
    +
    implementation("com.caoccao.javet:javet:3.0.3") // Linux and Windows (x86_64)
    +implementation("com.caoccao.javet:javet-linux-arm64:3.0.3") // Linux (arm64)
    +implementation("com.caoccao.javet:javet-macos:3.0.3") // Mac OS (x86_64 and arm64)
    +implementation("com.caoccao.javet:javet-android:3.0.3") // Android (arm, arm64, x86 and x86_64)
     
    @@ -422,11 +425,11 @@

    Gradle Kotlin DSLval os = OperatingSystem.current() val cpuArch = System.getProperty("os.arch") if (os.isMacOsX) { - implementation("com.caoccao.javet:javet:3.0.2") + implementation("com.caoccao.javet:javet:3.0.3") } else if (os.isLinux && (cpuArch == "aarch64" || cpuArch == "arm64")) { - implementation("com.caoccao.javet:javet-linux-arm64:3.0.2") + implementation("com.caoccao.javet:javet-linux-arm64:3.0.3") } else { - implementation("com.caoccao.javet:javet-macos:3.0.2") + implementation("com.caoccao.javet:javet-macos:3.0.3") }

    @@ -435,10 +438,10 @@

    Gradle Kotlin DSL

    Gradle Groovy DSL#

    -
    implementation 'com.caoccao.javet:javet:3.0.2' // Linux and Windows (x86_64)
    -implementation 'com.caoccao.javet:javet-linux-arm64:3.0.2' // Linux (arm64)
    -implementation 'com.caoccao.javet:javet-macos:3.0.2' // Mac OS (x86_64 and arm64)
    -implementation 'com.caoccao.javet:javet-android:3.0.2' // Android (arm, arm64, x86 and x86_64)
    +
    implementation 'com.caoccao.javet:javet:3.0.3' // Linux and Windows (x86_64)
    +implementation 'com.caoccao.javet:javet-linux-arm64:3.0.3' // Linux (arm64)
    +implementation 'com.caoccao.javet:javet-macos:3.0.3' // Mac OS (x86_64 and arm64)
    +implementation 'com.caoccao.javet:javet-android:3.0.3' // Android (arm, arm64, x86 and x86_64)
     
    @@ -485,16 +488,16 @@

    Linux#<

    Yes

    Ubuntu 18.04

    -

    Yes (since v1.1.0)

    +

    Yes (since v1.1.0 and private builds)

    Ubuntu 16.04

    -

    Yes (since v1.1.0)

    +

    Yes (since v1.1.0 and private builds)

    Cent OS 8

    -

    Yes (since v1.1.0)

    +

    Yes (since v1.1.0 and private builds)

    Cent OS 7

    -

    Yes (since v1.1.0)

    +

    Yes (since v1.1.0 and private builds)

    Other Linux Distributions

    Not Tested

    @@ -508,6 +511,32 @@

    Linux#<
  • Private builds imply considerable additional effort, so there is no commitments. Please contact the maintainer for private builds wisely.

  • +
    + + + + + + + + + + + + + + + + + + + + + + + +

    glibc Version

    Javet Version

    2.29

    v3.0.3+

    2.34

    v3.0.1 - v3.0.2

    2.29

    v0.8.6 - v3.0.0

    2.25

    v0.8.0 - v0.8.5

    2.14

    v0.7.0 - v0.7.4

    +

    Mac OS#

    @@ -652,7 +681,7 @@

    Android#<

    -

    + diff --git a/docs/tutorial/basic/installation.rst b/docs/tutorial/basic/installation.rst index 21fe5b726..7b56a3f2e 100644 --- a/docs/tutorial/basic/installation.rst +++ b/docs/tutorial/basic/installation.rst @@ -16,21 +16,21 @@ Maven com.caoccao.javet javet - 3.0.2 + 3.0.3 com.caoccao.javet javet-linux-arm64 - 3.0.2 + 3.0.3 com.caoccao.javet javet-macos - 3.0.2 + 3.0.3 .. tab:: Complete @@ -38,7 +38,7 @@ Maven .. code-block:: xml - 3.0.2 + 3.0.3 @@ -115,10 +115,10 @@ Gradle Kotlin DSL .. code-block:: kotlin - implementation("com.caoccao.javet:javet:3.0.2") // Linux and Windows (x86_64) - implementation("com.caoccao.javet:javet-linux-arm64:3.0.2") // Linux (arm64) - implementation("com.caoccao.javet:javet-macos:3.0.2") // Mac OS (x86_64 and arm64) - implementation("com.caoccao.javet:javet-android:3.0.2") // Android (arm, arm64, x86 and x86_64) + implementation("com.caoccao.javet:javet:3.0.3") // Linux and Windows (x86_64) + implementation("com.caoccao.javet:javet-linux-arm64:3.0.3") // Linux (arm64) + implementation("com.caoccao.javet:javet-macos:3.0.3") // Mac OS (x86_64 and arm64) + implementation("com.caoccao.javet:javet-android:3.0.3") // Android (arm, arm64, x86 and x86_64) .. tab:: Complete @@ -129,11 +129,11 @@ Gradle Kotlin DSL val os = OperatingSystem.current() val cpuArch = System.getProperty("os.arch") if (os.isMacOsX) { - implementation("com.caoccao.javet:javet:3.0.2") + implementation("com.caoccao.javet:javet:3.0.3") } else if (os.isLinux && (cpuArch == "aarch64" || cpuArch == "arm64")) { - implementation("com.caoccao.javet:javet-linux-arm64:3.0.2") + implementation("com.caoccao.javet:javet-linux-arm64:3.0.3") } else { - implementation("com.caoccao.javet:javet-macos:3.0.2") + implementation("com.caoccao.javet:javet-macos:3.0.3") } Gradle Groovy DSL @@ -141,10 +141,10 @@ Gradle Groovy DSL .. code-block:: groovy - implementation 'com.caoccao.javet:javet:3.0.2' // Linux and Windows (x86_64) - implementation 'com.caoccao.javet:javet-linux-arm64:3.0.2' // Linux (arm64) - implementation 'com.caoccao.javet:javet-macos:3.0.2' // Mac OS (x86_64 and arm64) - implementation 'com.caoccao.javet:javet-android:3.0.2' // Android (arm, arm64, x86 and x86_64) + implementation 'com.caoccao.javet:javet:3.0.3' // Linux and Windows (x86_64) + implementation 'com.caoccao.javet:javet-linux-arm64:3.0.3' // Linux (arm64) + implementation 'com.caoccao.javet:javet-macos:3.0.3' // Mac OS (x86_64 and arm64) + implementation 'com.caoccao.javet:javet-android:3.0.3' // Android (arm, arm64, x86 and x86_64) OS Compatibility ================ @@ -168,10 +168,10 @@ OS Compatible =========================== ======================================================================================================================= Ubuntu 22.04 Yes Ubuntu 20.04 Yes -Ubuntu 18.04 Yes (since v1.1.0) -Ubuntu 16.04 Yes (since v1.1.0) -Cent OS 8 Yes (since v1.1.0) -Cent OS 7 Yes (since v1.1.0) +Ubuntu 18.04 Yes (since v1.1.0 and private builds) +Ubuntu 16.04 Yes (since v1.1.0 and private builds) +Cent OS 8 Yes (since v1.1.0 and private builds) +Cent OS 7 Yes (since v1.1.0 and private builds) Other Linux Distributions Not Tested =========================== ======================================================================================================================= @@ -179,6 +179,16 @@ Other Linux Distributions Not Tested * Private builds imply considerable additional effort, so there is no commitments. Please contact the maintainer for private builds wisely. +=============== ======================== +glibc Version Javet Version +=============== ======================== +2.29 v3.0.3+ +2.34 v3.0.1 - v3.0.2 +2.29 v0.8.6 - v3.0.0 +2.25 v0.8.0 - v0.8.5 +2.14 v0.7.0 - v0.7.4 +=============== ======================== + Mac OS ------ diff --git a/docs/tutorial/basic/interception.html b/docs/tutorial/basic/interception.html index 6d474c115..355625409 100644 --- a/docs/tutorial/basic/interception.html +++ b/docs/tutorial/basic/interception.html @@ -6,7 +6,7 @@ - Interception - Javet 3.0.2 documentation + Interception - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/tutorial/basic/javet_shell.html b/docs/tutorial/basic/javet_shell.html index f4d49a2ff..02293ed3c 100644 --- a/docs/tutorial/basic/javet_shell.html +++ b/docs/tutorial/basic/javet_shell.html @@ -6,7 +6,7 @@ - Javet Shell - Javet 3.0.2 documentation + Javet Shell - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/tutorial/basic/node_js_mode_and_v8_mode.html b/docs/tutorial/basic/node_js_mode_and_v8_mode.html index 3fcc592e8..61f6643a0 100644 --- a/docs/tutorial/basic/node_js_mode_and_v8_mode.html +++ b/docs/tutorial/basic/node_js_mode_and_v8_mode.html @@ -6,7 +6,7 @@ - Node.js Mode and V8 Mode - Javet 3.0.2 documentation + Node.js Mode and V8 Mode - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/tutorial/basic/polyfill.html b/docs/tutorial/basic/polyfill.html index 50e411ee6..28aee0d53 100644 --- a/docs/tutorial/basic/polyfill.html +++ b/docs/tutorial/basic/polyfill.html @@ -6,7 +6,7 @@ - Polyfill - Javet 3.0.2 documentation + Polyfill - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/tutorial/basic/spring_integration.html b/docs/tutorial/basic/spring_integration.html index 21d1d3548..af874a9db 100644 --- a/docs/tutorial/basic/spring_integration.html +++ b/docs/tutorial/basic/spring_integration.html @@ -6,7 +6,7 @@ - Spring Integration - Javet 3.0.2 documentation + Spring Integration - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/tutorial/index.html b/docs/tutorial/index.html index 461659782..1be29c851 100644 --- a/docs/tutorial/index.html +++ b/docs/tutorial/index.html @@ -6,7 +6,7 @@ - Tutorial - Javet 3.0.2 documentation + Tutorial - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/docs/tutorial/migration_guides/index.html b/docs/tutorial/migration_guides/index.html index 8736b5f1d..345eb2f06 100644 --- a/docs/tutorial/migration_guides/index.html +++ b/docs/tutorial/migration_guides/index.html @@ -6,7 +6,7 @@ - Migration Guides - Javet 3.0.2 documentation + Migration Guides - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ diff --git a/docs/tutorial/migration_guides/migrate_from_j2v8.html b/docs/tutorial/migration_guides/migrate_from_j2v8.html index 6bfcc7063..def3ccaf9 100644 --- a/docs/tutorial/migration_guides/migrate_from_j2v8.html +++ b/docs/tutorial/migration_guides/migrate_from_j2v8.html @@ -6,7 +6,7 @@ - Migrate from J2V8 - Javet 3.0.2 documentation + Migrate from J2V8 - Javet 3.0.3 documentation @@ -125,7 +125,7 @@ - + diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 5e3474163..000000000 --- a/pom.xml +++ /dev/null @@ -1,238 +0,0 @@ - - 4.0.0 - - com.caoccao.javet - javet - 3.0.2 - javet - Javet is Java + V8 (JAVa + V + EighT). It is an awesome way of embedding V8 in Java. - https://github.com/caoccao/Javet - - - - APACHE LICENSE, VERSION 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - - Sam Cao - sjtucaocao@gmail.com - caoccao.com - https://www.caoccao.com - - - - - scm:git:git://github.com/caoccao/Javet.git - scm:git:git@github.com:caoccao/caoccao.git - https://github.com/caoccao/Javet - 3.0.2 - - - - 1.8 - 1.8 - - - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - - - org.eclipse.jetty.websocket - websocket-server - 9.4.51.v20230217 - test - - - - org.eclipse.jetty.websocket - javax-websocket-server-impl - 9.4.51.v20230217 - test - - - - com.fasterxml.jackson.core - jackson-databind - 2.15.3 - test - - - - net.bytebuddy - byte-buddy - 1.14.9 - test - - - - org.junit.jupiter - junit-jupiter-api - 5.10.0 - test - - - - org.junit.jupiter - junit-jupiter-engine - 5.10.0 - test - - - - org.junit.jupiter - junit-jupiter-params - 5.10.0 - test - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - - - - maven-surefire-plugin - 2.22.2 - - - maven-failsafe-plugin - 2.22.2 - - - maven-deploy-plugin - 3.0.0-M1 - - - default-deploy - deploy - - deploy - - - - - - org.apache.maven.plugins - maven-release-plugin - 3.0.0-M1 - - true - false - forked-path - - -Dgpg.passphrase=${gpg.passphrase} -Dmaven.test.skipTests=true -Dmaven.test.skip=true - - - - org.apache.maven.scm - maven-scm-provider-gitexe - 1.11.2 - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.8 - true - - ossrh - https://oss.sonatype.org/ - true - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.1 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.2.0 - - UTF-8 - - - - attach-javadoc - - jar - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - - com.caoccao.javet - - - - - - - - - - - release-sign-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - - - - - - diff --git a/scripts/node/javet-rebuild/rebuild.cmd b/scripts/node/javet-rebuild/rebuild.cmd index 57b58e9c3..10d817167 100644 --- a/scripts/node/javet-rebuild/rebuild.cmd +++ b/scripts/node/javet-rebuild/rebuild.cmd @@ -1,5 +1,5 @@ @echo off -SET NODE_LIB_FILE="..\..\..\..\..\..\build\libs\libjavet-node-windows-x86_64.v.3.0.2.lib" +SET NODE_LIB_FILE="..\..\..\..\..\..\build\libs\libjavet-node-windows-x86_64.v.3.0.3.lib" cd %NODE_MODULE_ROOT% call node-gyp clean call node-gyp configure --module_name=%NODE_MODULE_NAME% --module_path=%NODE_MODULE_PATH% --node_lib_file=%NODE_LIB_FILE% diff --git a/scripts/node/javet-rebuild/rebuild.sh b/scripts/node/javet-rebuild/rebuild.sh index 30f78c9e2..ee7e2bc52 100755 --- a/scripts/node/javet-rebuild/rebuild.sh +++ b/scripts/node/javet-rebuild/rebuild.sh @@ -1 +1 @@ -patchelf --add-needed libjavet-node-linux-x86_64.v.3.0.2.so ${NODE_MODULE_FILE} +patchelf --add-needed libjavet-node-linux-x86_64.v.3.0.3.so ${NODE_MODULE_FILE} diff --git a/scripts/node/test-es5/test-es5-multiline-string-literals.js b/scripts/node/test-es5/test-es5-multiline-string-literals.js index 7687ec17c..988d8aeeb 100644 --- a/scripts/node/test-es5/test-es5-multiline-string-literals.js +++ b/scripts/node/test-es5/test-es5-multiline-string-literals.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-array-find-index.js b/scripts/node/test-es6/test-es6-array-find-index.js index c7039aec1..7633562f2 100644 --- a/scripts/node/test-es6/test-es6-array-find-index.js +++ b/scripts/node/test-es6/test-es6-array-find-index.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-array-find.js b/scripts/node/test-es6/test-es6-array-find.js index 1a404d64b..2b97fd1e2 100644 --- a/scripts/node/test-es6/test-es6-array-find.js +++ b/scripts/node/test-es6/test-es6-array-find.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-arrow-function.js b/scripts/node/test-es6/test-es6-arrow-function.js index f8a774ad7..cf4ad9173 100644 --- a/scripts/node/test-es6/test-es6-arrow-function.js +++ b/scripts/node/test-es6/test-es6-arrow-function.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-class.js b/scripts/node/test-es6/test-es6-class.js index c5bc93f53..3707db38e 100644 --- a/scripts/node/test-es6/test-es6-class.js +++ b/scripts/node/test-es6/test-es6-class.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-default-parameter-values.js b/scripts/node/test-es6/test-es6-default-parameter-values.js index 02e742b61..640b39b6c 100644 --- a/scripts/node/test-es6/test-es6-default-parameter-values.js +++ b/scripts/node/test-es6/test-es6-default-parameter-values.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-function-rest-parameter.js b/scripts/node/test-es6/test-es6-function-rest-parameter.js index d7e37f824..c96e9f14d 100644 --- a/scripts/node/test-es6/test-es6-function-rest-parameter.js +++ b/scripts/node/test-es6/test-es6-function-rest-parameter.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-is-finite.js b/scripts/node/test-es6/test-es6-is-finite.js index 7a7da3a83..8fb3f4bc0 100644 --- a/scripts/node/test-es6/test-es6-is-finite.js +++ b/scripts/node/test-es6/test-es6-is-finite.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-is-nan.js b/scripts/node/test-es6/test-es6-is-nan.js index f3893b4d1..706507c62 100644 --- a/scripts/node/test-es6/test-es6-is-nan.js +++ b/scripts/node/test-es6/test-es6-is-nan.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-let-const.js b/scripts/node/test-es6/test-es6-let-const.js index ee02cb791..63b609432 100644 --- a/scripts/node/test-es6/test-es6-let-const.js +++ b/scripts/node/test-es6/test-es6-let-const.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-number-is-integer.js b/scripts/node/test-es6/test-es6-number-is-integer.js index 07d7a59c5..b111c27ac 100644 --- a/scripts/node/test-es6/test-es6-number-is-integer.js +++ b/scripts/node/test-es6/test-es6-number-is-integer.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-number-is-safe-integer.js b/scripts/node/test-es6/test-es6-number-is-safe-integer.js index a205210f4..ce5100ac9 100644 --- a/scripts/node/test-es6/test-es6-number-is-safe-integer.js +++ b/scripts/node/test-es6/test-es6-number-is-safe-integer.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-es6/test-es6-symbol.js b/scripts/node/test-es6/test-es6-symbol.js index 73ce7ad12..82d3ef685 100644 --- a/scripts/node/test-es6/test-es6-symbol.js +++ b/scripts/node/test-es6/test-es6-symbol.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-node/test-node-module-fs.js b/scripts/node/test-node/test-node-module-fs.js index 9911d91ab..013199bf4 100644 --- a/scripts/node/test-node/test-node-module-fs.js +++ b/scripts/node/test-node/test-node-module-fs.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-node/test-node-module-sqlite3-sync.js b/scripts/node/test-node/test-node-module-sqlite3-sync.js index 1270420e2..6816b7d5a 100644 --- a/scripts/node/test-node/test-node-module-sqlite3-sync.js +++ b/scripts/node/test-node/test-node-module-sqlite3-sync.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-node/test-node-module-swc-sync.js b/scripts/node/test-node/test-node-module-swc-sync.js index 6fc32c786..6b3f83768 100644 --- a/scripts/node/test-node/test-node-module-swc-sync.js +++ b/scripts/node/test-node/test-node-module-swc-sync.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-node/test-node-module-timers.js b/scripts/node/test-node/test-node-module-timers.js index cadb94748..6f4f671e0 100644 --- a/scripts/node/test-node/test-node-module-timers.js +++ b/scripts/node/test-node/test-node-module-timers.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/node/test-node/test-node-module-vm.js b/scripts/node/test-node/test-node-module-vm.js index 95fe3bff6..ca3060198 100644 --- a/scripts/node/test-node/test-node-module-vm.js +++ b/scripts/node/test-node/test-node-module-vm.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/python/change_javet_version.py b/scripts/python/change_javet_version.py index 81ed1aab7..00e6a826c 100644 --- a/scripts/python/change_javet_version.py +++ b/scripts/python/change_javet_version.py @@ -1,5 +1,5 @@ ''' - Copyright (c) 2021-2023 caoccao.com Sam Cao + Copyright (c) 2021-2024. caoccao.com Sam Cao All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,7 +39,7 @@ def update(self): re.compile(r'version: \'(?P\d+\.\d+\.\d+)\'')) self._update( 'build.gradle.kts', '\n', - re.compile(r'^version = "(?P\d+\.\d+\.\d+)"$')) + re.compile(r'^ const val JAVET = "(?P\d+\.\d+\.\d+)"$')) self._update( '.github/workflows/android_build.yml', '\n', re.compile(r'JAVET_VERSION: (?P\d+\.\d+\.\d+)')) @@ -109,10 +109,6 @@ def update(self): re.compile(r'(?P\d+\.\d+\.\d+)$'), re.compile(r'javet[\-\w]*:(?P\d+\.\d+\.\d+)["\'@]{1}'), re.compile(r'version: \'(?P\d+\.\d+\.\d+)\'')) - self._update( - 'pom.xml', '\n', - re.compile(r'^ (?P\d+\.\d+\.\d+)$'), - re.compile(r'^ (?P\d+\.\d+\.\d+)$')) self._update( 'android/pom.xml', '\n', re.compile(r'^ (?P\d+\.\d+\.\d+)$'), @@ -184,7 +180,7 @@ def _update(self, relative_file_path: str, line_separator: str, *patterns: list) logging.info(' Updated.') def main(): - change_javet_version = ChangeJavetVersion('3.0.2') + change_javet_version = ChangeJavetVersion('3.0.3') change_javet_version.update() return 0 diff --git a/scripts/python/change_node_v8_version.py b/scripts/python/change_node_v8_version.py index 14ad10e2f..fd5ab99e0 100644 --- a/scripts/python/change_node_v8_version.py +++ b/scripts/python/change_node_v8_version.py @@ -1,5 +1,5 @@ ''' - Copyright (c) 2021-2023 caoccao.com Sam Cao + Copyright (c) 2021-2024. caoccao.com Sam Cao All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); @@ -158,9 +158,9 @@ def update(self) -> None: re.compile(r'"(?P\d+\.\d+\.\d+\.\d+)",')) def main(): - change_node_version = ChangeNodeVersion('20.10.0') + change_node_version = ChangeNodeVersion('20.11.0') change_node_version.update() - change_v8_version = ChangeV8Version('12.0.267.8') + change_v8_version = ChangeV8Version('12.1.285.26') change_v8_version.update() return 0 diff --git a/scripts/python/patch_android_build.py b/scripts/python/patch_android_build.py index e252a9010..b78e1605a 100644 --- a/scripts/python/patch_android_build.py +++ b/scripts/python/patch_android_build.py @@ -1,5 +1,5 @@ ''' - Copyright (c) 2021-2023 caoccao.com Sam Cao + Copyright (c) 2021-2024. caoccao.com Sam Cao All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/python/patch_node_build.py b/scripts/python/patch_node_build.py index 72987e7c0..e4d8b1983 100644 --- a/scripts/python/patch_node_build.py +++ b/scripts/python/patch_node_build.py @@ -1,5 +1,5 @@ ''' - Copyright (c) 2021-2023 caoccao.com Sam Cao + Copyright (c) 2021-2024. caoccao.com Sam Cao All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/scripts/python/patch_v8_build.py b/scripts/python/patch_v8_build.py index e08d8fa39..35096a060 100644 --- a/scripts/python/patch_v8_build.py +++ b/scripts/python/patch_v8_build.py @@ -1,5 +1,5 @@ ''' - Copyright (c) 2021-2023 caoccao.com Sam Cao + Copyright (c) 2021-2024. caoccao.com Sam Cao All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/settings.gradle.kts b/settings.gradle.kts index e03365fc8..6251aa9be 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/CheckReturnValue.java b/src/main/java/com/caoccao/javet/annotations/CheckReturnValue.java index 3f714db48..88d006b3b 100644 --- a/src/main/java/com/caoccao/javet/annotations/CheckReturnValue.java +++ b/src/main/java/com/caoccao/javet/annotations/CheckReturnValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/NodeModule.java b/src/main/java/com/caoccao/javet/annotations/NodeModule.java index 99623d3be..035136283 100644 --- a/src/main/java/com/caoccao/javet/annotations/NodeModule.java +++ b/src/main/java/com/caoccao/javet/annotations/NodeModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/V8Allow.java b/src/main/java/com/caoccao/javet/annotations/V8Allow.java index 96910dbb0..3443034b4 100644 --- a/src/main/java/com/caoccao/javet/annotations/V8Allow.java +++ b/src/main/java/com/caoccao/javet/annotations/V8Allow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/V8BindingEnabler.java b/src/main/java/com/caoccao/javet/annotations/V8BindingEnabler.java index c9f7e6a2c..fdda30aa2 100644 --- a/src/main/java/com/caoccao/javet/annotations/V8BindingEnabler.java +++ b/src/main/java/com/caoccao/javet/annotations/V8BindingEnabler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/V8Block.java b/src/main/java/com/caoccao/javet/annotations/V8Block.java index d414f0748..522b9473e 100644 --- a/src/main/java/com/caoccao/javet/annotations/V8Block.java +++ b/src/main/java/com/caoccao/javet/annotations/V8Block.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/V8Convert.java b/src/main/java/com/caoccao/javet/annotations/V8Convert.java index c825c02d3..a08dc6dbf 100644 --- a/src/main/java/com/caoccao/javet/annotations/V8Convert.java +++ b/src/main/java/com/caoccao/javet/annotations/V8Convert.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/V8Function.java b/src/main/java/com/caoccao/javet/annotations/V8Function.java index 479e25ebf..37e4a740a 100644 --- a/src/main/java/com/caoccao/javet/annotations/V8Function.java +++ b/src/main/java/com/caoccao/javet/annotations/V8Function.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/V8Getter.java b/src/main/java/com/caoccao/javet/annotations/V8Getter.java index f67f72d0e..155653dac 100644 --- a/src/main/java/com/caoccao/javet/annotations/V8Getter.java +++ b/src/main/java/com/caoccao/javet/annotations/V8Getter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/V8Property.java b/src/main/java/com/caoccao/javet/annotations/V8Property.java index 64171c5fe..e2970e023 100644 --- a/src/main/java/com/caoccao/javet/annotations/V8Property.java +++ b/src/main/java/com/caoccao/javet/annotations/V8Property.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/V8RuntimeSetter.java b/src/main/java/com/caoccao/javet/annotations/V8RuntimeSetter.java index 1f5ac78cc..d35181cfd 100644 --- a/src/main/java/com/caoccao/javet/annotations/V8RuntimeSetter.java +++ b/src/main/java/com/caoccao/javet/annotations/V8RuntimeSetter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/V8Setter.java b/src/main/java/com/caoccao/javet/annotations/V8Setter.java index 473e7a10f..9ae2b52e9 100644 --- a/src/main/java/com/caoccao/javet/annotations/V8Setter.java +++ b/src/main/java/com/caoccao/javet/annotations/V8Setter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/annotations/package-info.java b/src/main/java/com/caoccao/javet/annotations/package-info.java index 4f3457e98..62f258af0 100644 --- a/src/main/java/com/caoccao/javet/annotations/package-info.java +++ b/src/main/java/com/caoccao/javet/annotations/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/entities/JavetEntityFunction.java b/src/main/java/com/caoccao/javet/entities/JavetEntityFunction.java index d48bf334f..e7b64fd02 100644 --- a/src/main/java/com/caoccao/javet/entities/JavetEntityFunction.java +++ b/src/main/java/com/caoccao/javet/entities/JavetEntityFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/entities/JavetEntityMap.java b/src/main/java/com/caoccao/javet/entities/JavetEntityMap.java index cc1b36eb2..3340a96ca 100644 --- a/src/main/java/com/caoccao/javet/entities/JavetEntityMap.java +++ b/src/main/java/com/caoccao/javet/entities/JavetEntityMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/entities/JavetEntitySymbol.java b/src/main/java/com/caoccao/javet/entities/JavetEntitySymbol.java index 8665db0a3..f10e6053c 100644 --- a/src/main/java/com/caoccao/javet/entities/JavetEntitySymbol.java +++ b/src/main/java/com/caoccao/javet/entities/JavetEntitySymbol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/entities/package-info.java b/src/main/java/com/caoccao/javet/entities/package-info.java index 1a4e7fa05..5f2426e50 100644 --- a/src/main/java/com/caoccao/javet/entities/package-info.java +++ b/src/main/java/com/caoccao/javet/entities/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/JSFunctionType.java b/src/main/java/com/caoccao/javet/enums/JSFunctionType.java index 358664bba..51dee8c41 100644 --- a/src/main/java/com/caoccao/javet/enums/JSFunctionType.java +++ b/src/main/java/com/caoccao/javet/enums/JSFunctionType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java b/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java index f76f84b82..49d9ba2f4 100644 --- a/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java +++ b/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public enum JSRuntimeType { */ Node( "node", - "11.3.244.8-node.25", // node -p process.versions.v8 + "11.3.244.8-node.17", // node -p process.versions.v8 NodeRuntimeOptions::new, o -> o instanceof NodeRuntimeOptions), /** @@ -47,7 +47,7 @@ public enum JSRuntimeType { */ V8( "v8", - "12.0.267.8", + "12.1.285.26", V8RuntimeOptions::new, o -> o instanceof V8RuntimeOptions); diff --git a/src/main/java/com/caoccao/javet/enums/JSScopeType.java b/src/main/java/com/caoccao/javet/enums/JSScopeType.java index 1fd6348d8..fc8321e93 100644 --- a/src/main/java/com/caoccao/javet/enums/JSScopeType.java +++ b/src/main/java/com/caoccao/javet/enums/JSScopeType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/JavetErrorType.java b/src/main/java/com/caoccao/javet/enums/JavetErrorType.java index caebf8e30..46ded45ba 100644 --- a/src/main/java/com/caoccao/javet/enums/JavetErrorType.java +++ b/src/main/java/com/caoccao/javet/enums/JavetErrorType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/JavetPromiseRejectEvent.java b/src/main/java/com/caoccao/javet/enums/JavetPromiseRejectEvent.java index a9612e999..4c1b122e4 100644 --- a/src/main/java/com/caoccao/javet/enums/JavetPromiseRejectEvent.java +++ b/src/main/java/com/caoccao/javet/enums/JavetPromiseRejectEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8AllocationSpace.java b/src/main/java/com/caoccao/javet/enums/V8AllocationSpace.java index 2e393ac19..fbab0c571 100644 --- a/src/main/java/com/caoccao/javet/enums/V8AllocationSpace.java +++ b/src/main/java/com/caoccao/javet/enums/V8AllocationSpace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8AwaitMode.java b/src/main/java/com/caoccao/javet/enums/V8AwaitMode.java index 32f835643..faf5d2c24 100644 --- a/src/main/java/com/caoccao/javet/enums/V8AwaitMode.java +++ b/src/main/java/com/caoccao/javet/enums/V8AwaitMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8ContextType.java b/src/main/java/com/caoccao/javet/enums/V8ContextType.java index 9143aba2f..6e4138dba 100644 --- a/src/main/java/com/caoccao/javet/enums/V8ContextType.java +++ b/src/main/java/com/caoccao/javet/enums/V8ContextType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8ConversionMode.java b/src/main/java/com/caoccao/javet/enums/V8ConversionMode.java index 0838c33b8..8f403a491 100644 --- a/src/main/java/com/caoccao/javet/enums/V8ConversionMode.java +++ b/src/main/java/com/caoccao/javet/enums/V8ConversionMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8GCCallbackFlags.java b/src/main/java/com/caoccao/javet/enums/V8GCCallbackFlags.java index 66b2789d0..6a0144d70 100644 --- a/src/main/java/com/caoccao/javet/enums/V8GCCallbackFlags.java +++ b/src/main/java/com/caoccao/javet/enums/V8GCCallbackFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8GCType.java b/src/main/java/com/caoccao/javet/enums/V8GCType.java index 9ab9594bd..91263b8a0 100644 --- a/src/main/java/com/caoccao/javet/enums/V8GCType.java +++ b/src/main/java/com/caoccao/javet/enums/V8GCType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8ScopeType.java b/src/main/java/com/caoccao/javet/enums/V8ScopeType.java index 5bc101eb7..8e96f5c5c 100644 --- a/src/main/java/com/caoccao/javet/enums/V8ScopeType.java +++ b/src/main/java/com/caoccao/javet/enums/V8ScopeType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8ValueInternalType.java b/src/main/java/com/caoccao/javet/enums/V8ValueInternalType.java index 53ec90ed0..f14235e22 100644 --- a/src/main/java/com/caoccao/javet/enums/V8ValueInternalType.java +++ b/src/main/java/com/caoccao/javet/enums/V8ValueInternalType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8ValueReferenceType.java b/src/main/java/com/caoccao/javet/enums/V8ValueReferenceType.java index 008e9a762..9a2730fbb 100644 --- a/src/main/java/com/caoccao/javet/enums/V8ValueReferenceType.java +++ b/src/main/java/com/caoccao/javet/enums/V8ValueReferenceType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/V8ValueSymbolType.java b/src/main/java/com/caoccao/javet/enums/V8ValueSymbolType.java index fb12124ec..622e48806 100644 --- a/src/main/java/com/caoccao/javet/enums/V8ValueSymbolType.java +++ b/src/main/java/com/caoccao/javet/enums/V8ValueSymbolType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/enums/package-info.java b/src/main/java/com/caoccao/javet/enums/package-info.java index d1addba25..65ec8ccac 100644 --- a/src/main/java/com/caoccao/javet/enums/package-info.java +++ b/src/main/java/com/caoccao/javet/enums/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/exceptions/BaseJavetScriptingException.java b/src/main/java/com/caoccao/javet/exceptions/BaseJavetScriptingException.java index 5fd5b553a..0ffdbe694 100644 --- a/src/main/java/com/caoccao/javet/exceptions/BaseJavetScriptingException.java +++ b/src/main/java/com/caoccao/javet/exceptions/BaseJavetScriptingException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/exceptions/JavetCompilationException.java b/src/main/java/com/caoccao/javet/exceptions/JavetCompilationException.java index ea8c8be00..37b5e4b13 100644 --- a/src/main/java/com/caoccao/javet/exceptions/JavetCompilationException.java +++ b/src/main/java/com/caoccao/javet/exceptions/JavetCompilationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/exceptions/JavetConverterException.java b/src/main/java/com/caoccao/javet/exceptions/JavetConverterException.java index 3e1b6a195..38632ff03 100644 --- a/src/main/java/com/caoccao/javet/exceptions/JavetConverterException.java +++ b/src/main/java/com/caoccao/javet/exceptions/JavetConverterException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/exceptions/JavetError.java b/src/main/java/com/caoccao/javet/exceptions/JavetError.java index f818935d6..afa8857af 100644 --- a/src/main/java/com/caoccao/javet/exceptions/JavetError.java +++ b/src/main/java/com/caoccao/javet/exceptions/JavetError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,6 +129,24 @@ public class JavetError { * @since 0.8.5 */ public static final String PARAMETER_METHOD_NAME = "methodName"; + /** + * The constant PARAMETER_V8_MODULE_COUNT. + * + * @since 3.0.3 + */ + public static final String PARAMETER_V8_MODULE_COUNT = "v8ModuleCount"; + /** + * The constant PARAMETER_REFERENCE_COUNT. + * + * @since 3.0.3 + */ + public static final String PARAMETER_REFERENCE_COUNT = "referenceCount"; + /** + * The constant PARAMETER_CALLBACK_CONTEXT_COUNT. + * + * @since 3.0.3 + */ + public static final String PARAMETER_CALLBACK_CONTEXT_COUNT = "callbackContextCount"; /** * The constant PARAMETER_OS. * @@ -394,6 +412,23 @@ public class JavetError { */ public static final JavetError RuntimeOutOfMemory = new JavetError( 806, JavetErrorType.Runtime, "Runtime is out of memory because ${message} with ${heapStatistics}"); + /** + * The constant RuntimeCreateSnapshotDisabled. + * + * @since 3.0.3 + */ + public static final JavetError RuntimeCreateSnapshotDisabled = new JavetError( + 807, JavetErrorType.Runtime, "Runtime create snapshot is disabled"); + /** + * The constant RuntimeCreateSnapshotBlocked. + * + * @since 3.0.3 + */ + public static final JavetError RuntimeCreateSnapshotBlocked = new JavetError( + 808, JavetErrorType.Runtime, "Runtime create snapshot is blocked because of " + + "${callbackContextCount} callback context(s), " + + "${referenceCount} reference(s), " + + "${v8ModuleCount} module(s)"); /** * The constant EngineNotAvailable. * diff --git a/src/main/java/com/caoccao/javet/exceptions/JavetException.java b/src/main/java/com/caoccao/javet/exceptions/JavetException.java index 72eae70d9..e2deec7e3 100644 --- a/src/main/java/com/caoccao/javet/exceptions/JavetException.java +++ b/src/main/java/com/caoccao/javet/exceptions/JavetException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/exceptions/JavetExecutionException.java b/src/main/java/com/caoccao/javet/exceptions/JavetExecutionException.java index 529c0fd4b..f2bb4b2b2 100644 --- a/src/main/java/com/caoccao/javet/exceptions/JavetExecutionException.java +++ b/src/main/java/com/caoccao/javet/exceptions/JavetExecutionException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/exceptions/JavetOutOfMemoryException.java b/src/main/java/com/caoccao/javet/exceptions/JavetOutOfMemoryException.java index 278724240..74c25f076 100644 --- a/src/main/java/com/caoccao/javet/exceptions/JavetOutOfMemoryException.java +++ b/src/main/java/com/caoccao/javet/exceptions/JavetOutOfMemoryException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/exceptions/JavetScriptingError.java b/src/main/java/com/caoccao/javet/exceptions/JavetScriptingError.java index d68a420f4..071015158 100644 --- a/src/main/java/com/caoccao/javet/exceptions/JavetScriptingError.java +++ b/src/main/java/com/caoccao/javet/exceptions/JavetScriptingError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/exceptions/JavetTerminatedException.java b/src/main/java/com/caoccao/javet/exceptions/JavetTerminatedException.java index 0c876672d..8d3d56032 100644 --- a/src/main/java/com/caoccao/javet/exceptions/JavetTerminatedException.java +++ b/src/main/java/com/caoccao/javet/exceptions/JavetTerminatedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/exceptions/package-info.java b/src/main/java/com/caoccao/javet/exceptions/package-info.java index fc533f9e5..150a834ed 100644 --- a/src/main/java/com/caoccao/javet/exceptions/package-info.java +++ b/src/main/java/com/caoccao/javet/exceptions/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interception/BaseJavetDirectCallableInterceptor.java b/src/main/java/com/caoccao/javet/interception/BaseJavetDirectCallableInterceptor.java new file mode 100644 index 000000000..c43ddf9e2 --- /dev/null +++ b/src/main/java/com/caoccao/javet/interception/BaseJavetDirectCallableInterceptor.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023-2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.interception; + +import com.caoccao.javet.interop.V8Runtime; +import com.caoccao.javet.interop.callback.IJavetDirectCallable; + +/** + * The type Base javet direct callable interceptor. + * + * @since 3.0.3 + */ +public abstract class BaseJavetDirectCallableInterceptor + extends BaseJavetInterceptor + implements IJavetDirectCallable { + /** + * Instantiates a new Base javet direct callable interceptor. + * + * @param v8Runtime the V8 runtime + * @since 3.0.3 + */ + public BaseJavetDirectCallableInterceptor(V8Runtime v8Runtime) { + super(v8Runtime); + } +} diff --git a/src/main/java/com/caoccao/javet/interception/BaseJavetInterceptor.java b/src/main/java/com/caoccao/javet/interception/BaseJavetInterceptor.java index 57aaac846..471cf6c77 100644 --- a/src/main/java/com/caoccao/javet/interception/BaseJavetInterceptor.java +++ b/src/main/java/com/caoccao/javet/interception/BaseJavetInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interception/jvm/JavetJVMInterceptor.java b/src/main/java/com/caoccao/javet/interception/jvm/JavetJVMInterceptor.java new file mode 100644 index 000000000..68cbb8ce9 --- /dev/null +++ b/src/main/java/com/caoccao/javet/interception/jvm/JavetJVMInterceptor.java @@ -0,0 +1,446 @@ +/* + * Copyright (c) 2023-2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.interception.jvm; + +import com.caoccao.javet.exceptions.JavetException; +import com.caoccao.javet.interception.BaseJavetDirectCallableInterceptor; +import com.caoccao.javet.interfaces.IJavetUniFunction; +import com.caoccao.javet.interop.V8Runtime; +import com.caoccao.javet.interop.V8Scope; +import com.caoccao.javet.interop.callback.JavetCallbackContext; +import com.caoccao.javet.interop.callback.JavetCallbackType; +import com.caoccao.javet.interop.converters.JavetProxyConverter; +import com.caoccao.javet.interop.proxy.IJavetDirectProxyHandler; +import com.caoccao.javet.utils.StringUtils; +import com.caoccao.javet.values.V8Value; +import com.caoccao.javet.values.primitive.V8ValueString; +import com.caoccao.javet.values.reference.IV8ValueObject; +import com.caoccao.javet.values.reference.V8ValueArray; +import com.caoccao.javet.values.reference.V8ValueObject; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * The Javet JVM interceptor exposes the whole JVM as javet in V8. + * It must be accompanied by {@link JavetProxyConverter}. + *

    + * Usages: + * + * let sb = new javet.package.java.util.StringBuilder(); + * sb.append(123).append('abc'); + * sb.toString(); // 123abc + * sb = undefined; + * javet.v8.gc(); + * + * + * @since 3.0.3 + */ +public class JavetJVMInterceptor extends BaseJavetDirectCallableInterceptor { + /** + * The constant DEFAULT_NAME. + * + * @since 3.0.3 + */ + public static final String DEFAULT_NAME = "javet"; + /** + * The constant ERROR_THE_CONVERTER_MUST_BE_INSTANCE_OF_JAVET_PROXY_CONVERTER. + * + * @since 3.0.3 + */ + protected static final String ERROR_THE_CONVERTER_MUST_BE_INSTANCE_OF_JAVET_PROXY_CONVERTER = + "The converter must be instance of JavetProxyConverter."; + /** + * The constant JAVET_PROXY_CONVERTER. + * + * @since 3.0.3 + */ + protected static final JavetProxyConverter JAVET_PROXY_CONVERTER = new JavetProxyConverter(); + /** + * The constant JS_PROPERTY_PACKAGE. + * + * @since 3.0.3 + */ + protected static final String JS_PROPERTY_PACKAGE = "package"; + /** + * The constant JS_PROPERTY_V8. + * + * @since 3.0.3 + */ + protected static final String JS_PROPERTY_V8 = "v8"; + /** + * The Name injected in V8. + * + * @since 3.0.3 + */ + protected String name; + + /** + * Instantiates a new Javet JVM interceptor. + * + * @param v8Runtime the V8 runtime + * @since 3.0.3 + */ + public JavetJVMInterceptor(V8Runtime v8Runtime) { + super(v8Runtime); + assert v8Runtime.getConverter() instanceof JavetProxyConverter : ERROR_THE_CONVERTER_MUST_BE_INSTANCE_OF_JAVET_PROXY_CONVERTER; + name = DEFAULT_NAME; + } + + @Override + public JavetCallbackContext[] getCallbackContexts() { + return new JavetCallbackContext[]{ + new JavetCallbackContext( + JS_PROPERTY_V8, + this, JavetCallbackType.DirectCallGetterAndNoThis, + (GetterAndNoThis) () -> new JavetV8(v8Runtime).toV8Value()), + new JavetCallbackContext( + JS_PROPERTY_PACKAGE, + this, JavetCallbackType.DirectCallGetterAndNoThis, + (GetterAndNoThis) () -> new JavetVirtualPackage(v8Runtime, StringUtils.EMPTY).toV8Value()), + }; + } + + /** + * Gets name. + * + * @return the name + * @since 3.0.3 + */ + public String getName() { + return name; + } + + @Override + public boolean register(IV8ValueObject... iV8ValueObjects) throws JavetException { + boolean successful = true; + try (V8ValueObject v8ValueObject = v8Runtime.createV8ValueObject()) { + v8ValueObject.bind(this); + for (IV8ValueObject iV8ValueObject : iV8ValueObjects) { + successful = iV8ValueObject.set(DEFAULT_NAME, v8ValueObject) & successful; + } + return successful; + } + } + + /** + * Sets name. + * + * @param name the name + * @since 3.0.3 + */ + public void setName(String name) { + this.name = Objects.requireNonNull(name); + } + + @Override + public boolean unregister(IV8ValueObject... iV8ValueObjects) throws JavetException { + boolean successful = true; + for (IV8ValueObject iV8ValueObject : iV8ValueObjects) { + successful = iV8ValueObject.delete(DEFAULT_NAME) & successful; + } + return successful; + } + + /** + * The type Base javet package. + * + * @since 3.0.3 + */ + abstract static class BaseJavetPackage implements IJavetDirectProxyHandler { + /** + * The String getter map. + * + * @since 3.0.3 + */ + protected Map> stringGetterMap; + /** + * The V8 runtime. + * + * @since 3.0.3 + */ + protected V8Runtime v8Runtime; + + /** + * Instantiates a new Base javet package. + * + * @param v8Runtime the V8 runtime + * @since 3.0.3 + */ + public BaseJavetPackage(V8Runtime v8Runtime) { + this.v8Runtime = v8Runtime; + } + + /** + * Gets name. + * + * @return the name + * @since 3.0.3 + */ + public abstract String getName(); + + @Override + public V8Runtime getV8Runtime() { + return v8Runtime; + } + + /** + * Is valid. + * + * @return true : valid, false : invalid + * @since 3.0.3 + */ + public abstract boolean isValid(); + + @Override + public V8Value proxyGet(V8Value target, V8Value property, V8Value receiver) throws JavetException, Exception { + V8Value v8Value = IJavetDirectProxyHandler.super.proxyGet(target, property, receiver); + if (v8Value.isUndefined()) { + if (property instanceof V8ValueString) { + String childName = ((V8ValueString) property).getValue(); + if (!StringUtils.isEmpty(childName)) { + String name; + if (StringUtils.isEmpty(getName())) { + name = childName; + } else { + name = getName() + "." + childName; + } + try { + Class clazz = Class.forName(name); + v8Value = JAVET_PROXY_CONVERTER.toV8Value(v8Runtime, clazz); + } catch (Throwable ignored) { + Package namedPackage = Package.getPackage(name); + if (namedPackage != null) { + v8Value = new JavetPackage(v8Runtime, namedPackage).toV8Value(); + } else { + v8Value = new JavetVirtualPackage(v8Runtime, name).toV8Value(); + } + } + } + + } + } + return v8Value; + } + + @Override + public Map> proxyGetStringGetterMap() { + if (stringGetterMap == null) { + stringGetterMap = new HashMap<>(); + stringGetterMap.put(".getPackages", (propertyName) -> + v8Runtime.createV8ValueFunction( + new JavetCallbackContext( + propertyName, + this, JavetCallbackType.DirectCallNoThisAndResult, + (NoThisAndResult) (v8Values) -> { + final String prefix = getName() + "."; + try (V8Scope v8Scope = v8Runtime.getV8Scope()) { + V8ValueArray v8ValueArray = v8Runtime.createV8ValueArray(); + for (Package p : Stream.of(Package.getPackages()) + .filter((p) -> p.getName().startsWith(prefix)) + .filter((p) -> p.getName().substring(prefix.length()).contains(".")) + .collect(Collectors.toList())) { + v8ValueArray.push(new JavetPackage(v8Runtime, p).toV8Value()); + } + v8Scope.setEscapable(); + return v8ValueArray; + } + }))); + stringGetterMap.put(".name", (propertyName) -> v8Runtime.createV8ValueString(getName())); + stringGetterMap.put(".valid", (propertyName) -> v8Runtime.createV8ValueBoolean(isValid())); + } + return stringGetterMap; + } + + /** + * To V8 value V8 value. + * + * @return the V8 value + * @throws JavetException the javet exception + * @since 3.0.3 + */ + public V8Value toV8Value() throws JavetException { + return JAVET_PROXY_CONVERTER.toV8Value(v8Runtime, this); + } + } + + /** + * The type Javet package. + * + * @since 3.0.3 + */ + static class JavetPackage extends BaseJavetPackage { + /** + * The Named package. + * + * @since 3.0.3 + */ + protected Package namedPackage; + + /** + * Instantiates a new Javet package. + * + * @param v8Runtime the V8 runtime + * @param namedPackage the named package + * @since 3.0.3 + */ + public JavetPackage(V8Runtime v8Runtime, Package namedPackage) { + super(v8Runtime); + this.namedPackage = namedPackage; + stringGetterMap = null; + } + + @Override + public String getName() { + return namedPackage.getName(); + } + + @Override + public boolean isValid() { + return true; + } + + @Override + public Map> proxyGetStringGetterMap() { + if (stringGetterMap == null) { + stringGetterMap = super.proxyGetStringGetterMap(); + stringGetterMap.put( + ".implementationTitle", + (propertyName) -> v8Runtime.createV8ValueString(namedPackage.getImplementationTitle())); + stringGetterMap.put( + ".implementationVersion", + (propertyName) -> v8Runtime.createV8ValueString(namedPackage.getImplementationVersion())); + stringGetterMap.put( + ".implementationVendor", + (propertyName) -> v8Runtime.createV8ValueString(namedPackage.getImplementationVendor())); + stringGetterMap.put( + ".sealed", + (propertyName) -> v8Runtime.createV8ValueBoolean(namedPackage.isSealed())); + stringGetterMap.put( + ".specificationTitle", + (propertyName) -> v8Runtime.createV8ValueString(namedPackage.getSpecificationTitle())); + stringGetterMap.put( + ".specificationVersion", + (propertyName) -> v8Runtime.createV8ValueString(namedPackage.getSpecificationVersion())); + stringGetterMap.put( + ".specificationVendor", + (propertyName) -> v8Runtime.createV8ValueString(namedPackage.getSpecificationVendor())); + } + return stringGetterMap; + } + } + + /** + * The type Javet V8. + * + * @since 3.0.3 + */ + static class JavetV8 implements IJavetDirectProxyHandler { + /** + * The String getter map. + * + * @since 3.0.3 + */ + protected Map> stringGetterMap; + /** + * The V8 runtime. + * + * @since 3.0.3 + */ + protected V8Runtime v8Runtime; + + /** + * Instantiates a new Javet V8. + * + * @param v8Runtime the V8 runtime + * @since 3.0.3 + */ + public JavetV8(V8Runtime v8Runtime) { + this.v8Runtime = v8Runtime; + } + + @Override + public V8Runtime getV8Runtime() { + return v8Runtime; + } + + @Override + public Map> proxyGetStringGetterMap() { + if (stringGetterMap == null) { + stringGetterMap = new HashMap<>(); + stringGetterMap.put("gc", (propertyName) -> + v8Runtime.createV8ValueFunction( + new JavetCallbackContext( + propertyName, + this, JavetCallbackType.DirectCallNoThisAndNoResult, + (NoThisAndNoResult) (v8Values) -> v8Runtime.lowMemoryNotification()) + )); + } + return stringGetterMap; + } + + /** + * To V8 value V8 value. + * + * @return the V8 value + * @throws JavetException the javet exception + * @since 3.0.3 + */ + public V8Value toV8Value() throws JavetException { + return JAVET_PROXY_CONVERTER.toV8Value(v8Runtime, this); + } + } + + /** + * The type Javet virtual package. + * + * @since 3.0.3 + */ + static class JavetVirtualPackage extends BaseJavetPackage { + /** + * The Package name. + * + * @since 3.0.3 + */ + protected String packageName; + + /** + * Instantiates a new Javet virtual package. + * + * @param v8Runtime the V8 runtime + * @param packageName the package name + * @since 3.0.3 + */ + public JavetVirtualPackage(V8Runtime v8Runtime, String packageName) { + super(v8Runtime); + this.packageName = packageName; + } + + @Override + public String getName() { + return packageName; + } + + @Override + public boolean isValid() { + return false; + } + } +} diff --git a/src/main/java/com/caoccao/javet/interception/logging/BaseJavetConsoleInterceptor.java b/src/main/java/com/caoccao/javet/interception/logging/BaseJavetConsoleInterceptor.java index 3ec6b98f7..613cc0301 100644 --- a/src/main/java/com/caoccao/javet/interception/logging/BaseJavetConsoleInterceptor.java +++ b/src/main/java/com/caoccao/javet/interception/logging/BaseJavetConsoleInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,11 @@ package com.caoccao.javet.interception.logging; -import com.caoccao.javet.exceptions.JavetError; import com.caoccao.javet.exceptions.JavetException; -import com.caoccao.javet.interception.BaseJavetInterceptor; +import com.caoccao.javet.interception.BaseJavetDirectCallableInterceptor; import com.caoccao.javet.interop.V8Runtime; import com.caoccao.javet.interop.callback.JavetCallbackContext; -import com.caoccao.javet.utils.SimpleMap; +import com.caoccao.javet.interop.callback.JavetCallbackType; import com.caoccao.javet.utils.V8ValueUtils; import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.reference.IV8ValueObject; @@ -32,43 +31,7 @@ * * @since 0.7.0 */ -public abstract class BaseJavetConsoleInterceptor extends BaseJavetInterceptor { - /** - * The constant JAVA_CONSOLE_DEBUG. - * - * @since 0.7.0 - */ - protected static final String JAVA_CONSOLE_DEBUG = "consoleDebug"; - /** - * The constant JAVA_CONSOLE_ERROR. - * - * @since 0.7.0 - */ - protected static final String JAVA_CONSOLE_ERROR = "consoleError"; - /** - * The constant JAVA_CONSOLE_INFO. - * - * @since 0.7.0 - */ - protected static final String JAVA_CONSOLE_INFO = "consoleInfo"; - /** - * The constant JAVA_CONSOLE_LOG. - * - * @since 0.7.0 - */ - protected static final String JAVA_CONSOLE_LOG = "consoleLog"; - /** - * The constant JAVA_CONSOLE_TRACE. - * - * @since 0.7.0 - */ - protected static final String JAVA_CONSOLE_TRACE = "consoleTrace"; - /** - * The constant JAVA_CONSOLE_WARN. - * - * @since 0.7.0 - */ - protected static final String JAVA_CONSOLE_WARN = "consoleWarn"; +public abstract class BaseJavetConsoleInterceptor extends BaseJavetDirectCallableInterceptor { /** * The constant JS_FUNCTION_DEBUG. * @@ -187,45 +150,39 @@ public String concat(V8Value... v8Values) { */ public abstract void consoleWarn(V8Value... v8Values); + @Override + public JavetCallbackContext[] getCallbackContexts() { + return new JavetCallbackContext[]{ + new JavetCallbackContext( + JS_FUNCTION_DEBUG, this, JavetCallbackType.DirectCallNoThisAndNoResult, + (NoThisAndNoResult) this::consoleDebug), + new JavetCallbackContext( + JS_FUNCTION_ERROR, this, JavetCallbackType.DirectCallNoThisAndNoResult, + (NoThisAndNoResult) this::consoleError), + new JavetCallbackContext( + JS_FUNCTION_INFO, this, JavetCallbackType.DirectCallNoThisAndNoResult, + (NoThisAndNoResult) this::consoleInfo), + new JavetCallbackContext( + JS_FUNCTION_LOG, this, JavetCallbackType.DirectCallNoThisAndNoResult, + (NoThisAndNoResult) this::consoleLog), + new JavetCallbackContext( + JS_FUNCTION_TRACE, this, JavetCallbackType.DirectCallNoThisAndNoResult, + (NoThisAndNoResult) this::consoleTrace), + new JavetCallbackContext( + JS_FUNCTION_WARN, this, JavetCallbackType.DirectCallNoThisAndNoResult, + (NoThisAndNoResult) this::consoleWarn), + }; + } + @Override public boolean register(IV8ValueObject... iV8ValueObjects) throws JavetException { - try (V8ValueObject console = v8Runtime.createV8ValueObject()) { + boolean successful = true; + try (V8ValueObject v8ValueObject = v8Runtime.createV8ValueObject()) { + v8ValueObject.bind(this); for (IV8ValueObject iV8ValueObject : iV8ValueObjects) { - iV8ValueObject.set(PROPERTY_CONSOLE, console); - register(console, JS_FUNCTION_DEBUG, JAVA_CONSOLE_DEBUG); - register(console, JS_FUNCTION_ERROR, JAVA_CONSOLE_ERROR); - register(console, JS_FUNCTION_INFO, JAVA_CONSOLE_INFO); - register(console, JS_FUNCTION_LOG, JAVA_CONSOLE_LOG); - register(console, JS_FUNCTION_TRACE, JAVA_CONSOLE_TRACE); - register(console, JS_FUNCTION_WARN, JAVA_CONSOLE_WARN); + successful = iV8ValueObject.set(PROPERTY_CONSOLE, v8ValueObject) & successful; } - return true; - } - } - - /** - * Register a JS function by name. - * - * @param iV8ValueObject the V8 value object - * @param jsFunctionName the JS function name - * @param javaFunctionName the Java function name - * @throws JavetException the Javet exception - * @since 0.7.0 - */ - protected void register(IV8ValueObject iV8ValueObject, String jsFunctionName, String javaFunctionName) - throws JavetException { - try { - iV8ValueObject.bindFunction(new JavetCallbackContext( - jsFunctionName, - this, - getClass().getMethod(javaFunctionName, V8Value[].class))); - } catch (NoSuchMethodException e) { - throw new JavetException( - JavetError.CallbackRegistrationFailure, - SimpleMap.of( - JavetError.PARAMETER_METHOD_NAME, javaFunctionName, - JavetError.PARAMETER_MESSAGE, e.getMessage()), - e); + return successful; } } @@ -233,15 +190,7 @@ protected void register(IV8ValueObject iV8ValueObject, String jsFunctionName, St public boolean unregister(IV8ValueObject... iV8ValueObjects) throws JavetException { boolean successful = true; for (IV8ValueObject iV8ValueObject : iV8ValueObjects) { - try (V8ValueObject console = iV8ValueObject.get(PROPERTY_CONSOLE)) { - console.delete(JS_FUNCTION_DEBUG); - console.delete(JS_FUNCTION_ERROR); - console.delete(JS_FUNCTION_INFO); - console.delete(JS_FUNCTION_LOG); - console.delete(JS_FUNCTION_TRACE); - console.delete(JS_FUNCTION_WARN); - } - successful &= iV8ValueObject.delete(PROPERTY_CONSOLE); + successful = iV8ValueObject.delete(PROPERTY_CONSOLE) & successful; } return successful; } diff --git a/src/main/java/com/caoccao/javet/interception/logging/JavetStandardConsoleInterceptor.java b/src/main/java/com/caoccao/javet/interception/logging/JavetStandardConsoleInterceptor.java index 2a81f163d..33ce67019 100644 --- a/src/main/java/com/caoccao/javet/interception/logging/JavetStandardConsoleInterceptor.java +++ b/src/main/java/com/caoccao/javet/interception/logging/JavetStandardConsoleInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interception/logging/package-info.java b/src/main/java/com/caoccao/javet/interception/logging/package-info.java index 5f66d8132..ff9f96158 100644 --- a/src/main/java/com/caoccao/javet/interception/logging/package-info.java +++ b/src/main/java/com/caoccao/javet/interception/logging/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interception/package-info.java b/src/main/java/com/caoccao/javet/interception/package-info.java index 94fe93bac..5c297f885 100644 --- a/src/main/java/com/caoccao/javet/interception/package-info.java +++ b/src/main/java/com/caoccao/javet/interception/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IEnumBitset.java b/src/main/java/com/caoccao/javet/interfaces/IEnumBitset.java index b8e710e79..8da86b87a 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IEnumBitset.java +++ b/src/main/java/com/caoccao/javet/interfaces/IEnumBitset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavaFunction.java b/src/main/java/com/caoccao/javet/interfaces/IJavaFunction.java index 660489b7f..726482662 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavaFunction.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavaFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavaSupplier.java b/src/main/java/com/caoccao/javet/interfaces/IJavaSupplier.java index 9d8df3fea..c363d87fc 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavaSupplier.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavaSupplier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetAnonymous.java b/src/main/java/com/caoccao/javet/interfaces/IJavetAnonymous.java index de2136734..83f0dcf61 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetAnonymous.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetAnonymous.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetBiConsumer.java b/src/main/java/com/caoccao/javet/interfaces/IJavetBiConsumer.java index f4fa28f14..1dbb5acc1 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetBiConsumer.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetBiConsumer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetBiFunction.java b/src/main/java/com/caoccao/javet/interfaces/IJavetBiFunction.java index 34b199a98..a60c9b622 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetBiFunction.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetBiFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetBiIndexedConsumer.java b/src/main/java/com/caoccao/javet/interfaces/IJavetBiIndexedConsumer.java index f8acb60fa..b0960888e 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetBiIndexedConsumer.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetBiIndexedConsumer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetClosable.java b/src/main/java/com/caoccao/javet/interfaces/IJavetClosable.java index 9be0c4a11..6e9148f6e 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetClosable.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetClosable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetEntityFunction.java b/src/main/java/com/caoccao/javet/interfaces/IJavetEntityFunction.java index 18812f311..ecee740f4 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetEntityFunction.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetEntityFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetEntityMap.java b/src/main/java/com/caoccao/javet/interfaces/IJavetEntityMap.java index 35d1bd158..f3db580bc 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetEntityMap.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetEntityMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetInterceptor.java b/src/main/java/com/caoccao/javet/interfaces/IJavetInterceptor.java index 490330cb2..4be43982b 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetInterceptor.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetLogger.java b/src/main/java/com/caoccao/javet/interfaces/IJavetLogger.java index d407ae759..9559e2795 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetLogger.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetLogger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetMappable.java b/src/main/java/com/caoccao/javet/interfaces/IJavetMappable.java index 3c1b87aa0..5b433ba97 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetMappable.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetMappable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetResettable.java b/src/main/java/com/caoccao/javet/interfaces/IJavetResettable.java index cf2270696..3d4468d2a 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetResettable.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetResettable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetSupplier.java b/src/main/java/com/caoccao/javet/interfaces/IJavetSupplier.java index 42e7afff9..0a061383a 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetSupplier.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetSupplier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetUniConsumer.java b/src/main/java/com/caoccao/javet/interfaces/IJavetUniConsumer.java index e8378ab13..a429f121e 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetUniConsumer.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetUniConsumer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetUniFunction.java b/src/main/java/com/caoccao/javet/interfaces/IJavetUniFunction.java index f65d9ce7e..6cbc2edba 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetUniFunction.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetUniFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/IJavetUniIndexedConsumer.java b/src/main/java/com/caoccao/javet/interfaces/IJavetUniIndexedConsumer.java index 7f453d763..dc9fe11c9 100644 --- a/src/main/java/com/caoccao/javet/interfaces/IJavetUniIndexedConsumer.java +++ b/src/main/java/com/caoccao/javet/interfaces/IJavetUniIndexedConsumer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interfaces/package-info.java b/src/main/java/com/caoccao/javet/interfaces/package-info.java index 37492532f..0441ae555 100644 --- a/src/main/java/com/caoccao/javet/interfaces/package-info.java +++ b/src/main/java/com/caoccao/javet/interfaces/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/INodeNative.java b/src/main/java/com/caoccao/javet/interop/INodeNative.java index c8bb32607..bb49aefed 100644 --- a/src/main/java/com/caoccao/javet/interop/INodeNative.java +++ b/src/main/java/com/caoccao/javet/interop/INodeNative.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/IV8Cloneable.java b/src/main/java/com/caoccao/javet/interop/IV8Cloneable.java index 545fe06fc..61291aabf 100644 --- a/src/main/java/com/caoccao/javet/interop/IV8Cloneable.java +++ b/src/main/java/com/caoccao/javet/interop/IV8Cloneable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/IV8Convertible.java b/src/main/java/com/caoccao/javet/interop/IV8Convertible.java index 24a7dc62c..062f143d5 100644 --- a/src/main/java/com/caoccao/javet/interop/IV8Convertible.java +++ b/src/main/java/com/caoccao/javet/interop/IV8Convertible.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/IV8Creatable.java b/src/main/java/com/caoccao/javet/interop/IV8Creatable.java index 562ff68b4..f5849c990 100644 --- a/src/main/java/com/caoccao/javet/interop/IV8Creatable.java +++ b/src/main/java/com/caoccao/javet/interop/IV8Creatable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/IV8Executable.java b/src/main/java/com/caoccao/javet/interop/IV8Executable.java index be5ca65dd..7444c2bdd 100644 --- a/src/main/java/com/caoccao/javet/interop/IV8Executable.java +++ b/src/main/java/com/caoccao/javet/interop/IV8Executable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/IV8InspectorListener.java b/src/main/java/com/caoccao/javet/interop/IV8InspectorListener.java index ef221ca9c..1facf2248 100644 --- a/src/main/java/com/caoccao/javet/interop/IV8InspectorListener.java +++ b/src/main/java/com/caoccao/javet/interop/IV8InspectorListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/IV8Native.java b/src/main/java/com/caoccao/javet/interop/IV8Native.java index 13e777f4b..72817ac5d 100644 --- a/src/main/java/com/caoccao/javet/interop/IV8Native.java +++ b/src/main/java/com/caoccao/javet/interop/IV8Native.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -368,6 +368,8 @@ Object scriptExecute( void setWeak(long v8RuntimeHandle, long v8ValueHandle, int v8ValueType, Object objectReference); + byte[] snapshotCreate(long v8RuntimeHandle); + boolean strictEquals(long v8RuntimeHandle, long v8ValueHandle1, long v8ValueHandle2); Object symbolCreate(long v8RuntimeHandle, String description); diff --git a/src/main/java/com/caoccao/javet/interop/JavetClassLoader.java b/src/main/java/com/caoccao/javet/interop/JavetClassLoader.java index fd279e28b..38012816f 100644 --- a/src/main/java/com/caoccao/javet/interop/JavetClassLoader.java +++ b/src/main/java/com/caoccao/javet/interop/JavetClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/NodeNative.java b/src/main/java/com/caoccao/javet/interop/NodeNative.java index df6e9466e..41f4d4eb4 100644 --- a/src/main/java/com/caoccao/javet/interop/NodeNative.java +++ b/src/main/java/com/caoccao/javet/interop/NodeNative.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/NodeRuntime.java b/src/main/java/com/caoccao/javet/interop/NodeRuntime.java index 8de75debe..d964e9dc0 100644 --- a/src/main/java/com/caoccao/javet/interop/NodeRuntime.java +++ b/src/main/java/com/caoccao/javet/interop/NodeRuntime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.caoccao.javet.annotations.CheckReturnValue; import com.caoccao.javet.annotations.NodeModule; import com.caoccao.javet.enums.JSRuntimeType; +import com.caoccao.javet.exceptions.JavetError; import com.caoccao.javet.exceptions.JavetException; import com.caoccao.javet.interop.options.RuntimeOptions; import com.caoccao.javet.node.modules.INodeModule; @@ -80,6 +81,11 @@ public class NodeRuntime extends V8Runtime { nodeModuleMap = new HashMap<>(); } + @Override + public byte[] createSnapshot() throws JavetException { + throw new JavetException(JavetError.RuntimeCreateSnapshotDisabled); + } + @Override public JSRuntimeType getJSRuntimeType() { return JSRuntimeType.Node; diff --git a/src/main/java/com/caoccao/javet/interop/V8Host.java b/src/main/java/com/caoccao/javet/interop/V8Host.java index 8ea519d59..9904b6f78 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Host.java +++ b/src/main/java/com/caoccao/javet/interop/V8Host.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/V8Inspector.java b/src/main/java/com/caoccao/javet/interop/V8Inspector.java index e0ce6a689..27822dd2d 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Inspector.java +++ b/src/main/java/com/caoccao/javet/interop/V8Inspector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,10 @@ import com.caoccao.javet.exceptions.JavetException; import com.caoccao.javet.interfaces.IJavetLogger; +import com.caoccao.javet.utils.SimpleList; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -41,8 +42,7 @@ public final class V8Inspector { } public void addListeners(IV8InspectorListener... listeners) { - Objects.requireNonNull(listeners); - this.listeners.addAll(Arrays.asList(listeners)); + Collections.addAll(this.listeners, Objects.requireNonNull(listeners)); } public void flushProtocolNotifications() { @@ -87,8 +87,7 @@ public void receiveResponse(String message) { } public void removeListeners(IV8InspectorListener... listeners) { - Objects.requireNonNull(listeners); - this.listeners.removeAll(Arrays.asList(listeners)); + this.listeners.removeAll(SimpleList.of(listeners)); } public void runIfWaitingForDebugger(int contextGroupId) { diff --git a/src/main/java/com/caoccao/javet/interop/V8Internal.java b/src/main/java/com/caoccao/javet/interop/V8Internal.java index 8e79d539c..d5f024573 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Internal.java +++ b/src/main/java/com/caoccao/javet/interop/V8Internal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/V8Locker.java b/src/main/java/com/caoccao/javet/interop/V8Locker.java index 1e35cf4c4..cca97e3de 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Locker.java +++ b/src/main/java/com/caoccao/javet/interop/V8Locker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/V8Native.java b/src/main/java/com/caoccao/javet/interop/V8Native.java index 8ea12ac18..d0f381272 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Native.java +++ b/src/main/java/com/caoccao/javet/interop/V8Native.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -558,6 +558,9 @@ public native Object scriptExecute( @Override public native void setWeak(long v8RuntimeHandle, long v8ValueHandle, int v8ValueType, Object objectReference); + @Override + public native byte[] snapshotCreate(long v8RuntimeHandle); + @Override public native boolean strictEquals(long v8RuntimeHandle, long v8ValueHandle1, long v8ValueHandle2); diff --git a/src/main/java/com/caoccao/javet/interop/V8Notifier.java b/src/main/java/com/caoccao/javet/interop/V8Notifier.java index 1b745cb02..667c4771c 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Notifier.java +++ b/src/main/java/com/caoccao/javet/interop/V8Notifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/V8Runtime.java b/src/main/java/com/caoccao/javet/interop/V8Runtime.java index 461396319..a08e2e4db 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Runtime.java +++ b/src/main/java/com/caoccao/javet/interop/V8Runtime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import com.caoccao.javet.utils.JavetDefaultLogger; import com.caoccao.javet.utils.JavetResourceUtils; import com.caoccao.javet.utils.SimpleMap; +import com.caoccao.javet.utils.StringUtils; import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.primitive.*; import com.caoccao.javet.values.reference.*; @@ -49,7 +50,6 @@ import java.text.MessageFormat; import java.time.ZonedDateTime; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import static com.caoccao.javet.exceptions.JavetError.PARAMETER_FEATURE; @@ -181,6 +181,12 @@ public class V8Runtime implements IJavetClosable, IV8Creatable, IV8Convertible { * @since 2.2.0 */ final boolean[] primitiveFlags; + /** + * The Reference lock. + * + * @since 0.9.12 + */ + final Object referenceLock; /** * The Reference map. * @@ -326,7 +332,8 @@ public class V8Runtime implements IJavetClosable, IV8Creatable, IV8Convertible { this.pooled = pooled; primitiveFlags = new boolean[1]; promiseRejectCallback = new JavetPromiseRejectCallback(logger); - referenceMap = new ConcurrentHashMap<>(); + referenceLock = new Object(); + referenceMap = new HashMap<>(); this.v8Host = Objects.requireNonNull(v8Host); v8Inspector = null; this.v8Native = Objects.requireNonNull(v8Native); @@ -376,7 +383,9 @@ public void addGCPrologueCallback(IJavetGCCallback iJavetGCCallback) { * @since 1.0.3 */ void addReference(IV8ValueReference iV8ValueReference) { - referenceMap.put(iV8ValueReference.getHandle(), iV8ValueReference); + synchronized (referenceLock) { + referenceMap.put(iV8ValueReference.getHandle(), iV8ValueReference); + } } /** @@ -560,7 +569,7 @@ public V8Module compileV8Module( String scriptString, byte[] cachedData, V8ScriptOrigin v8ScriptOrigin, boolean resultRequired) throws JavetException { v8ScriptOrigin.setModule(true); - if (v8ScriptOrigin.getResourceName() == null || v8ScriptOrigin.getResourceName().isEmpty()) { + if (StringUtils.isEmpty(v8ScriptOrigin.getResourceName())) { throw new JavetException(JavetError.ModuleNameEmpty); } Object result = v8Native.moduleCompile( @@ -693,11 +702,35 @@ boolean contextSetLength(IV8Context iV8Context, int length) throws JavetExceptio return v8Native.contextSetLength(handle, iV8Context.getHandle(), iV8Context.getType().getId(), length); } + /** + * Create snapshot in byte array. + * + * @return the byte array + * @throws JavetException the javet exception + * @see Custom startup snapshots + * @since 3.0.3 + */ + public byte[] createSnapshot() throws JavetException { + if (!runtimeOptions.isCreateSnapshotEnabled()) { + throw new JavetException(JavetError.RuntimeCreateSnapshotDisabled); + } + final int callbackContextCount = getCallbackContextCount(); + final int referenceCount = getReferenceCount(); + final int v8ModuleCount = getV8ModuleCount(); + if (callbackContextCount > 0 || referenceCount > 0 || v8ModuleCount > 0) { + throw new JavetException(JavetError.RuntimeCreateSnapshotBlocked, SimpleMap.of( + JavetError.PARAMETER_CALLBACK_CONTEXT_COUNT, callbackContextCount, + JavetError.PARAMETER_REFERENCE_COUNT, referenceCount, + JavetError.PARAMETER_V8_MODULE_COUNT, v8ModuleCount)); + } + return v8Native.snapshotCreate(handle); + } + @Override @SuppressWarnings("RedundantThrows") @CheckReturnValue public V8Module createV8Module(String moduleName, IV8ValueObject iV8ValueObject) throws JavetException { - if (moduleName == null || moduleName.isEmpty()) { + if (StringUtils.isEmpty(moduleName)) { throw new JavetException(JavetError.ModuleNameEmpty); } Objects.requireNonNull(iV8ValueObject); @@ -851,7 +884,7 @@ public V8ValueString createV8ValueString(String str) throws JavetException { @Override @CheckReturnValue public V8ValueSymbol createV8ValueSymbol(String description, boolean global) throws JavetException { - assert description != null && !description.isEmpty() : ERROR_SYMBOL_DESCRIPTION_CANNOT_BE_EMPTY; + assert !StringUtils.isEmpty(description) : ERROR_SYMBOL_DESCRIPTION_CANNOT_BE_EMPTY; if (global) { try (V8ValueBuiltInSymbol v8ValueBuiltInSymbol = getGlobalObject().getBuiltInSymbol()) { return v8ValueBuiltInSymbol._for(description); @@ -1462,7 +1495,7 @@ public V8Locker getV8Locker() throws JavetException { @CheckReturnValue IV8Module getV8Module(String resourceName, IV8Module v8ModuleReferrer) throws JavetException { IV8Module iV8Module = null; - if (resourceName != null && !resourceName.isEmpty()) { + if (!StringUtils.isEmpty(resourceName)) { synchronized (v8ModuleLock) { iV8Module = v8ModuleMap.get(resourceName); } @@ -2954,12 +2987,14 @@ void removeJNIGlobalRef(long handle) { @SuppressWarnings("RedundantThrows") void removeReference(IV8ValueReference iV8ValueReference) throws JavetException { final long referenceHandle = iV8ValueReference.getHandle(); - if (referenceMap.remove(referenceHandle) != null) { - final int referenceType = iV8ValueReference.getType().getId(); - if (referenceType == V8ValueReferenceType.Module.getId()) { - removeV8Module((IV8Module) iV8ValueReference); + synchronized (referenceLock) { + if (referenceMap.remove(referenceHandle) != null) { + final int referenceType = iV8ValueReference.getType().getId(); + if (referenceType == V8ValueReferenceType.Module.getId()) { + removeV8Module((IV8Module) iV8ValueReference); + } + v8Native.removeReferenceHandle(handle, referenceHandle, referenceType); } - v8Native.removeReferenceHandle(handle, referenceHandle, referenceType); } if (gcScheduled) { lowMemoryNotification(); @@ -2974,31 +3009,33 @@ void removeReference(IV8ValueReference iV8ValueReference) throws JavetException * @since 0.7.0 */ void removeReferences() throws JavetException { - if (!referenceMap.isEmpty()) { - final int referenceCount = getReferenceCount(); - final int v8ModuleCount = getV8ModuleCount(); - int weakReferenceCount = 0; - for (IV8ValueReference iV8ValueReference : new ArrayList<>(referenceMap.values())) { - if (iV8ValueReference instanceof IV8ValueObject) { - IV8ValueObject iV8ValueObject = (IV8ValueObject) iV8ValueReference; - if (iV8ValueObject.isWeak()) { - ++weakReferenceCount; + synchronized (referenceLock) { + if (!referenceMap.isEmpty()) { + final int referenceCount = getReferenceCount(); + final int v8ModuleCount = getV8ModuleCount(); + int weakReferenceCount = 0; + for (IV8ValueReference iV8ValueReference : new ArrayList<>(referenceMap.values())) { + if (iV8ValueReference instanceof IV8ValueObject) { + IV8ValueObject iV8ValueObject = (IV8ValueObject) iV8ValueReference; + if (iV8ValueObject.isWeak()) { + ++weakReferenceCount; + } } + iV8ValueReference.close(true); } - iV8ValueReference.close(true); - } - if (v8ModuleCount + weakReferenceCount < referenceCount) { - logger.logWarn("{0} V8 object(s) not recycled, {1} weak, {2} module(s).", - Integer.toString(referenceCount), - Integer.toString(weakReferenceCount), - Integer.toString(v8ModuleCount)); - } else { - logger.logDebug("{0} V8 object(s) not recycled, {1} weak, {2} module(s).", - Integer.toString(referenceCount), - Integer.toString(weakReferenceCount), - Integer.toString(v8ModuleCount)); + if (v8ModuleCount + weakReferenceCount < referenceCount) { + logger.logWarn("{0} V8 object(s) not recycled, {1} weak, {2} module(s).", + Integer.toString(referenceCount), + Integer.toString(weakReferenceCount), + Integer.toString(v8ModuleCount)); + } else { + logger.logDebug("{0} V8 object(s) not recycled, {1} weak, {2} module(s).", + Integer.toString(referenceCount), + Integer.toString(weakReferenceCount), + Integer.toString(v8ModuleCount)); + } + referenceMap.clear(); } - referenceMap.clear(); } } diff --git a/src/main/java/com/caoccao/javet/interop/V8Scope.java b/src/main/java/com/caoccao/javet/interop/V8Scope.java index 849a6b603..2b193c2c8 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Scope.java +++ b/src/main/java/com/caoccao/javet/interop/V8Scope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/V8ScriptOrigin.java b/src/main/java/com/caoccao/javet/interop/V8ScriptOrigin.java index 11e6a30ba..72143ed08 100644 --- a/src/main/java/com/caoccao/javet/interop/V8ScriptOrigin.java +++ b/src/main/java/com/caoccao/javet/interop/V8ScriptOrigin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/binding/BindingContext.java b/src/main/java/com/caoccao/javet/interop/binding/BindingContext.java index 7079cac4c..cb9bcd65e 100644 --- a/src/main/java/com/caoccao/javet/interop/binding/BindingContext.java +++ b/src/main/java/com/caoccao/javet/interop/binding/BindingContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/binding/ClassDescriptor.java b/src/main/java/com/caoccao/javet/interop/binding/ClassDescriptor.java index 8c6a670cc..7c8655822 100644 --- a/src/main/java/com/caoccao/javet/interop/binding/ClassDescriptor.java +++ b/src/main/java/com/caoccao/javet/interop/binding/ClassDescriptor.java @@ -91,6 +91,12 @@ public class ClassDescriptor { * @since 0.9.6 */ protected Class targetClass; + /** + * The Target type list. + * + * @since 3.0.3 + */ + protected boolean targetTypeList; /** * The target type map. * @@ -128,8 +134,13 @@ public ClassDescriptor(V8ProxyMode proxyMode, Class targetClass) { this.proxyMode = proxyMode; settersMap = new LinkedHashMap<>(); this.targetClass = targetClass; - targetTypeMap = Map.class.isAssignableFrom(targetClass); - targetTypeSet = Set.class.isAssignableFrom(targetClass); + targetTypeList = List.class.isAssignableFrom(targetClass); + if (!targetTypeList) { + targetTypeMap = Map.class.isAssignableFrom(targetClass); + if (!targetTypeMap) { + targetTypeSet = Set.class.isAssignableFrom(targetClass); + } + } uniqueKeySet = new LinkedHashSet<>(); } @@ -255,6 +266,16 @@ public Set getUniqueKeySet() { return uniqueKeySet; } + /** + * Is target type list. + * + * @return true: is a list, false: is not a list + * @since 3.0.3 + */ + public boolean isTargetTypeList() { + return targetTypeList; + } + /** * Is target type map. * diff --git a/src/main/java/com/caoccao/javet/interop/binding/MethodDescriptor.java b/src/main/java/com/caoccao/javet/interop/binding/MethodDescriptor.java index 195fe1936..2aac03471 100644 --- a/src/main/java/com/caoccao/javet/interop/binding/MethodDescriptor.java +++ b/src/main/java/com/caoccao/javet/interop/binding/MethodDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/binding/package-info.java b/src/main/java/com/caoccao/javet/interop/binding/package-info.java index a338a1371..77d0e05e3 100644 --- a/src/main/java/com/caoccao/javet/interop/binding/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/binding/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/IJavetDirectCallable.java b/src/main/java/com/caoccao/javet/interop/callback/IJavetDirectCallable.java index a5cdcebb5..293cf05c4 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/IJavetDirectCallable.java +++ b/src/main/java/com/caoccao/javet/interop/callback/IJavetDirectCallable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/IJavetGCCallback.java b/src/main/java/com/caoccao/javet/interop/callback/IJavetGCCallback.java index 5d7e4261b..7e2ac33c7 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/IJavetGCCallback.java +++ b/src/main/java/com/caoccao/javet/interop/callback/IJavetGCCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/IJavetPromiseRejectCallback.java b/src/main/java/com/caoccao/javet/interop/callback/IJavetPromiseRejectCallback.java index 3274e0f10..4ff969008 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/IJavetPromiseRejectCallback.java +++ b/src/main/java/com/caoccao/javet/interop/callback/IJavetPromiseRejectCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/IV8ModuleResolver.java b/src/main/java/com/caoccao/javet/interop/callback/IV8ModuleResolver.java index f1f4bdc43..84e713fb7 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/IV8ModuleResolver.java +++ b/src/main/java/com/caoccao/javet/interop/callback/IV8ModuleResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/JavetBuiltInModuleResolver.java b/src/main/java/com/caoccao/javet/interop/callback/JavetBuiltInModuleResolver.java index 29e15a7d5..42f4f6ff0 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/JavetBuiltInModuleResolver.java +++ b/src/main/java/com/caoccao/javet/interop/callback/JavetBuiltInModuleResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/JavetCallbackContext.java b/src/main/java/com/caoccao/javet/interop/callback/JavetCallbackContext.java index d57c3a300..24af71119 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/JavetCallbackContext.java +++ b/src/main/java/com/caoccao/javet/interop/callback/JavetCallbackContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/JavetCallbackType.java b/src/main/java/com/caoccao/javet/interop/callback/JavetCallbackType.java index 714b1a42e..f93875b98 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/JavetCallbackType.java +++ b/src/main/java/com/caoccao/javet/interop/callback/JavetCallbackType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/JavetGCCallback.java b/src/main/java/com/caoccao/javet/interop/callback/JavetGCCallback.java index 3b5b3d628..3e5d57118 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/JavetGCCallback.java +++ b/src/main/java/com/caoccao/javet/interop/callback/JavetGCCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/JavetPromiseRejectCallback.java b/src/main/java/com/caoccao/javet/interop/callback/JavetPromiseRejectCallback.java index 13f432d6e..1a9df332f 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/JavetPromiseRejectCallback.java +++ b/src/main/java/com/caoccao/javet/interop/callback/JavetPromiseRejectCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/V8FunctionCallback.java b/src/main/java/com/caoccao/javet/interop/callback/V8FunctionCallback.java index bd74dd4cf..5f6e1a611 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/V8FunctionCallback.java +++ b/src/main/java/com/caoccao/javet/interop/callback/V8FunctionCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/callback/package-info.java b/src/main/java/com/caoccao/javet/interop/callback/package-info.java index 9a485cc45..cf43fc35e 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/callback/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/converters/BaseJavetConverter.java b/src/main/java/com/caoccao/javet/interop/converters/BaseJavetConverter.java index dfae07293..ba68ec8a0 100644 --- a/src/main/java/com/caoccao/javet/interop/converters/BaseJavetConverter.java +++ b/src/main/java/com/caoccao/javet/interop/converters/BaseJavetConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/converters/IJavetConverter.java b/src/main/java/com/caoccao/javet/interop/converters/IJavetConverter.java index adbcfeea1..889ed9c32 100644 --- a/src/main/java/com/caoccao/javet/interop/converters/IJavetConverter.java +++ b/src/main/java/com/caoccao/javet/interop/converters/IJavetConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/converters/JavetBridgeConverter.java b/src/main/java/com/caoccao/javet/interop/converters/JavetBridgeConverter.java index 332aa7337..45a337b41 100644 --- a/src/main/java/com/caoccao/javet/interop/converters/JavetBridgeConverter.java +++ b/src/main/java/com/caoccao/javet/interop/converters/JavetBridgeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/converters/JavetConverterConfig.java b/src/main/java/com/caoccao/javet/interop/converters/JavetConverterConfig.java index a76c7fcef..e9aad9dcf 100644 --- a/src/main/java/com/caoccao/javet/interop/converters/JavetConverterConfig.java +++ b/src/main/java/com/caoccao/javet/interop/converters/JavetConverterConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,6 +91,12 @@ public class JavetConverterConfig> { * @since 0.9.3 */ protected int maxDepth; + /** + * The Proxy list enabled. + * + * @since 3.0.3 + */ + protected boolean proxyListEnabled; /** * The Proxy map enabled. * @@ -130,10 +136,12 @@ public JavetConverterConfig() { defaultInt = 0; defaultLong = 0L; defaultShort = 0; - reflectionObjectFactory = null; extractFunctionSourceCode = false; maxDepth = DEFAULT_MAX_DEPTH; + proxyListEnabled = false; proxyMapEnabled = false; + proxySetEnabled = false; + reflectionObjectFactory = null; skipFunctionInObject = true; } @@ -238,19 +246,29 @@ public IJavetReflectionObjectFactory getReflectionObjectFactory() { } /** - * Is extract function source code boolean. + * Is extract function source code. * - * @return the boolean + * @return true : extract, false : skip * @since 0.9.4 */ public boolean isExtractFunctionSourceCode() { return extractFunctionSourceCode; } + /** + * Is proxy list enabled. + * + * @return true : enabled, false : disabled + * @since 3.0.3 + */ + public boolean isProxyListEnabled() { + return proxyListEnabled; + } + /** * Is proxy map enabled. * - * @return the boolean + * @return true : enabled, false : disabled * @since 0.9.6 */ public boolean isProxyMapEnabled() { @@ -260,7 +278,7 @@ public boolean isProxyMapEnabled() { /** * Is proxy set enabled. * - * @return the boolean + * @return true : enabled, false : disabled * @since 0.9.8 */ public boolean isProxySetEnabled() { @@ -268,9 +286,9 @@ public boolean isProxySetEnabled() { } /** - * Is skip functions boolean. + * Is skip functions. * - * @return the boolean + * @return true : skip, false : not skip * @since 0.9.4 */ public boolean isSkipFunctionInObject() { @@ -407,6 +425,19 @@ public JavetConverterConfig setMaxDepth(int maxDepth) { return this; } + /** + * Sets proxy list enabled. + * + * @param proxyListEnabled the proxy list enabled + * @return the self + * @since 3.0.3 + */ + @SuppressWarnings("UnusedReturnValue") + public JavetConverterConfig setProxyListEnabled(boolean proxyListEnabled) { + this.proxyListEnabled = proxyListEnabled; + return this; + } + /** * Sets proxy map enabled. * diff --git a/src/main/java/com/caoccao/javet/interop/converters/JavetObjectConverter.java b/src/main/java/com/caoccao/javet/interop/converters/JavetObjectConverter.java index 2a58654d4..1a2c587e5 100644 --- a/src/main/java/com/caoccao/javet/interop/converters/JavetObjectConverter.java +++ b/src/main/java/com/caoccao/javet/interop/converters/JavetObjectConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import com.caoccao.javet.interop.V8Scope; import com.caoccao.javet.interop.callback.JavetCallbackContext; import com.caoccao.javet.interop.proxy.IJavetProxyHandler; -import com.caoccao.javet.interop.proxy.JavetReflectionProxyObjectHandler; import com.caoccao.javet.utils.JavetResourceUtils; import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.reference.*; @@ -338,61 +337,29 @@ protected T toV8Value( v8Scope.setEscapable(); } } else if (object instanceof Map) { - if (config.isProxyMapEnabled()) { - try (V8Scope v8Scope = v8Runtime.getV8Scope()) { - V8ValueProxy v8ValueProxy = v8Scope.createV8ValueProxy(); - try (IV8ValueObject iV8ValueObjectHandler = v8ValueProxy.getHandler()) { - JavetReflectionProxyObjectHandler, ?> javetProxyHandler = - new JavetReflectionProxyObjectHandler<>(v8Runtime, null, (Map) object); - List javetCallbackContexts = - iV8ValueObjectHandler.bind(javetProxyHandler); - iV8ValueObjectHandler.setPrivateProperty( - PRIVATE_PROPERTY_PROXY_TARGET, javetCallbackContexts.get(0).getHandle()); - } - v8Value = v8ValueProxy; - v8Scope.setEscapable(); - } - } else { - try (V8Scope v8Scope = v8Runtime.getV8Scope()) { - V8ValueObject v8ValueObject = v8Scope.createV8ValueObject(); - final Map mapObject = (Map) object; - for (Object key : mapObject.keySet()) { - try (V8Value childV8Value = toV8Value(v8Runtime, mapObject.get(key), depth + 1)) { - String childStringKey = key instanceof String ? (String) key : key.toString(); - v8ValueObject.set(childStringKey, childV8Value); - } + try (V8Scope v8Scope = v8Runtime.getV8Scope()) { + V8ValueObject v8ValueObject = v8Scope.createV8ValueObject(); + final Map mapObject = (Map) object; + for (Object key : mapObject.keySet()) { + try (V8Value childV8Value = toV8Value(v8Runtime, mapObject.get(key), depth + 1)) { + String childStringKey = key instanceof String ? (String) key : key.toString(); + v8ValueObject.set(childStringKey, childV8Value); } - v8Value = v8ValueObject; - v8Scope.setEscapable(); } + v8Value = v8ValueObject; + v8Scope.setEscapable(); } } else if (object instanceof Set) { - if (config.isProxySetEnabled()) { - try (V8Scope v8Scope = v8Runtime.getV8Scope()) { - V8ValueProxy v8ValueProxy = v8Scope.createV8ValueProxy(); - try (IV8ValueObject iV8ValueObjectHandler = v8ValueProxy.getHandler()) { - JavetReflectionProxyObjectHandler, ?> javetProxyHandler = - new JavetReflectionProxyObjectHandler<>(v8Runtime, null, (Set) object); - List javetCallbackContexts = - iV8ValueObjectHandler.bind(javetProxyHandler); - iV8ValueObjectHandler.setPrivateProperty( - PRIVATE_PROPERTY_PROXY_TARGET, javetCallbackContexts.get(0).getHandle()); - } - v8Value = v8ValueProxy; - v8Scope.setEscapable(); - } - } else { - try (V8Scope v8Scope = v8Runtime.getV8Scope()) { - V8ValueSet v8ValueSet = v8Scope.createV8ValueSet(); - final Set setObject = (Set) object; - for (Object item : setObject) { - try (V8Value childV8Value = toV8Value(v8Runtime, item, depth + 1)) { - v8ValueSet.add(childV8Value); - } + try (V8Scope v8Scope = v8Runtime.getV8Scope()) { + V8ValueSet v8ValueSet = v8Scope.createV8ValueSet(); + final Set setObject = (Set) object; + for (Object item : setObject) { + try (V8Value childV8Value = toV8Value(v8Runtime, item, depth + 1)) { + v8ValueSet.add(childV8Value); } - v8Value = v8ValueSet; - v8Scope.setEscapable(); } + v8Value = v8ValueSet; + v8Scope.setEscapable(); } } else if (object instanceof Collection) { try (V8Scope v8Scope = v8Runtime.getV8Scope()) { diff --git a/src/main/java/com/caoccao/javet/interop/converters/JavetPrimitiveConverter.java b/src/main/java/com/caoccao/javet/interop/converters/JavetPrimitiveConverter.java index 89a6383e9..06fb4a3a4 100644 --- a/src/main/java/com/caoccao/javet/interop/converters/JavetPrimitiveConverter.java +++ b/src/main/java/com/caoccao/javet/interop/converters/JavetPrimitiveConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/converters/JavetProxyConverter.java b/src/main/java/com/caoccao/javet/interop/converters/JavetProxyConverter.java index e3ff5fc0c..d1de6eeca 100644 --- a/src/main/java/com/caoccao/javet/interop/converters/JavetProxyConverter.java +++ b/src/main/java/com/caoccao/javet/interop/converters/JavetProxyConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,8 @@ import com.caoccao.javet.values.reference.V8ValueProxy; import java.util.List; +import java.util.Map; +import java.util.Set; /** * The type Javet proxy converter converts most of Java objects to @@ -149,9 +151,14 @@ protected T toV8Value( if (object instanceof V8Value) { return (T) object; } - V8Value v8Value = super.toV8Value(v8Runtime, object, depth); - if (v8Value != null && !(v8Value.isUndefined())) { - return (T) v8Value; + boolean proxyRequired = config.isProxyListEnabled() && object instanceof List; + proxyRequired = proxyRequired || (config.isProxyMapEnabled() && object instanceof Map); + proxyRequired = proxyRequired || (config.isProxySetEnabled() && object instanceof Set); + if (!proxyRequired) { + V8Value v8Value = super.toV8Value(v8Runtime, object, depth); + if (v8Value != null && !(v8Value.isUndefined())) { + return (T) v8Value; + } } return toProxiedV8Value(v8Runtime, object); } diff --git a/src/main/java/com/caoccao/javet/interop/converters/package-info.java b/src/main/java/com/caoccao/javet/interop/converters/package-info.java index a1f7bd7c6..9202ce42d 100644 --- a/src/main/java/com/caoccao/javet/interop/converters/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/converters/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/IJavetEngine.java b/src/main/java/com/caoccao/javet/interop/engine/IJavetEngine.java index d5a5599eb..c74b49acb 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/IJavetEngine.java +++ b/src/main/java/com/caoccao/javet/interop/engine/IJavetEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/IJavetEngineGuard.java b/src/main/java/com/caoccao/javet/interop/engine/IJavetEngineGuard.java index 92d42eab4..92726f7b5 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/IJavetEngineGuard.java +++ b/src/main/java/com/caoccao/javet/interop/engine/IJavetEngineGuard.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/IJavetEnginePool.java b/src/main/java/com/caoccao/javet/interop/engine/IJavetEnginePool.java index 9f9969863..d50a72e35 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/IJavetEnginePool.java +++ b/src/main/java/com/caoccao/javet/interop/engine/IJavetEnginePool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/JavetEngine.java b/src/main/java/com/caoccao/javet/interop/engine/JavetEngine.java index 56fe35064..019623cf9 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/JavetEngine.java +++ b/src/main/java/com/caoccao/javet/interop/engine/JavetEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/JavetEngineConfig.java b/src/main/java/com/caoccao/javet/interop/engine/JavetEngineConfig.java index 05dcc8dea..d8eb0e900 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/JavetEngineConfig.java +++ b/src/main/java/com/caoccao/javet/interop/engine/JavetEngineConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/JavetEngineGuard.java b/src/main/java/com/caoccao/javet/interop/engine/JavetEngineGuard.java index 27a6613ae..e28f890cc 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/JavetEngineGuard.java +++ b/src/main/java/com/caoccao/javet/interop/engine/JavetEngineGuard.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/JavetEnginePool.java b/src/main/java/com/caoccao/javet/interop/engine/JavetEnginePool.java index afe64c26d..c277971b7 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/JavetEnginePool.java +++ b/src/main/java/com/caoccao/javet/interop/engine/JavetEnginePool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/JavetEngineUsage.java b/src/main/java/com/caoccao/javet/interop/engine/JavetEngineUsage.java index f070cb0cf..4ee433a69 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/JavetEngineUsage.java +++ b/src/main/java/com/caoccao/javet/interop/engine/JavetEngineUsage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/observers/IV8RuntimeObserver.java b/src/main/java/com/caoccao/javet/interop/engine/observers/IV8RuntimeObserver.java index 4b6e2c5f5..4cd420b24 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/observers/IV8RuntimeObserver.java +++ b/src/main/java/com/caoccao/javet/interop/engine/observers/IV8RuntimeObserver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageCallbackContextCount.java b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageCallbackContextCount.java index 5d993ceaf..6ff1bed37 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageCallbackContextCount.java +++ b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageCallbackContextCount.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageReferenceCount.java b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageReferenceCount.java index 93d9aed32..c877a2123 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageReferenceCount.java +++ b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageReferenceCount.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8HeapSpaceStatistics.java b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8HeapSpaceStatistics.java index 87c66d925..7609bf878 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8HeapSpaceStatistics.java +++ b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8HeapSpaceStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.caoccao.javet.enums.V8AllocationSpace; import com.caoccao.javet.interop.V8Runtime; import com.caoccao.javet.interop.monitoring.V8HeapSpaceStatistics; +import com.caoccao.javet.utils.StringUtils; import java.util.ArrayList; import java.util.List; @@ -69,12 +70,12 @@ public V8RuntimeObserverAverageV8HeapSpaceStatistics(V8AllocationSpace v8Allocat public V8HeapSpaceStatistics getResult() { long physicalSpaceSize = 0; long spaceAvailableSize = 0; - String spaceName = ""; + String spaceName = StringUtils.EMPTY; long spaceSize = 0; long spaceUsedSize = 0; if (!v8HeapSpaceStatisticsList.isEmpty()) { for (V8HeapSpaceStatistics v8HeapSpaceStatistics : v8HeapSpaceStatisticsList) { - if (spaceName.length() == 0) { + if (spaceName.isEmpty()) { spaceName = v8HeapSpaceStatistics.getSpaceName(); } physicalSpaceSize += v8HeapSpaceStatistics.getPhysicalSpaceSize(); diff --git a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8HeapStatistics.java b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8HeapStatistics.java index 71f4b738c..c1248e3da 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8HeapStatistics.java +++ b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8HeapStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8ModuleCount.java b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8ModuleCount.java index 53c51b523..ad35e82d1 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8ModuleCount.java +++ b/src/main/java/com/caoccao/javet/interop/engine/observers/V8RuntimeObserverAverageV8ModuleCount.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/observers/package-info.java b/src/main/java/com/caoccao/javet/interop/engine/observers/package-info.java index 07e54d314..15fcd506e 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/observers/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/engine/observers/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/engine/package-info.java b/src/main/java/com/caoccao/javet/interop/engine/package-info.java index 7005d97b8..161cb5863 100644 --- a/src/main/java/com/caoccao/javet/interop/engine/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/engine/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/executors/BaseV8Executor.java b/src/main/java/com/caoccao/javet/interop/executors/BaseV8Executor.java index cb98f395a..76d959e64 100644 --- a/src/main/java/com/caoccao/javet/interop/executors/BaseV8Executor.java +++ b/src/main/java/com/caoccao/javet/interop/executors/BaseV8Executor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/executors/IV8Executor.java b/src/main/java/com/caoccao/javet/interop/executors/IV8Executor.java index 921bdfeb4..3bad1b70f 100644 --- a/src/main/java/com/caoccao/javet/interop/executors/IV8Executor.java +++ b/src/main/java/com/caoccao/javet/interop/executors/IV8Executor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/executors/V8FileExecutor.java b/src/main/java/com/caoccao/javet/interop/executors/V8FileExecutor.java index 7e2a5841d..38b814496 100644 --- a/src/main/java/com/caoccao/javet/interop/executors/V8FileExecutor.java +++ b/src/main/java/com/caoccao/javet/interop/executors/V8FileExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/executors/V8PathExecutor.java b/src/main/java/com/caoccao/javet/interop/executors/V8PathExecutor.java index 0bf4fb035..f19ea7164 100644 --- a/src/main/java/com/caoccao/javet/interop/executors/V8PathExecutor.java +++ b/src/main/java/com/caoccao/javet/interop/executors/V8PathExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/executors/V8StringExecutor.java b/src/main/java/com/caoccao/javet/interop/executors/V8StringExecutor.java index fd397996e..c687f0cca 100644 --- a/src/main/java/com/caoccao/javet/interop/executors/V8StringExecutor.java +++ b/src/main/java/com/caoccao/javet/interop/executors/V8StringExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/executors/package-info.java b/src/main/java/com/caoccao/javet/interop/executors/package-info.java index fef6df62b..fe59ac8e9 100644 --- a/src/main/java/com/caoccao/javet/interop/executors/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/executors/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/loader/IJavetLibLoadingListener.java b/src/main/java/com/caoccao/javet/interop/loader/IJavetLibLoadingListener.java index ad30ff58a..6bfd870b6 100644 --- a/src/main/java/com/caoccao/javet/interop/loader/IJavetLibLoadingListener.java +++ b/src/main/java/com/caoccao/javet/interop/loader/IJavetLibLoadingListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoader.java b/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoader.java index d2baf5607..1e7dc72a1 100644 --- a/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoader.java +++ b/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import com.caoccao.javet.interfaces.IJavetLogger; import com.caoccao.javet.utils.JavetDefaultLogger; import com.caoccao.javet.utils.JavetOSUtils; -import com.caoccao.javet.utils.JavetStringUtils; import com.caoccao.javet.utils.SimpleMap; +import com.caoccao.javet.utils.StringUtils; import java.io.File; import java.io.FileOutputStream; @@ -48,7 +48,7 @@ public final class JavetLibLoader { * * @since 0.8.0 */ - public static final String LIB_VERSION = "3.0.2"; + public static final String LIB_VERSION = "3.0.3"; private static final String ANDROID_ABI_ARM = "armeabi-v7a"; private static final String ANDROID_ABI_ARM64 = "arm64-v8a"; private static final String ANDROID_ABI_X86 = "x86"; @@ -295,7 +295,7 @@ private String getOSName() { public String getResourceFileName() throws JavetException { String resourceFileName = MessageFormat.format(RESOURCE_NAME_FORMAT, JavetOSUtils.IS_ANDROID - ? JavetStringUtils.join("/", LIB_FILE_NAME_PREFIX, getAndroidABI(), getLibFileName()) + ? StringUtils.join("/", LIB_FILE_NAME_PREFIX, getAndroidABI(), getLibFileName()) : getLibFileName()); if (JavetLibLoader.class.getResource(resourceFileName) == null) { throw new JavetException( diff --git a/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoadingListener.java b/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoadingListener.java index e741f49bb..79ea8c883 100644 --- a/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoadingListener.java +++ b/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoadingListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/loader/package-info.java b/src/main/java/com/caoccao/javet/interop/loader/package-info.java index b72cc6d77..d92deb58e 100644 --- a/src/main/java/com/caoccao/javet/interop/loader/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/loader/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/monitoring/V8HeapSpaceStatistics.java b/src/main/java/com/caoccao/javet/interop/monitoring/V8HeapSpaceStatistics.java index e1556fbdf..f22181bbd 100644 --- a/src/main/java/com/caoccao/javet/interop/monitoring/V8HeapSpaceStatistics.java +++ b/src/main/java/com/caoccao/javet/interop/monitoring/V8HeapSpaceStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/monitoring/V8HeapStatistics.java b/src/main/java/com/caoccao/javet/interop/monitoring/V8HeapStatistics.java index e31aca029..3fb0465a2 100644 --- a/src/main/java/com/caoccao/javet/interop/monitoring/V8HeapStatistics.java +++ b/src/main/java/com/caoccao/javet/interop/monitoring/V8HeapStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/monitoring/V8SharedMemoryStatistics.java b/src/main/java/com/caoccao/javet/interop/monitoring/V8SharedMemoryStatistics.java index 4af441248..1c09592cd 100644 --- a/src/main/java/com/caoccao/javet/interop/monitoring/V8SharedMemoryStatistics.java +++ b/src/main/java/com/caoccao/javet/interop/monitoring/V8SharedMemoryStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/monitoring/package-info.java b/src/main/java/com/caoccao/javet/interop/monitoring/package-info.java index 086ba4439..1ee33ab19 100644 --- a/src/main/java/com/caoccao/javet/interop/monitoring/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/monitoring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/options/NodeRuntimeOptions.java b/src/main/java/com/caoccao/javet/interop/options/NodeRuntimeOptions.java index e720544d4..001a6953a 100644 --- a/src/main/java/com/caoccao/javet/interop/options/NodeRuntimeOptions.java +++ b/src/main/java/com/caoccao/javet/interop/options/NodeRuntimeOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/options/RuntimeOptions.java b/src/main/java/com/caoccao/javet/interop/options/RuntimeOptions.java index 30d0cd9fc..81c53a8c4 100644 --- a/src/main/java/com/caoccao/javet/interop/options/RuntimeOptions.java +++ b/src/main/java/com/caoccao/javet/interop/options/RuntimeOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package com.caoccao.javet.interop.options; -import com.caoccao.javet.interop.proxy.IJavetReflectionObjectFactory; +import com.caoccao.javet.utils.ArrayUtils; /** * The type Runtime options. @@ -26,11 +26,18 @@ */ public abstract class RuntimeOptions> { /** - * The reflection object factory. + * The Snapshot enabled flag indicates whether the snapshot feature is enabled or not. + * It is disabled by default. * - * @since 2.0.1 + * @since 3.0.3 */ - protected IJavetReflectionObjectFactory reflectionObjectFactory; + protected boolean createSnapshotEnabled; + /** + * The Snapshot blob. + * + * @since 3.0.3 + */ + protected byte[] snapshotBlob; /** * Instantiates a new Runtime options. @@ -38,28 +45,51 @@ public abstract class RuntimeOptions> { * @since 1.0.0 */ public RuntimeOptions() { - reflectionObjectFactory = null; + createSnapshotEnabled = false; + snapshotBlob = null; + } + + /** + * Get snapshot blob in byte array. + * + * @return the byte array + * @since 3.0.3 + */ + public byte[] getSnapshotBlob() { + return snapshotBlob; } /** - * Gets reflection object factory. + * Is create snapshot enabled. * - * @return the reflection object factory - * @since 2.0.1 + * @return true : enabled, false : disabled + * @since 3.0.3 */ - public IJavetReflectionObjectFactory getReflectionObjectFactory() { - return reflectionObjectFactory; + public boolean isCreateSnapshotEnabled() { + return createSnapshotEnabled; + } + + /** + * Sets create snapshot enabled. + * + * @param createSnapshotEnabled the create snapshot enabled + * @return the self + * @since 3.0.3 + */ + public RuntimeOptions setCreateSnapshotEnabled(boolean createSnapshotEnabled) { + this.createSnapshotEnabled = createSnapshotEnabled; + return this; } /** - * Sets reflection object factory. + * Sets snapshot blob. * - * @param reflectionObjectFactory the reflection object factory + * @param snapshotBlob the snapshot blob * @return the self - * @since 2.0.1 + * @since 3.0.3 */ - public RuntimeOptions setReflectionObjectFactory(IJavetReflectionObjectFactory reflectionObjectFactory) { - this.reflectionObjectFactory = reflectionObjectFactory; + public RuntimeOptions setSnapshotBlob(byte[] snapshotBlob) { + this.snapshotBlob = ArrayUtils.isEmpty(snapshotBlob) ? null : snapshotBlob; return this; } } diff --git a/src/main/java/com/caoccao/javet/interop/options/V8Flags.java b/src/main/java/com/caoccao/javet/interop/options/V8Flags.java index 3cf401124..33659c171 100644 --- a/src/main/java/com/caoccao/javet/interop/options/V8Flags.java +++ b/src/main/java/com/caoccao/javet/interop/options/V8Flags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package com.caoccao.javet.interop.options; -import com.caoccao.javet.utils.JavetStringUtils; +import com.caoccao.javet.utils.StringUtils; import java.text.MessageFormat; import java.util.ArrayList; @@ -391,9 +391,9 @@ public String toString() { tokens.add(FLAG_TRACK_RETAINING_PATH); } Collections.sort(tokens, String::compareTo); - if (customFlags != null && customFlags.length() > 0) { + if (StringUtils.isNotEmpty(customFlags)) { tokens.add(customFlags); } - return JavetStringUtils.join(SPACE, tokens); + return StringUtils.join(SPACE, tokens); } } diff --git a/src/main/java/com/caoccao/javet/interop/options/V8RuntimeOptions.java b/src/main/java/com/caoccao/javet/interop/options/V8RuntimeOptions.java index 59eafdeb2..e4b390519 100644 --- a/src/main/java/com/caoccao/javet/interop/options/V8RuntimeOptions.java +++ b/src/main/java/com/caoccao/javet/interop/options/V8RuntimeOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package com.caoccao.javet.interop.options; +import com.caoccao.javet.utils.StringUtils; + /** * The type V8 runtime options. * @@ -34,12 +36,7 @@ public final class V8RuntimeOptions extends RuntimeOptions { * @since 1.1.7 */ public static final V8Flags V8_FLAGS = new V8Flags(); - /** - * The Global name. - * - * @since 1.0.0 - */ - protected String globalName; + private String globalName; /** * Instantiates a new V8 runtime options. @@ -69,7 +66,7 @@ public String getGlobalName() { * @since 1.0.0 */ public V8RuntimeOptions setGlobalName(String globalName) { - this.globalName = globalName == null || globalName.length() == 0 ? null : globalName; + this.globalName = StringUtils.isEmpty(globalName) ? null : globalName; return this; } } diff --git a/src/main/java/com/caoccao/javet/interop/options/package-info.java b/src/main/java/com/caoccao/javet/interop/options/package-info.java index 6d42cc506..0c3ff0f0b 100644 --- a/src/main/java/com/caoccao/javet/interop/options/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/options/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/package-info.java b/src/main/java/com/caoccao/javet/interop/package-info.java index e4bd745f0..da46ce602 100644 --- a/src/main/java/com/caoccao/javet/interop/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetDirectProxyHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetDirectProxyHandler.java index f8d32b56b..5459b6e66 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetDirectProxyHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetDirectProxyHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetProxyHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetProxyHandler.java index b23214945..6fac1fbbe 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetProxyHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetProxyHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetProxySymbolConverter.java b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetProxySymbolConverter.java index 1644b1634..90ed927f0 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetProxySymbolConverter.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetProxySymbolConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,12 +79,10 @@ public BaseJavetProxySymbolConverter(V8Runtime v8Runtime, T targetObject) { @CheckReturnValue @Override public V8ValueFunction getV8ValueFunction() throws JavetException { - JavetCallbackContext javetCallbackContext = new JavetCallbackContext( - METHOD_NAME_TO_V8_VALUE, - this, - JavetCallbackType.DirectCallNoThisAndResult, - (IJavetDirectCallable.NoThisAndResult) this::toV8Value); - return v8Runtime.createV8ValueFunction(javetCallbackContext); + return v8Runtime.createV8ValueFunction( + new JavetCallbackContext( + METHOD_NAME_TO_V8_VALUE, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) this::toV8Value)); } /** diff --git a/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetReflectionProxyHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetReflectionProxyHandler.java index dc84597e4..2ca513b18 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetReflectionProxyHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetReflectionProxyHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -150,7 +150,7 @@ protected void addMethod(Method method, int startIndex, Map if (method.isAnnotationPresent(V8Function.class)) { String methodName = method.getName(); String aliasMethodName = method.getAnnotation(V8Function.class).name(); - if (aliasMethodName.length() > 0) { + if (!aliasMethodName.isEmpty()) { methodName = aliasMethodName; } List methods = map.computeIfAbsent(methodName, k -> new ArrayList<>()); @@ -291,7 +291,7 @@ protected V8Value getFromMethod(V8Value target, V8Value property) throws JavetEx if (methods != null && !methods.isEmpty()) { JavetReflectionProxyInterceptor reflectionProxyInterceptor = new JavetReflectionProxyInterceptor( reflectionObjectFactory, targetObject, propertyName, methods); - return v8Runtime.toV8Value(reflectionProxyInterceptor.invoke((V8ValueObject) target)); + return reflectionProxyInterceptor.invokeV8Value(target); } if (FUNCTION_NAME_TO_V8_VALUE.equals(propertyName)) { return new JavetProxySymbolToPrimitiveConverter<>(v8Runtime, targetObject).getV8ValueFunction(); @@ -447,7 +447,7 @@ protected void initializePublicFields( String fieldName = field.getName(); if (field.isAnnotationPresent(V8Property.class)) { String aliasFieldName = field.getAnnotation(V8Property.class).name(); - if (aliasFieldName.length() > 0) { + if (!aliasFieldName.isEmpty()) { fieldName = aliasFieldName; } } @@ -696,7 +696,7 @@ protected boolean setToSetter(V8Value target, V8Value propertyKey, V8Value prope if (methods != null) { JavetReflectionProxyInterceptor reflectionProxyInterceptor = new JavetReflectionProxyInterceptor( reflectionObjectFactory, targetObject, propertyName, methods); - reflectionProxyInterceptor.invoke((V8ValueObject) target, propertyValue); + reflectionProxyInterceptor.invokeObject((V8ValueObject) target, propertyValue); return true; } } diff --git a/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetReflectionProxyInvocationHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetReflectionProxyInvocationHandler.java new file mode 100644 index 000000000..88195fb3a --- /dev/null +++ b/src/main/java/com/caoccao/javet/interop/proxy/BaseJavetReflectionProxyInvocationHandler.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021-2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.interop.proxy; + +import com.caoccao.javet.exceptions.JavetException; +import com.caoccao.javet.interfaces.IJavetClosable; +import com.caoccao.javet.utils.JavetResourceUtils; +import com.caoccao.javet.values.reference.V8ValueReference; + +import java.lang.reflect.InvocationHandler; + +/** + * The type Base javet reflection proxy invocation handler. + * + * @param the type parameter + * @since 3.0.3 + */ +public abstract class BaseJavetReflectionProxyInvocationHandler + implements InvocationHandler, IJavetClosable { + /** + * The constant METHOD_NAME_CLOSE. + * + * @since 3.0.3 + */ + protected static final String METHOD_NAME_CLOSE = "close"; + /** + * The V8 value reference. + * + * @since 3.0.3 + */ + protected Reference v8ValueReference; + + /** + * Instantiates a new Base javet reflection proxy invocation handler. + * + * @param v8ValueReference the V8 value object + * @since 3.0.3 + */ + public BaseJavetReflectionProxyInvocationHandler(Reference v8ValueReference) { + this.v8ValueReference = v8ValueReference; + } + + @Override + public void close() throws JavetException { + JavetResourceUtils.safeClose(v8ValueReference); + v8ValueReference = null; + } + + @Override + protected void finalize() throws Throwable { + close(); + } + + @Override + public boolean isClosed() { + return v8ValueReference == null || v8ValueReference.isClosed(); + } +} diff --git a/src/main/java/com/caoccao/javet/interop/proxy/IJavetDirectProxyHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/IJavetDirectProxyHandler.java index 16c8b2815..6d8ddd924 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/IJavetDirectProxyHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/IJavetDirectProxyHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxyHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxyHandler.java index 1abaa613b..162a0fb9e 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxyHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxyHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,12 @@ public interface IJavetProxyHandler { * @since 2.2.0 */ String PROXY_FUNCTION_NAME_CONSTRUCT = "construct"; + /** + * The constant PROXY_FUNCTION_NAME_DELETE_PROPERTY. + * + * @since 3.0.3 + */ + String PROXY_FUNCTION_NAME_DELETE_PROPERTY = "deleteProperty"; /** * The constant PROXY_FUNCTION_NAME_GET. * @@ -127,18 +133,16 @@ default V8ValueBoolean defineProperty( /** * Delete property. * - * @param target the target - * @param property the property - * @param descriptor the descriptor + * @param target the target + * @param property the property * @return the V8 value boolean * @throws JavetException the javet exception * @throws E the custom exception * @since 2.2.0 */ - default V8ValueBoolean deleteProperty( - V8Value target, V8Value property, V8ValueObject descriptor) + default V8ValueBoolean deleteProperty(V8Value target, V8Value property) throws JavetException, E { - return getV8Runtime().createV8ValueBoolean(false); + return getV8Runtime().createV8ValueBoolean(true); } /** diff --git a/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxyPolyfillFunction.java b/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxyPolyfillFunction.java new file mode 100644 index 000000000..cb38cb65d --- /dev/null +++ b/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxyPolyfillFunction.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.interop.proxy; + +import com.caoccao.javet.exceptions.JavetException; +import com.caoccao.javet.values.V8Value; + +/** + * The interface Javet proxy polyfill function. + * + * @param the type parameter + * @param the type parameter + * @since 3.0.3 + */ +public interface IJavetProxyPolyfillFunction { + /** + * Apply to the handle and return a V8 value. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + * @throws E the custom exception + * @since 3.0.3 + */ + V8Value apply(IJavetProxyHandler handler) throws JavetException, E; +} diff --git a/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxySymbolConverter.java b/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxySymbolConverter.java index d2882f72b..c33381b2e 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxySymbolConverter.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/IJavetProxySymbolConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/JavetDirectProxyFunctionHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/JavetDirectProxyFunctionHandler.java index 723c7f2e2..2420b5f84 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/JavetDirectProxyFunctionHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/JavetDirectProxyFunctionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/JavetDirectProxyObjectHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/JavetDirectProxyObjectHandler.java index cf5da16c1..72df5437c 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/JavetDirectProxyObjectHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/JavetDirectProxyObjectHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/JavetProxySymbolIterableConverter.java b/src/main/java/com/caoccao/javet/interop/proxy/JavetProxySymbolIterableConverter.java index 0334717f6..1c79cdab6 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/JavetProxySymbolIterableConverter.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/JavetProxySymbolIterableConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/JavetProxySymbolToPrimitiveConverter.java b/src/main/java/com/caoccao/javet/interop/proxy/JavetProxySymbolToPrimitiveConverter.java index bb19cc4cb..e404bdc71 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/JavetProxySymbolToPrimitiveConverter.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/JavetProxySymbolToPrimitiveConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyFunctionHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyFunctionHandler.java index ce74f4743..7ad848c94 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyFunctionHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyFunctionHandler.java @@ -94,6 +94,9 @@ public JavetCallbackContext[] getCallbackContexts() { new JavetCallbackContext( PROXY_FUNCTION_NAME_APPLY, this, JavetCallbackType.DirectCallNoThisAndResult, (NoThisAndResult) (v8Values) -> apply(v8Values[0], v8Values[1], (V8ValueArray) v8Values[2])), + new JavetCallbackContext( + PROXY_FUNCTION_NAME_DELETE_PROPERTY, this, JavetCallbackType.DirectCallNoThisAndResult, + (NoThisAndResult) (v8Values) -> deleteProperty(v8Values[0], v8Values[1])), new JavetCallbackContext( PROXY_FUNCTION_NAME_GET, this, JavetCallbackType.DirectCallNoThisAndResult, (NoThisAndResult) (v8Values) -> get(v8Values[0], v8Values[1], v8Values[2])), diff --git a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyInterceptor.java b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyInterceptor.java index 00c515b06..520a55fb5 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyInterceptor.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyInterceptor.java @@ -18,7 +18,9 @@ import com.caoccao.javet.exceptions.JavetError; import com.caoccao.javet.exceptions.JavetException; +import com.caoccao.javet.interop.callback.IJavetDirectCallable; import com.caoccao.javet.interop.callback.JavetCallbackContext; +import com.caoccao.javet.interop.callback.JavetCallbackType; import com.caoccao.javet.utils.SimpleMap; import com.caoccao.javet.utils.V8ValueUtils; import com.caoccao.javet.values.V8Value; @@ -68,15 +70,9 @@ public JavetReflectionProxyInterceptor( * @since 0.9.6 */ public JavetCallbackContext getCallbackContext() { - try { - return new JavetCallbackContext( - METHOD_NAME_INVOKE, - this, - getClass().getMethod(METHOD_NAME_INVOKE, V8ValueObject.class, V8Value[].class), - true); - } catch (NoSuchMethodException ignored) { - } - return null; + return new JavetCallbackContext( + METHOD_NAME_INVOKE, JavetCallbackType.DirectCallThisAndResult, + (IJavetDirectCallable.ThisAndResult) this::invokeV8Value); } /** @@ -110,7 +106,7 @@ public Object getTargetObject() { } /** - * Invoke. + * Invoke and return object. * * @param thisObject this object * @param v8Values the V8 values @@ -118,7 +114,7 @@ public Object getTargetObject() { * @throws JavetException the javet exception * @since 0.9.6 */ - public Object invoke(V8ValueObject thisObject, V8Value... v8Values) throws JavetException { + public Object invokeObject(V8ValueObject thisObject, V8Value... v8Values) throws JavetException { try { return BaseJavetReflectionProxyHandler.execute( reflectionObjectFactory, @@ -142,4 +138,16 @@ public Object invoke(V8ValueObject thisObject, V8Value... v8Values) throws Javet t); } } + + /** + * Invoke and return V8 value. + * + * @param thisObject this object + * @param v8Values the V8 values + * @return the V8 value + * @throws JavetException the javet exception + */ + public V8Value invokeV8Value(V8Value thisObject, V8Value... v8Values) throws JavetException { + return thisObject.getV8Runtime().toV8Value(invokeObject((V8ValueObject) thisObject, v8Values)); + } } diff --git a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyObjectHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyObjectHandler.java index 5039d73e5..817bcbdd0 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyObjectHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyObjectHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,15 +22,15 @@ import com.caoccao.javet.interop.V8Runtime; import com.caoccao.javet.interop.V8Scope; import com.caoccao.javet.interop.binding.ClassDescriptor; +import com.caoccao.javet.interop.callback.IJavetDirectCallable; import com.caoccao.javet.interop.callback.JavetCallbackContext; import com.caoccao.javet.interop.callback.JavetCallbackType; -import com.caoccao.javet.utils.JavetStringUtils; -import com.caoccao.javet.utils.ThreadSafeMap; +import com.caoccao.javet.utils.*; import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.primitive.V8ValueBoolean; +import com.caoccao.javet.values.primitive.V8ValueInteger; import com.caoccao.javet.values.primitive.V8ValueString; -import com.caoccao.javet.values.reference.V8ValueArray; -import com.caoccao.javet.values.reference.V8ValueSymbol; +import com.caoccao.javet.values.reference.*; import com.caoccao.javet.values.reference.builtin.V8ValueBuiltInSymbol; import java.lang.reflect.Array; @@ -46,19 +46,171 @@ @SuppressWarnings("unchecked") public class JavetReflectionProxyObjectHandler extends BaseJavetReflectionProxyHandler { - /** - * The constant FUNCTION_NAME_LENGTH. + * The constant POLYFILL_LIST_AT. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_AT = "at"; + /** + * The constant POLYFILL_LIST_EVERY. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_EVERY = "every"; + /** + * The constant POLYFILL_LIST_INCLUDES. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_INCLUDES = "includes"; + /** + * The constant POLYFILL_LIST_KEYS. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_KEYS = "keys"; + /** + * The constant POLYFILL_LIST_MAP. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_MAP = "map"; + /** + * The constant POLYFILL_LIST_POP. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_POP = "pop"; + /** + * The constant POLYFILL_LIST_PUSH. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_PUSH = "push"; + /** + * The constant POLYFILL_LIST_REVERSE. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_REVERSE = "reverse"; + /** + * The constant POLYFILL_LIST_SHIFT. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_SHIFT = "shift"; + /** + * The constant POLYFILL_LIST_SOME. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_SOME = "some"; + /** + * The constant POLYFILL_LIST_TO_REVERSED. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_TO_REVERSED = "toReversed"; + /** + * The constant POLYFILL_LIST_UNSHIFT. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_UNSHIFT = "unshift"; + /** + * The constant POLYFILL_LIST_WITH. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_LIST_WITH = "with"; + /** + * The constant POLYFILL_SET_DELETE. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_SET_DELETE = "delete"; + /** + * The constant POLYFILL_SET_HAS. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_SET_HAS = "has"; + /** + * The constant POLYFILL_SET_KEYS. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_SET_KEYS = "keys"; + /** + * The constant POLYFILL_SHARED_LENGTH. * * @since 1.0.6 */ - protected static final String FUNCTION_NAME_LENGTH = "length"; + protected static final String POLYFILL_SHARED_LENGTH = "length"; + /** + * The constant POLYFILL_SHARED_TO_JSON. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_SHARED_TO_JSON = "toJSON"; + /** + * The constant POLYFILL_SHARED_VALUES. + * + * @since 3.0.3 + */ + protected static final String POLYFILL_SHARED_VALUES = "values"; /** * The constant classDescriptorMap. * * @since 1.1.7 */ protected static final ThreadSafeMap, ClassDescriptor> classDescriptorMap = new ThreadSafeMap<>(); + /** + * The constant polyfillListFunctionMap. + * + * @since 3.0.3 + */ + protected static final Map> polyfillListFunctionMap; + /** + * The constant polyfillMapFunctionMap. + * + * @since 3.0.3 + */ + protected static final Map> polyfillMapFunctionMap; + /** + * The constant polyfillSetFunctionMap. + * + * @since 3.0.3 + */ + protected static final Map> polyfillSetFunctionMap; + + static { + polyfillListFunctionMap = new HashMap<>(); + polyfillListFunctionMap.put(POLYFILL_LIST_AT, JavetReflectionProxyObjectHandler::polyfillListAt); + polyfillListFunctionMap.put(POLYFILL_LIST_EVERY, JavetReflectionProxyObjectHandler::polyfillListEvery); + polyfillListFunctionMap.put(POLYFILL_LIST_INCLUDES, JavetReflectionProxyObjectHandler::polyfillListIncludes); + polyfillListFunctionMap.put(POLYFILL_LIST_KEYS, JavetReflectionProxyObjectHandler::polyfillListKeys); + polyfillListFunctionMap.put(POLYFILL_SHARED_LENGTH, JavetReflectionProxyObjectHandler::polyfillListLength); + polyfillListFunctionMap.put(POLYFILL_LIST_MAP, JavetReflectionProxyObjectHandler::polyfillListMap); + polyfillListFunctionMap.put(POLYFILL_LIST_POP, JavetReflectionProxyObjectHandler::polyfillListPop); + polyfillListFunctionMap.put(POLYFILL_LIST_PUSH, JavetReflectionProxyObjectHandler::polyfillListPush); + polyfillListFunctionMap.put(POLYFILL_LIST_REVERSE, JavetReflectionProxyObjectHandler::polyfillListReverse); + polyfillListFunctionMap.put(POLYFILL_LIST_SHIFT, JavetReflectionProxyObjectHandler::polyfillListShift); + polyfillListFunctionMap.put(POLYFILL_LIST_SOME, JavetReflectionProxyObjectHandler::polyfillListSome); + polyfillListFunctionMap.put(POLYFILL_SHARED_TO_JSON, JavetReflectionProxyObjectHandler::polyfillListToJSON); + polyfillListFunctionMap.put(POLYFILL_LIST_TO_REVERSED, JavetReflectionProxyObjectHandler::polyfillListToReversed); + polyfillListFunctionMap.put(POLYFILL_LIST_UNSHIFT, JavetReflectionProxyObjectHandler::polyfillListUnshift); + polyfillListFunctionMap.put(POLYFILL_SHARED_VALUES, JavetReflectionProxyObjectHandler::polyfillSharedValues); + polyfillListFunctionMap.put(POLYFILL_LIST_WITH, JavetReflectionProxyObjectHandler::polyfillListWith); + polyfillMapFunctionMap = new HashMap<>(); + polyfillMapFunctionMap.put(POLYFILL_SHARED_TO_JSON, JavetReflectionProxyObjectHandler::polyfillMapToJSON); + polyfillSetFunctionMap = new HashMap<>(); + polyfillSetFunctionMap.put(POLYFILL_SET_DELETE, JavetReflectionProxyObjectHandler::polyfillSetDelete); + polyfillSetFunctionMap.put(POLYFILL_SET_HAS, JavetReflectionProxyObjectHandler::polyfillSetHas); + polyfillSetFunctionMap.put(POLYFILL_SET_KEYS, JavetReflectionProxyObjectHandler::polyfillSharedValues); + polyfillSetFunctionMap.put(POLYFILL_SHARED_VALUES, JavetReflectionProxyObjectHandler::polyfillSharedValues); + } /** * Instantiates a new Javet reflection proxy object handler. @@ -75,13 +227,547 @@ public JavetReflectionProxyObjectHandler( super(v8Runtime, reflectionObjectFactory, Objects.requireNonNull(targetObject)); } + /** + * Polyfill Array.prototype.at(). + * The at() method of Array instances takes an integer value and returns the item at that index, + * allowing for positive and negative integers. Negative integers count back from the last item in the array. + *

    + * Parameters + * index + * Zero-based index of the array element to be returned, converted to an integer. + * Negative index counts back from the end of the array — if index < 0, index + array.length is accessed. + *

    + * Return value + * The element in the array matching the given index. + * Always returns undefined if index < -array.length or index >= array.length + * without attempting to access the corresponding property. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListAt(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_AT, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + if (ArrayUtils.isNotEmpty(v8Values) && v8Values[0] instanceof V8ValueInteger) { + final int size = list.size(); + int index = ((V8ValueInteger) v8Values[0]).getValue(); + if (index < 0) { + index += size; + } + if (index >= 0 && index < size) { + return handler.getV8Runtime().toV8Value(list.get(index)); + } + } + return handler.getV8Runtime().createV8ValueUndefined(); + })); + } + + /** + * Polyfill Array.prototype.every(). + * The every() method of Array instances tests whether all elements in the array pass the test implemented + * by the provided function. It returns a Boolean value. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListEvery(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_EVERY, handler, JavetCallbackType.DirectCallThisAndResult, + (IJavetDirectCallable.ThisAndResult) (thisObject, v8Values) -> { + boolean valid = false; + if (ArrayUtils.isNotEmpty(v8Values) && v8Values[0] instanceof V8ValueFunction) { + V8ValueFunction v8ValueFunction = (V8ValueFunction) v8Values[0]; + IV8ValueObject thisArg = v8Values.length > 1 && v8Values[1] instanceof IV8ValueObject + ? (IV8ValueObject) v8Values[1] : null; + int index = 0; + valid = true; + for (Object object : list) { + try (V8Value result = v8ValueFunction.call(thisArg, object, index, thisObject)) { + if (!(result instanceof V8ValueBoolean) || !((V8ValueBoolean) result).getValue()) { + valid = false; + break; + } + } + ++index; + } + } + return handler.getV8Runtime().createV8ValueBoolean(valid); + })); + } + + /** + * Polyfill Array.prototype.includes(). + * The includes() method of Array instances determines whether an array includes a certain value among its entries, + * returning true or false as appropriate. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListIncludes(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_INCLUDES, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + boolean included = false; + if (ArrayUtils.isNotEmpty(v8Values)) { + Object object = handler.getV8Runtime().toObject(v8Values[0]); + int fromIndex = 0; + if (v8Values.length > 1 && v8Values[1] instanceof V8ValueInteger) { + fromIndex = ((V8ValueInteger) v8Values[1]).getValue(); + } + included = ListUtils.includes(list, object, fromIndex); + } + return handler.getV8Runtime().createV8ValueBoolean(included); + })); + } + + /** + * Polyfill Array.prototype.keys() + * The keys() method of Array instances returns a new array iterator object + * that contains the keys for each index in the array. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListKeys(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_KEYS, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + final int size = list.size(); + Object[] indexes = new Object[size]; + for (int i = 0; i < size; ++i) { + indexes[i] = handler.getV8Runtime().createV8ValueInteger(i); + } + try (V8Scope v8Scope = handler.getV8Runtime().getV8Scope()) { + V8ValueArray v8ValueArray = v8Scope.createV8ValueArray(); + if (size > 0) { + v8ValueArray.push(indexes); + } + v8Scope.setEscapable(); + return v8ValueArray; + } + })); + } + + /** + * Polyfill Array: length. + * The length data property of an Array instance represents the number of elements in that array. + * The value is an unsigned, 32-bit integer that is always numerically greater than the highest index in the array. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListLength(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueInteger(list.size()); + } + + /** + * Polyfill Array.prototype.map(). + * The map() method of Array instances creates a new array populated with the results of + * calling a provided function on every element in the calling array. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListMap(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_MAP, handler, JavetCallbackType.DirectCallThisAndResult, + (IJavetDirectCallable.ThisAndResult) (thisObject, v8Values) -> { + try (V8Scope v8Scope = handler.getV8Runtime().getV8Scope()) { + V8ValueArray v8ValueArray = v8Scope.createV8ValueArray(); + if (ArrayUtils.isNotEmpty(v8Values) && v8Values[0] instanceof V8ValueFunction) { + V8ValueFunction v8ValueFunction = (V8ValueFunction) v8Values[0]; + IV8ValueObject thisArg = v8Values.length > 1 && v8Values[1] instanceof IV8ValueObject + ? (IV8ValueObject) v8Values[1] : null; + List results = new ArrayList<>(list.size()); + try { + int index = 0; + for (Object object : list) { + results.add(v8ValueFunction.call(thisArg, object, index, thisObject)); + ++index; + } + v8ValueArray.push(results.toArray()); + } finally { + JavetResourceUtils.safeClose(results); + } + } + v8Scope.setEscapable(); + return v8ValueArray; + } + })); + } + + /** + * Polyfill Array.prototype.pop(). + * The pop() method of Array instances removes the last element from an array and returns that element. + * This method changes the length of the array. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListPop(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_POP, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + if (list.isEmpty()) { + return handler.getV8Runtime().createV8ValueUndefined(); + } + return handler.getV8Runtime().toV8Value(ListUtils.pop(list)); + })); + } + + /** + * Polyfill Array.prototype.push(). + * The push() method of Array instances adds the specified elements to the end of an array + * and returns the new length of the array. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListPush(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_PUSH, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> + handler.getV8Runtime().createV8ValueInteger( + ListUtils.push(list, V8ValueUtils.toArray(handler.getV8Runtime(), v8Values))))); + } + + /** + * Polyfill Array.prototype.reverse(). + * The reverse() method of Array instances reverses an array in place and returns the reference to the same array, + * the first array element now becoming the last, and the last array element becoming the first. In other words, + * elements order in the array will be turned towards the direction opposite to that previously stated. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListReverse(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_REVERSE, handler, JavetCallbackType.DirectCallThisAndResult, + (IJavetDirectCallable.ThisAndResult) (thisObject, v8Values) -> { + if (!list.isEmpty()) { + Collections.reverse(list); + } + return thisObject; + })); + } + + /** + * Polyfill Array.prototype.shift(). + * The shift() method of Array instances removes the first element from an array and returns that removed element. + * This method changes the length of the array. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListShift(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_SHIFT, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + if (list.isEmpty()) { + return handler.getV8Runtime().createV8ValueUndefined(); + } + return handler.getV8Runtime().toV8Value(ListUtils.shift(list)); + })); + } + + /** + * Polyfill Array.prototype.some(). + * The some() method of Array instances tests whether at least one element in the array passes + * the test implemented by the provided function. It returns true if, in the array, + * it finds an element for which the provided function returns true; otherwise it returns false. + * It doesn't modify the array. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListSome(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_SOME, handler, JavetCallbackType.DirectCallThisAndResult, + (IJavetDirectCallable.ThisAndResult) (thisObject, v8Values) -> { + boolean valid = false; + if (ArrayUtils.isNotEmpty(v8Values) && v8Values[0] instanceof V8ValueFunction) { + V8ValueFunction v8ValueFunction = (V8ValueFunction) v8Values[0]; + IV8ValueObject thisArg = v8Values.length > 1 && v8Values[1] instanceof IV8ValueObject + ? (IV8ValueObject) v8Values[1] : null; + int index = 0; + for (Object object : list) { + try (V8Value result = v8ValueFunction.call(thisArg, object, index, thisObject)) { + if (result instanceof V8ValueBoolean && ((V8ValueBoolean) result).getValue()) { + valid = true; + break; + } + } + ++index; + } + } + return handler.getV8Runtime().createV8ValueBoolean(valid); + })); + } + + /** + * Polyfill Array.toJSON(). + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListToJSON(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_SHARED_TO_JSON, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + Object[] objects = list.toArray(); + try (V8Scope v8Scope = handler.getV8Runtime().getV8Scope()) { + V8ValueArray v8ValueArray = v8Scope.createV8ValueArray(); + v8ValueArray.push(objects); + v8Scope.setEscapable(); + return v8ValueArray; + } + })); + } + + /** + * Polyfill Array.prototype.toReversed(). + * The toReversed() method of Array instances is the copying counterpart of the reverse() method. + * It returns a new array with the elements in reversed order. + * + * @param handler the handler + * @return the v 8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListToReversed(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_TO_REVERSED, handler, JavetCallbackType.DirectCallThisAndResult, + (IJavetDirectCallable.ThisAndResult) (thisObject, v8Values) -> { + try (V8Scope v8Scope = handler.getV8Runtime().getV8Scope()) { + V8ValueArray v8ValueArray = v8Scope.createV8ValueArray(); + if (!list.isEmpty()) { + List reversedList = new ArrayList<>(list); + Collections.reverse(reversedList); + v8ValueArray.push(reversedList.toArray()); + } + v8Scope.setEscapable(); + return v8ValueArray; + } + })); + } + + /** + * Polyfill Array.prototype.unshift() + * The unshift() method of Array instances adds the specified elements to the beginning of an array + * and returns the new length of the array. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListUnshift(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_UNSHIFT, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> + handler.getV8Runtime().createV8ValueInteger( + ListUtils.unshift(list, V8ValueUtils.toArray(handler.getV8Runtime(), v8Values))))); + } + + /** + * Polyfill Array.prototype.with(). + * The with() method of Array instances is the copying version of using the bracket notation to change the value + * of a given index. It returns a new array with the element at the given index replaced with the given value. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillListWith(IJavetProxyHandler handler) throws JavetException { + List list = (List) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_LIST_WITH, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + try (V8Scope v8Scope = handler.getV8Runtime().getV8Scope()) { + Object[] objects = list.toArray(); + V8ValueArray v8ValueArray = v8Scope.createV8ValueArray(); + if (v8Values != null && v8Values.length > 1 && v8Values[0] instanceof V8ValueInteger) { + int toBeReplacedIndex = ((V8ValueInteger) v8Values[0]).getValue(); + if (toBeReplacedIndex >= 0 && toBeReplacedIndex < objects.length) { + objects[toBeReplacedIndex] = handler.getV8Runtime().toObject(v8Values[1]); + } + } + v8ValueArray.push(objects); + v8Scope.setEscapable(); + return v8ValueArray; + } + })); + } + + /** + * Polyfill Map.toJSON(). + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillMapToJSON(IJavetProxyHandler handler) throws JavetException { + Map map = (Map) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_SHARED_TO_JSON, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + Object[] objects = new Object[map.size() << 1]; + int index = 0; + for (Map.Entry entry : map.entrySet()) { + objects[index] = entry.getKey(); + objects[index + 1] = entry.getKey(); + index += 2; + } + try (V8Scope v8Scope = handler.getV8Runtime().getV8Scope()) { + V8ValueObject v8ValueObject = v8Scope.createV8ValueObject(); + v8ValueObject.set(objects); + v8Scope.setEscapable(); + return v8ValueObject; + } + })); + } + + /** + * Polyfill Set.prototype.delete(). + * The delete() method of Set instances removes a specified value from this set, if it is in the set. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillSetDelete(IJavetProxyHandler handler) throws JavetException { + Set set = (Set) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_SET_DELETE, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + boolean result = false; + if (v8Values != null && v8Values.length > 0) { + result = set.remove(handler.getV8Runtime().toObject(v8Values[0])); + } + return handler.getV8Runtime().createV8ValueBoolean(result); + })); + } + + /** + * Polyfill Set.prototype.has(). + * The has() method of Set instances returns a boolean indicating whether an element + * with the specified value exists in this set or not. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillSetHas(IJavetProxyHandler handler) throws JavetException { + Set set = (Set) handler.getTargetObject(); + return handler.getV8Runtime().createV8ValueFunction(new JavetCallbackContext( + POLYFILL_SET_HAS, handler, JavetCallbackType.DirectCallNoThisAndResult, + (IJavetDirectCallable.NoThisAndResult) (v8Values) -> { + boolean result = false; + if (v8Values != null && v8Values.length > 0) { + result = set.contains(handler.getV8Runtime().toObject(v8Values[0])); + } + return handler.getV8Runtime().createV8ValueBoolean(result); + })); + } + + /** + * Polyfill Array.prototype.values(). + * The values() method of Array instances returns a new array iterator object that iterates the value + * of each item in the array. + *

    + * Polyfill Set.prototype.values(). + * The values() method of Set instances returns a new set iterator object that contains the values + * for each element in this set in insertion order. + * + * @param handler the handler + * @return the V8 value + * @throws JavetException the javet exception + */ + protected static V8Value polyfillSharedValues(IJavetProxyHandler handler) throws JavetException { + return new JavetProxySymbolIterableConverter<>( + handler.getV8Runtime(), handler.getTargetObject()).getV8ValueFunction(); + } + + /** + * Delete from collection. + * + * @param property the property + * @return true : deleted, false : not deleted + * @throws JavetException the javet exception + */ + protected boolean deleteFromCollection(V8Value property) throws JavetException { + if (property instanceof V8ValueString) { + try { + String propertyString = ((V8ValueString) property).getValue(); + if (StringUtils.isDigital(propertyString)) { + final int index = Integer.parseInt(propertyString); + if (index >= 0) { + if (classDescriptor.getTargetClass().isArray()) { + if (index < Array.getLength(targetObject)) { + // Only non-primitive array supports delete. + if (!classDescriptor.getTargetClass().getComponentType().isPrimitive()) { + Array.set(targetObject, index, null); + return true; + } + } + } else if (classDescriptor.isTargetTypeList()) { + List list = (List) targetObject; + if (index < list.size()) { + list.remove(index); + return true; + } + } + } + } + if (classDescriptor.isTargetTypeMap()) { + Map map = (Map) targetObject; + return map.remove(propertyString) != null; + } + } catch (Throwable ignored) { + } + } + return false; + } + + @Override + public V8ValueBoolean deleteProperty(V8Value target, V8Value property) throws JavetException, E { + boolean result = deleteFromCollection(property); + return super.deleteProperty(target, property); + } + @Override - public V8Value get(V8Value target, V8Value property, V8Value receiver) throws JavetException { + public V8Value get(V8Value target, V8Value property, V8Value receiver) throws JavetException, E { V8Value result = getFromCollection(property); result = result == null ? getFromField(property) : result; result = result == null ? getFromMethod(target, property) : result; result = result == null ? getFromSymbol(property) : result; result = result == null ? getFromGetter(property) : result; + result = result == null ? getFromPolyfill(property) : result; return result == null ? v8Runtime.createV8ValueUndefined() : result; } @@ -92,6 +778,9 @@ public JavetCallbackContext[] getCallbackContexts() { new JavetCallbackContext( PROXY_FUNCTION_NAME_GET, this, JavetCallbackType.DirectCallNoThisAndResult, (NoThisAndResult) (v8Values) -> get(v8Values[0], v8Values[1], v8Values[2])), + new JavetCallbackContext( + PROXY_FUNCTION_NAME_DELETE_PROPERTY, this, JavetCallbackType.DirectCallNoThisAndResult, + (NoThisAndResult) (v8Values) -> deleteProperty(v8Values[0], v8Values[1])), new JavetCallbackContext( PROXY_FUNCTION_NAME_HAS, this, JavetCallbackType.DirectCallNoThisAndResult, (NoThisAndResult) (v8Values) -> has(v8Values[0], v8Values[1])), @@ -121,28 +810,58 @@ public ThreadSafeMap, ClassDescriptor> getClassDescriptorCache() { */ protected V8Value getFromCollection(V8Value property) throws JavetException { if (property instanceof V8ValueString) { - String propertyString = ((V8ValueString) property).toPrimitive(); - if (JavetStringUtils.isDigital(propertyString)) { + String propertyString = ((V8ValueString) property).getValue(); + if (StringUtils.isDigital(propertyString)) { final int index = Integer.parseInt(propertyString); if (index >= 0) { if (classDescriptor.getTargetClass().isArray()) { if (index < Array.getLength(targetObject)) { return v8Runtime.toV8Value(Array.get(targetObject, index)); } - } else if (List.class.isAssignableFrom(classDescriptor.getTargetClass())) { + } else if (classDescriptor.isTargetTypeList()) { List list = (List) targetObject; if (index < list.size()) { return v8Runtime.toV8Value(list.get(index)); } } } - } else if (classDescriptor.getTargetClass().isArray() && FUNCTION_NAME_LENGTH.equals(propertyString)) { + } else if (classDescriptor.getTargetClass().isArray() && POLYFILL_SHARED_LENGTH.equals(propertyString)) { return v8Runtime.toV8Value(Array.getLength(targetObject)); } } return null; } + /** + * Gets from polyfill. + * + * @param property the property + * @return the V8 value + * @throws JavetException the javet exception + * @throws E the custom exception + * @since 3.0.3 + */ + protected V8Value getFromPolyfill(V8Value property) throws JavetException, E { + if (property instanceof V8ValueString) { + String propertyName = ((V8ValueString) property).getValue(); + IJavetProxyPolyfillFunction iJavetProxyPolyfillFunction = null; + if (classDescriptor.isTargetTypeList()) { + iJavetProxyPolyfillFunction = (IJavetProxyPolyfillFunction) + polyfillListFunctionMap.get(propertyName); + } else if (classDescriptor.isTargetTypeMap()) { + iJavetProxyPolyfillFunction = (IJavetProxyPolyfillFunction) + polyfillMapFunctionMap.get(propertyName); + } else if (classDescriptor.isTargetTypeSet()) { + iJavetProxyPolyfillFunction = (IJavetProxyPolyfillFunction) + polyfillSetFunctionMap.get(propertyName); + } + if (iJavetProxyPolyfillFunction != null) { + return iJavetProxyPolyfillFunction.apply(this); + } + } + return null; + } + /** * Gets from symbol. * @@ -181,15 +900,18 @@ public V8ValueBoolean has(V8Value target, V8Value property) throws JavetExceptio * @param property the property * @return true : has, false: not has * @throws JavetException the javet exception + * @since 1.1.7 */ protected boolean hasFromCollection(V8Value property) throws JavetException { if (classDescriptor.isTargetTypeMap()) { return ((Map) targetObject).containsKey(v8Runtime.toObject(property)); + } else if (classDescriptor.isTargetTypeList()) { + return ((List) targetObject).contains(v8Runtime.toObject(property)); } else if (classDescriptor.isTargetTypeSet()) { return ((Set) targetObject).contains(v8Runtime.toObject(property)); } else if (property instanceof V8ValueString) { - String indexString = ((V8ValueString) property).toPrimitive(); - if (JavetStringUtils.isDigital(indexString)) { + String indexString = ((V8ValueString) property).getValue(); + if (StringUtils.isDigital(indexString)) { final int index = Integer.parseInt(indexString); if (index >= 0) { if (classDescriptor.getTargetClass().isArray()) { @@ -311,19 +1033,20 @@ public V8ValueBoolean set( * @param propertyValue the property value * @return true : set, false: not set * @throws JavetException the javet exception + * @since 1.1.7 */ protected boolean setToCollection(V8Value propertyKey, V8Value propertyValue) throws JavetException { if (propertyKey instanceof V8ValueString) { - String indexString = ((V8ValueString) propertyKey).toPrimitive(); - if (JavetStringUtils.isDigital(indexString)) { - final int index = Integer.parseInt(indexString); + String propertyKeyString = ((V8ValueString) propertyKey).getValue(); + if (StringUtils.isDigital(propertyKeyString)) { + final int index = Integer.parseInt(propertyKeyString); if (index >= 0) { if (classDescriptor.getTargetClass().isArray()) { if (index < Array.getLength(targetObject)) { Array.set(targetObject, index, v8Runtime.toObject(propertyValue)); return true; } - } else if (List.class.isAssignableFrom(classDescriptor.getTargetClass())) { + } else if (classDescriptor.isTargetTypeList()) { List list = (List) targetObject; if (index < list.size()) { list.set(index, v8Runtime.toObject(propertyValue)); diff --git a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyV8ValueFunctionInvocationHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyV8ValueFunctionInvocationHandler.java index ae9332af7..309f39c78 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyV8ValueFunctionInvocationHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyV8ValueFunctionInvocationHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,8 @@ package com.caoccao.javet.interop.proxy; -import com.caoccao.javet.exceptions.JavetException; -import com.caoccao.javet.interfaces.IJavetClosable; -import com.caoccao.javet.utils.JavetResourceUtils; import com.caoccao.javet.values.reference.V8ValueFunction; -import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; /** @@ -29,10 +25,8 @@ * * @since 0.9.10 */ -public final class JavetReflectionProxyV8ValueFunctionInvocationHandler implements InvocationHandler, IJavetClosable { - private static final String METHOD_NAME_CLOSE = "close"; - private V8ValueFunction v8ValueFunction; - +public final class JavetReflectionProxyV8ValueFunctionInvocationHandler + extends BaseJavetReflectionProxyInvocationHandler { /** * Instantiates a new Javet reflection proxy V8 value function invocation handler. * @@ -40,13 +34,7 @@ public final class JavetReflectionProxyV8ValueFunctionInvocationHandler implemen * @since 0.9.10 */ public JavetReflectionProxyV8ValueFunctionInvocationHandler(V8ValueFunction v8ValueFunction) { - this.v8ValueFunction = v8ValueFunction; - } - - @Override - public void close() throws JavetException { - JavetResourceUtils.safeClose(v8ValueFunction); - v8ValueFunction = null; + super(v8ValueFunction); } @Override @@ -58,14 +46,9 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl String methodName = method.getName(); if (methodName.equals(METHOD_NAME_CLOSE) && args.length == 0) { close(); - } else if (v8ValueFunction != null && !v8ValueFunction.isClosed()) { - result = v8ValueFunction.callObject(null, args); + } else if (v8ValueReference != null && !v8ValueReference.isClosed()) { + result = v8ValueReference.callObject(null, args); } return result; } - - @Override - public boolean isClosed() { - return v8ValueFunction == null || v8ValueFunction.isClosed(); - } } diff --git a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyV8ValueObjectInvocationHandler.java b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyV8ValueObjectInvocationHandler.java index f54a79158..4d646c735 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyV8ValueObjectInvocationHandler.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/JavetReflectionProxyV8ValueObjectInvocationHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +17,9 @@ package com.caoccao.javet.interop.proxy; import com.caoccao.javet.annotations.V8Function; -import com.caoccao.javet.exceptions.JavetException; -import com.caoccao.javet.interfaces.IJavetClosable; -import com.caoccao.javet.utils.JavetResourceUtils; +import com.caoccao.javet.utils.StringUtils; import com.caoccao.javet.values.reference.V8ValueObject; -import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; /** @@ -30,10 +27,8 @@ * * @since 0.9.10 */ -public final class JavetReflectionProxyV8ValueObjectInvocationHandler implements InvocationHandler, IJavetClosable { - private static final String METHOD_NAME_CLOSE = "close"; - private V8ValueObject v8ValueObject; - +public final class JavetReflectionProxyV8ValueObjectInvocationHandler + extends BaseJavetReflectionProxyInvocationHandler { /** * Instantiates a new Javet reflection proxy V8 value object invocation handler. * @@ -41,13 +36,7 @@ public final class JavetReflectionProxyV8ValueObjectInvocationHandler implements * @since 0.9.10 */ public JavetReflectionProxyV8ValueObjectInvocationHandler(V8ValueObject v8ValueObject) { - this.v8ValueObject = v8ValueObject; - } - - @Override - public void close() throws JavetException { - JavetResourceUtils.safeClose(v8ValueObject); - v8ValueObject = null; + super(v8ValueObject); } @Override @@ -59,20 +48,15 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl String methodName = method.getName(); if (methodName.equals(METHOD_NAME_CLOSE) && args.length == 0) { close(); - } else if (v8ValueObject != null && !v8ValueObject.isClosed()) { + } else if (v8ValueReference != null && !v8ValueReference.isClosed()) { if (method.isAnnotationPresent(V8Function.class)) { String aliasMethodName = method.getAnnotation(V8Function.class).name(); - if (aliasMethodName != null && aliasMethodName.length() > 0) { + if (!StringUtils.isEmpty(aliasMethodName)) { methodName = aliasMethodName; } } - result = v8ValueObject.invokeObject(methodName, args); + result = v8ValueReference.invokeObject(methodName, args); } return result; } - - @Override - public boolean isClosed() { - return v8ValueObject == null || v8ValueObject.isClosed(); - } } diff --git a/src/main/java/com/caoccao/javet/interop/proxy/ScoredExecutable.java b/src/main/java/com/caoccao/javet/interop/proxy/ScoredExecutable.java index 70d911f6a..af8365d81 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/ScoredExecutable.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/ScoredExecutable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/interop/proxy/package-info.java b/src/main/java/com/caoccao/javet/interop/proxy/package-info.java index eda2401d0..40d7987b0 100644 --- a/src/main/java/com/caoccao/javet/interop/proxy/package-info.java +++ b/src/main/java/com/caoccao/javet/interop/proxy/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/node/modules/BaseNodeModule.java b/src/main/java/com/caoccao/javet/node/modules/BaseNodeModule.java index 39f55c2ac..2444cf7f6 100644 --- a/src/main/java/com/caoccao/javet/node/modules/BaseNodeModule.java +++ b/src/main/java/com/caoccao/javet/node/modules/BaseNodeModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/node/modules/INodeModule.java b/src/main/java/com/caoccao/javet/node/modules/INodeModule.java index 67e5b9230..f37b8dca7 100644 --- a/src/main/java/com/caoccao/javet/node/modules/INodeModule.java +++ b/src/main/java/com/caoccao/javet/node/modules/INodeModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/node/modules/NodeModuleAny.java b/src/main/java/com/caoccao/javet/node/modules/NodeModuleAny.java index 1be87e11c..1d037569d 100644 --- a/src/main/java/com/caoccao/javet/node/modules/NodeModuleAny.java +++ b/src/main/java/com/caoccao/javet/node/modules/NodeModuleAny.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/node/modules/NodeModuleModule.java b/src/main/java/com/caoccao/javet/node/modules/NodeModuleModule.java index e535c8d5c..899322990 100644 --- a/src/main/java/com/caoccao/javet/node/modules/NodeModuleModule.java +++ b/src/main/java/com/caoccao/javet/node/modules/NodeModuleModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/node/modules/NodeModuleProcess.java b/src/main/java/com/caoccao/javet/node/modules/NodeModuleProcess.java index 2313fcbcb..aa29e5d28 100644 --- a/src/main/java/com/caoccao/javet/node/modules/NodeModuleProcess.java +++ b/src/main/java/com/caoccao/javet/node/modules/NodeModuleProcess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/node/modules/package-info.java b/src/main/java/com/caoccao/javet/node/modules/package-info.java index 0178ca698..364f30370 100644 --- a/src/main/java/com/caoccao/javet/node/modules/package-info.java +++ b/src/main/java/com/caoccao/javet/node/modules/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/ArrayUtils.java b/src/main/java/com/caoccao/javet/utils/ArrayUtils.java new file mode 100644 index 000000000..94347ae91 --- /dev/null +++ b/src/main/java/com/caoccao/javet/utils/ArrayUtils.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.utils; + +/** + * The type Array utils. + * + * @since 3.0.3 + */ +public final class ArrayUtils { + /** + * Test if the input byte array is empty. + * + * @param array the array + * @return true : empty, false : not empty + * @since 3.0.3 + */ + public static boolean isEmpty(byte[] array) { + return array == null || array.length == 0; + } + + /** + * Test if the input long array is empty. + * + * @param array the array + * @return true : empty, false : not empty + * @since 3.0.3 + */ + public static boolean isEmpty(long[] array) { + return array == null || array.length == 0; + } + + /** + * Test if the input array is empty. + * + * @param the type parameter + * @param array the array + * @return true : empty, false : not empty + * @since 3.0.3 + */ + public static boolean isEmpty(T[] array) { + return array == null || array.length == 0; + } + + /** + * Test if the input byte array is not empty. + * + * @param array the array + * @return true : not empty, false : empty + * @since 3.0.3 + */ + public static boolean isNotEmpty(byte[] array) { + return array != null && array.length > 0; + } + + /** + * Test if the input long array is not empty. + * + * @param array the array + * @return true : not empty, false : empty + * @since 3.0.3 + */ + public static boolean isNotEmpty(long[] array) { + return array != null && array.length > 0; + } + + /** + * Test if the input array is not empty. + * + * @param the type parameter + * @param array the array + * @return true : not empty, false : empty + * @since 3.0.3 + */ + public static boolean isNotEmpty(T[] array) { + return array != null && array.length > 0; + } +} diff --git a/src/main/java/com/caoccao/javet/utils/JavetDateTimeUtils.java b/src/main/java/com/caoccao/javet/utils/JavetDateTimeUtils.java index 667d71e0a..a88e871bc 100644 --- a/src/main/java/com/caoccao/javet/utils/JavetDateTimeUtils.java +++ b/src/main/java/com/caoccao/javet/utils/JavetDateTimeUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/JavetDefaultLogger.java b/src/main/java/com/caoccao/javet/utils/JavetDefaultLogger.java index a1eed27e1..3ed5bc9dd 100644 --- a/src/main/java/com/caoccao/javet/utils/JavetDefaultLogger.java +++ b/src/main/java/com/caoccao/javet/utils/JavetDefaultLogger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/JavetOSUtils.java b/src/main/java/com/caoccao/javet/utils/JavetOSUtils.java index 7b27fecde..06f36813e 100644 --- a/src/main/java/com/caoccao/javet/utils/JavetOSUtils.java +++ b/src/main/java/com/caoccao/javet/utils/JavetOSUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/JavetReflectionUtils.java b/src/main/java/com/caoccao/javet/utils/JavetReflectionUtils.java index dd5aa06e1..10c3959b7 100644 --- a/src/main/java/com/caoccao/javet/utils/JavetReflectionUtils.java +++ b/src/main/java/com/caoccao/javet/utils/JavetReflectionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/JavetResourceUtils.java b/src/main/java/com/caoccao/javet/utils/JavetResourceUtils.java index b130ab352..364a7ffe3 100644 --- a/src/main/java/com/caoccao/javet/utils/JavetResourceUtils.java +++ b/src/main/java/com/caoccao/javet/utils/JavetResourceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/JavetTypeUtils.java b/src/main/java/com/caoccao/javet/utils/JavetTypeUtils.java index 4da3cf9e0..aa0d60c62 100644 --- a/src/main/java/com/caoccao/javet/utils/JavetTypeUtils.java +++ b/src/main/java/com/caoccao/javet/utils/JavetTypeUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/JavetVirtualObject.java b/src/main/java/com/caoccao/javet/utils/JavetVirtualObject.java index 638e99caa..047738e76 100644 --- a/src/main/java/com/caoccao/javet/utils/JavetVirtualObject.java +++ b/src/main/java/com/caoccao/javet/utils/JavetVirtualObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/ListUtils.java b/src/main/java/com/caoccao/javet/utils/ListUtils.java new file mode 100644 index 000000000..8de96d2b3 --- /dev/null +++ b/src/main/java/com/caoccao/javet/utils/ListUtils.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.utils; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * The type List utils. + * + * @since 3.0.3 + */ +@SuppressWarnings("unchecked") +public final class ListUtils { + private ListUtils() { + } + + /** + * The includes() method of Array instances determines whether an array includes a certain value among its entries, + * returning true or false as appropriate. + * + * @param the type parameter + * @param list the list + * @param element the element + * @param fromIndex the from index + * @return true : included, false : not included + * @since 3.0.3 + */ + public static boolean includes(List list, T element, int fromIndex) { + int index = 0; + for (T item : list) { + if (Objects.equals(item, element) && index >= fromIndex) { + return true; + } + ++index; + } + return false; + } + + /** + * The pop() method of Array instances removes the last element from an array and returns that element. + * This method changes the length of the array. + * + * @param the type parameter + * @param list the list + * @return the removed element + * @since 3.0.3 + */ + public static T pop(List list) { + final int size = list.size(); + if (size > 0) { + return list.remove(size - 1); + } + return null; + } + + /** + * The push() method of Array instances adds the specified elements to the end of an array + * and returns the new length of the array. + * + * @param the type parameter + * @param list the list + * @param elements the elements + * @return the new length of the array + * @since 3.0.3 + */ + public static int push(List list, T... elements) { + if (ArrayUtils.isNotEmpty(elements)) { + Collections.addAll(list, elements); + } + return list.size(); + } + + /** + * The shift() method of Array instances removes the first element from an array and + * returns that removed element. This method changes the length of the array. + * + * @param the type parameter + * @param list the list + * @return the removed element + */ + public static T shift(List list) { + final int size = list.size(); + if (size > 0) { + return list.remove(0); + } + return null; + } + + /** + * The unshift() method of Array instances adds the specified elements to the beginning of an array and + * returns the new length of the array. + * + * @param the type parameter + * @param list the list + * @param elements the elements + * @return the new length of the array + */ + public static int unshift(List list, T... elements) { + if (ArrayUtils.isNotEmpty(elements)) { + list.addAll(0, Arrays.asList(elements)); + } + return list.size(); + } +} diff --git a/src/main/java/com/caoccao/javet/utils/SimpleFreeMarkerFormat.java b/src/main/java/com/caoccao/javet/utils/SimpleFreeMarkerFormat.java index 74851142b..52fdc8c8e 100644 --- a/src/main/java/com/caoccao/javet/utils/SimpleFreeMarkerFormat.java +++ b/src/main/java/com/caoccao/javet/utils/SimpleFreeMarkerFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,15 +18,35 @@ import java.util.Map; +/** + * The type Simple free marker format. + * + * @since 0.8.5 + */ public final class SimpleFreeMarkerFormat { - + /** + * The constant STRING_NULL. + * + * @since 0.8.5 + */ public static final String STRING_NULL = ""; private static final char CHAR_DOLLAR = '$'; private static final char CHAR_VARIABLE_CLOSE = '}'; private static final char CHAR_VARIABLE_OPEN = '{'; + private SimpleFreeMarkerFormat() { + } + + /** + * Format string. + * + * @param format the format + * @param parameters the parameters + * @return the string + * @since 0.8.5 + */ public static String format(final String format, final Map parameters) { - if (format == null || format.length() == 0 || parameters == null || parameters.isEmpty()) { + if (StringUtils.isEmpty(format) || parameters == null || parameters.isEmpty()) { return format; } final int length = format.length(); @@ -105,9 +125,29 @@ public static String format(final String format, final Map param return stringBuilderMessage.toString(); } + /** + * The enum State. + * + * @since 0.8.5 + */ enum State { + /** + * Text state. + * + * @since 0.8.5 + */ Text, + /** + * Dollar state. + * + * @since 0.8.5 + */ Dollar, + /** + * Variable state. + * + * @since 0.8.5 + */ Variable, } } diff --git a/src/main/java/com/caoccao/javet/utils/SimpleList.java b/src/main/java/com/caoccao/javet/utils/SimpleList.java new file mode 100644 index 000000000..658bb6420 --- /dev/null +++ b/src/main/java/com/caoccao/javet/utils/SimpleList.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023-2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.utils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * The type Simple list. + * + * @since 3.0.3 + */ +public final class SimpleList { + private SimpleList() { + } + + /** + * Of list. + * + * @param the type parameter + * @return the list + * @since 3.0.3 + */ + public static List of() { + return new ArrayList<>(); + } + + /** + * Of list. + * + * @param the type parameter + * @param objects the objects + * @return the list + * @since 3.0.3 + */ + @SafeVarargs + public static List of(T... objects) { + List list = new ArrayList<>(); + Collections.addAll(list, objects); + return list; + } +} diff --git a/src/main/java/com/caoccao/javet/utils/SimpleMap.java b/src/main/java/com/caoccao/javet/utils/SimpleMap.java index 149eb421b..84e856d08 100644 --- a/src/main/java/com/caoccao/javet/utils/SimpleMap.java +++ b/src/main/java/com/caoccao/javet/utils/SimpleMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ * @since 0.8.5 */ public final class SimpleMap { + private SimpleMap() { + } /** * Of map. diff --git a/src/main/java/com/caoccao/javet/utils/SimpleSet.java b/src/main/java/com/caoccao/javet/utils/SimpleSet.java new file mode 100644 index 000000000..5dd90289b --- /dev/null +++ b/src/main/java/com/caoccao/javet/utils/SimpleSet.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023-2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.utils; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * The type Simple set is a polyfill because Set.of() is not available at JDK 8 . + * + * @since 3.0.3 + */ +public final class SimpleSet { + private SimpleSet() { + } + + /** + * Of set. + * + * @param the type parameter + * @return the set + * @since 3.0.3 + */ + public static Set of() { + return new HashSet<>(); + } + + /** + * Of set. + * + * @param the type parameter + * @param objects the objects + * @return the set + * @since 3.0.3 + */ + @SafeVarargs + public static Set of(T... objects) { + Set set = new HashSet<>(); + Collections.addAll(set, objects); + return set; + } +} diff --git a/src/main/java/com/caoccao/javet/utils/JavetStringUtils.java b/src/main/java/com/caoccao/javet/utils/StringUtils.java similarity index 62% rename from src/main/java/com/caoccao/javet/utils/JavetStringUtils.java rename to src/main/java/com/caoccao/javet/utils/StringUtils.java index c98e240c7..bf03342b8 100644 --- a/src/main/java/com/caoccao/javet/utils/JavetStringUtils.java +++ b/src/main/java/com/caoccao/javet/utils/StringUtils.java @@ -1,85 +1,135 @@ -/* - * Copyright (c) 2021-2023. caoccao.com Sam Cao - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.caoccao.javet.utils; - -import java.util.Objects; -import java.util.StringJoiner; - -/** - * The type Javet string utils. - * - * @since 1.0.3 - */ -public final class JavetStringUtils { - private JavetStringUtils() { - } - - /** - * Is digital. - * - * @param str the str - * @return true : yes, false : no - * @since 1.0.6 - */ - public static boolean isDigital(String str) { - if (str == null || str.length() == 0) { - return false; - } - for (int i = 0; i < str.length(); ++i) { - if (!Character.isDigit(str.charAt(i))) { - return false; - } - } - return true; - } - - /** - * Join string. - * - * @param delimiter the delimiter - * @param elements the elements - * @return the string - * @since 1.0.3 - */ - public static String join(CharSequence delimiter, CharSequence... elements) { - Objects.requireNonNull(delimiter); - Objects.requireNonNull(elements); - StringJoiner stringJoiner = new StringJoiner(delimiter); - for (CharSequence cs : elements) { - stringJoiner.add(cs); - } - return stringJoiner.toString(); - } - - /** - * Join string. - * - * @param delimiter the delimiter - * @param elements the elements - * @return the string - * @since 1.0.3 - */ - public static String join(CharSequence delimiter, Iterable elements) { - Objects.requireNonNull(delimiter); - Objects.requireNonNull(elements); - StringJoiner stringJoiner = new StringJoiner(delimiter); - for (CharSequence cs : elements) { - stringJoiner.add(cs); - } - return stringJoiner.toString(); - } -} +/* + * Copyright (c) 2023-2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.utils; + +import java.util.Objects; +import java.util.StringJoiner; + +/** + * The type String utils. + * + * @since 3.0.3 + */ +public final class StringUtils { + /** + * The constant EMPTY. + * + * @since 3.0.3 + */ + public static final String EMPTY = ""; + + private StringUtils() { + } + + /** + * Is blank. + * + * @param str the str + * @return true : blank, false : not blank + * @since 3.0.3 + */ + public static boolean isBlank(String str) { + if (!isEmpty(str)) { + final int length = str.length(); + for (int i = 0; i < length; i++) { + char c = str.charAt(i); + if (c == ' ' || c == '\t' || c == '\r' || c == '\n') { + continue; + } + return false; + } + } + return true; + } + + /** + * Is digital. + * + * @param str the str + * @return true : yes, false : no + * @since 1.0.6 + */ + public static boolean isDigital(String str) { + if (isEmpty(str)) { + return false; + } + for (int i = 0; i < str.length(); ++i) { + if (!Character.isDigit(str.charAt(i))) { + return false; + } + } + return true; + } + + /** + * Is empty. + * + * @param str the str + * @return true : empty, false : not empty + * @since 3.0.3 + */ + public static boolean isEmpty(String str) { + return str == null || str.isEmpty(); + } + + /** + * Is not empty. + * + * @param str the str + * @return true : not empty, false : empty + * @since 3.0.3 + */ + public static boolean isNotEmpty(String str) { + return str != null && !str.isEmpty(); + } + + /** + * Join string. + * + * @param delimiter the delimiter + * @param elements the elements + * @return the string + * @since 1.0.3 + */ + public static String join(CharSequence delimiter, CharSequence... elements) { + Objects.requireNonNull(delimiter); + Objects.requireNonNull(elements); + StringJoiner stringJoiner = new StringJoiner(delimiter); + for (CharSequence cs : elements) { + stringJoiner.add(cs); + } + return stringJoiner.toString(); + } + + /** + * Join string. + * + * @param delimiter the delimiter + * @param elements the elements + * @return the string + * @since 1.0.3 + */ + public static String join(CharSequence delimiter, Iterable elements) { + Objects.requireNonNull(delimiter); + Objects.requireNonNull(elements); + StringJoiner stringJoiner = new StringJoiner(delimiter); + for (CharSequence cs : elements) { + stringJoiner.add(cs); + } + return stringJoiner.toString(); + } +} diff --git a/src/main/java/com/caoccao/javet/utils/V8ValueUtils.java b/src/main/java/com/caoccao/javet/utils/V8ValueUtils.java index e1ddb47f2..c244bd9bc 100644 --- a/src/main/java/com/caoccao/javet/utils/V8ValueUtils.java +++ b/src/main/java/com/caoccao/javet/utils/V8ValueUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package com.caoccao.javet.utils; +import com.caoccao.javet.exceptions.JavetException; +import com.caoccao.javet.interop.V8Runtime; import com.caoccao.javet.values.V8Value; import java.util.StringJoiner; @@ -26,12 +28,6 @@ * @since 0.7.1 */ public final class V8ValueUtils { - /** - * The constant EMPTY. - * - * @since 0.7.1 - */ - public static final String EMPTY = ""; private V8ValueUtils() { } @@ -45,11 +41,11 @@ private V8ValueUtils() { * @since 0.7.1 */ public static String concat(String delimiter, V8Value... v8Values) { - if (v8Values == null || v8Values.length == 0) { - return EMPTY; + if (ArrayUtils.isEmpty(v8Values)) { + return StringUtils.EMPTY; } if (delimiter == null) { - delimiter = EMPTY; + delimiter = StringUtils.EMPTY; } StringJoiner stringJoiner = new StringJoiner(delimiter); for (V8Value v8Value : v8Values) { @@ -66,7 +62,7 @@ public static String concat(String delimiter, V8Value... v8Values) { * @since 0.9.10 */ public static JavetVirtualObject[] convertToVirtualObjects(V8Value... v8Values) { - final int length = v8Values.length; + final int length = v8Values == null ? 0 : v8Values.length; JavetVirtualObject[] javetVirtualObjects = new JavetVirtualObject[length]; for (int i = 0; i < length; ++i) { javetVirtualObjects[i] = new JavetVirtualObject(v8Values[i]); @@ -74,6 +70,24 @@ public static JavetVirtualObject[] convertToVirtualObjects(V8Value... v8Values) return javetVirtualObjects; } + /** + * Convert V8 values to objects. + * + * @param v8Runtime the V8 runtime + * @param v8Values the V8 values + * @return the array + * @throws JavetException the javet exception + * @since 3.0.3 + */ + public static Object[] toArray(V8Runtime v8Runtime, V8Value... v8Values) throws JavetException { + final int length = v8Values == null ? 0 : v8Values.length; + Object[] objects = new Object[length]; + for (int i = 0; i < length; ++i) { + objects[i] = v8Runtime.toObject(v8Values[i]); + } + return objects; + } + /** * Trim anonymous function source code. * diff --git a/src/main/java/com/caoccao/javet/utils/package-info.java b/src/main/java/com/caoccao/javet/utils/package-info.java index 7cc8d7ebc..df8a43232 100644 --- a/src/main/java/com/caoccao/javet/utils/package-info.java +++ b/src/main/java/com/caoccao/javet/utils/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/receivers/IJavetCallbackReceiver.java b/src/main/java/com/caoccao/javet/utils/receivers/IJavetCallbackReceiver.java index b3bed6ca2..4c44340c2 100644 --- a/src/main/java/com/caoccao/javet/utils/receivers/IJavetCallbackReceiver.java +++ b/src/main/java/com/caoccao/javet/utils/receivers/IJavetCallbackReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/utils/receivers/JavetCallbackReceiver.java b/src/main/java/com/caoccao/javet/utils/receivers/JavetCallbackReceiver.java index 7db5f98b4..2c6530747 100644 --- a/src/main/java/com/caoccao/javet/utils/receivers/JavetCallbackReceiver.java +++ b/src/main/java/com/caoccao/javet/utils/receivers/JavetCallbackReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import com.caoccao.javet.annotations.CheckReturnValue; import com.caoccao.javet.exceptions.JavetException; import com.caoccao.javet.interop.V8Runtime; -import com.caoccao.javet.utils.JavetStringUtils; +import com.caoccao.javet.utils.StringUtils; import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.reference.V8ValueArray; @@ -129,7 +129,7 @@ public String echoString(V8Value... args) { for (V8Value arg : args) { stringList.add(arg == null ? null : arg.toString()); } - return JavetStringUtils.join(COMMA, stringList); + return StringUtils.join(COMMA, stringList); } @Override diff --git a/src/main/java/com/caoccao/javet/utils/receivers/package-info.java b/src/main/java/com/caoccao/javet/utils/receivers/package-info.java index a6d6fa4cc..d9205ca43 100644 --- a/src/main/java/com/caoccao/javet/utils/receivers/package-info.java +++ b/src/main/java/com/caoccao/javet/utils/receivers/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/IV8Value.java b/src/main/java/com/caoccao/javet/values/IV8Value.java index 0e27626cd..ab9e56a40 100644 --- a/src/main/java/com/caoccao/javet/values/IV8Value.java +++ b/src/main/java/com/caoccao/javet/values/IV8Value.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/V8Data.java b/src/main/java/com/caoccao/javet/values/V8Data.java index a0f1f140b..8ea795684 100644 --- a/src/main/java/com/caoccao/javet/values/V8Data.java +++ b/src/main/java/com/caoccao/javet/values/V8Data.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/V8Value.java b/src/main/java/com/caoccao/javet/values/V8Value.java index 6ac76cf12..6a8efdd1e 100644 --- a/src/main/java/com/caoccao/javet/values/V8Value.java +++ b/src/main/java/com/caoccao/javet/values/V8Value.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/package-info.java b/src/main/java/com/caoccao/javet/values/package-info.java index c23548eba..520dd5a53 100644 --- a/src/main/java/com/caoccao/javet/values/package-info.java +++ b/src/main/java/com/caoccao/javet/values/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueBigInteger.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueBigInteger.java index 678c432ad..930137625 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueBigInteger.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueBigInteger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import com.caoccao.javet.exceptions.JavetException; import com.caoccao.javet.interop.V8Runtime; +import com.caoccao.javet.utils.ArrayUtils; import java.math.BigInteger; import java.util.Objects; @@ -96,7 +97,7 @@ public V8ValueBigInteger(V8Runtime v8Runtime, String value) throws JavetExceptio * @since 1.1.5 */ static BigInteger toBigInteger(int signum, long[] longArray) { - if (signum == 0 || signum > 1 || signum < -1 || longArray == null || longArray.length == 0) { + if (signum == 0 || signum > 1 || signum < -1 || ArrayUtils.isEmpty(longArray)) { return BigInteger.ZERO; } final int longLength = longArray.length; diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueBoolean.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueBoolean.java index d6bc7fbd7..093c82ec9 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueBoolean.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueDouble.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueDouble.java index 906a38c44..4b3b0bc17 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueDouble.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueInteger.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueInteger.java index be733ac2e..0eae10a78 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueInteger.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueInteger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueLong.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueLong.java index 9e31c50c6..fc0c1095a 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueLong.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueNull.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueNull.java index 57c6f940b..b9c5d401e 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueNull.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueNull.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValuePrimitive.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValuePrimitive.java index 30c98cee4..0ce47f5ba 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValuePrimitive.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValuePrimitive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueString.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueString.java index 0bbf9f932..ed2dda5ed 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueString.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueUndefined.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueUndefined.java index 4d5be3692..56e563cc1 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueUndefined.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueUndefined.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueUnknown.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueUnknown.java index 020f11b9a..9ae8392fd 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueUnknown.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueUnknown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/V8ValueZonedDateTime.java b/src/main/java/com/caoccao/javet/values/primitive/V8ValueZonedDateTime.java index b59c88ab0..1cb140bd0 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/V8ValueZonedDateTime.java +++ b/src/main/java/com/caoccao/javet/values/primitive/V8ValueZonedDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/primitive/package-info.java b/src/main/java/com/caoccao/javet/values/primitive/package-info.java index da0633cf7..a940d29c9 100644 --- a/src/main/java/com/caoccao/javet/values/primitive/package-info.java +++ b/src/main/java/com/caoccao/javet/values/primitive/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8Cacheable.java b/src/main/java/com/caoccao/javet/values/reference/IV8Cacheable.java index 1692d88a1..61d7c5ad4 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8Cacheable.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8Cacheable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8Context.java b/src/main/java/com/caoccao/javet/values/reference/IV8Context.java index f5c1e8cbe..e85068bde 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8Context.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8Context.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8Module.java b/src/main/java/com/caoccao/javet/values/reference/IV8Module.java index 8279d84e2..9d5cfab5c 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8Module.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8Module.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8Script.java b/src/main/java/com/caoccao/javet/values/reference/IV8Script.java index 12ee3c649..e1a7652fb 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8Script.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8Script.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueArray.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueArray.java index e82f9fd7d..ceea18330 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueArray.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueFunction.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueFunction.java index ef518e8a6..f59b93e71 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueFunction.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueIterator.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueIterator.java index 33047dde0..41134bb9f 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueIterator.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueKeyContainer.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueKeyContainer.java index 19ae29b4d..a3daa6c72 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueKeyContainer.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueKeyContainer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueMap.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueMap.java index e6bd4119d..44f1b5a03 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueMap.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueObject.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueObject.java index 63f9c29db..c572a5e4c 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueObject.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValuePromise.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValuePromise.java index 940fa49ee..0269c58cb 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValuePromise.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValuePromise.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueProxy.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueProxy.java index 85b68f9f8..38e115850 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueProxy.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueReference.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueReference.java index 657e8aab9..14b733d08 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueReference.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueSet.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueSet.java index 23ce83f39..982f965c5 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueSet.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/IV8ValueTypedArray.java b/src/main/java/com/caoccao/javet/values/reference/IV8ValueTypedArray.java index ef866810d..f497d3cfa 100644 --- a/src/main/java/com/caoccao/javet/values/reference/IV8ValueTypedArray.java +++ b/src/main/java/com/caoccao/javet/values/reference/IV8ValueTypedArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8Context.java b/src/main/java/com/caoccao/javet/values/reference/V8Context.java index c5fe51f56..72867cdeb 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8Context.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8Context.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8Module.java b/src/main/java/com/caoccao/javet/values/reference/V8Module.java index 191c80438..09d30c876 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8Module.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8Module.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8Script.java b/src/main/java/com/caoccao/javet/values/reference/V8Script.java index e158ebb3c..98f35bc34 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8Script.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8Script.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueArguments.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueArguments.java index 62b6202b4..821d260bc 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueArguments.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueArguments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueArray.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueArray.java index 299124f01..7e6894ac5 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueArray.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueArrayBuffer.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueArrayBuffer.java index a34ab197b..383532606 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueArrayBuffer.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueArrayBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueDataView.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueDataView.java index e2194e8fd..4c79a4cde 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueDataView.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueDataView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueError.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueError.java index ec02f8f34..5418d521e 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueError.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueFunction.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueFunction.java index 4e27e203a..d8aa68847 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueFunction.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueGlobalObject.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueGlobalObject.java index caa2f41bc..9ef54f910 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueGlobalObject.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueGlobalObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueIterator.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueIterator.java index ac47cd05f..f8f7ae7c1 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueIterator.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueMap.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueMap.java index 9752f0259..fb5692388 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueMap.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueObject.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueObject.java index 3f208d3ea..204586bc0 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueObject.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValuePromise.java b/src/main/java/com/caoccao/javet/values/reference/V8ValuePromise.java index a50c8b705..c89cf58e0 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValuePromise.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValuePromise.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import com.caoccao.javet.enums.V8ValueReferenceType; import com.caoccao.javet.exceptions.JavetException; import com.caoccao.javet.interop.V8Runtime; +import com.caoccao.javet.interop.callback.IJavetDirectCallable; import com.caoccao.javet.interop.callback.JavetCallbackContext; +import com.caoccao.javet.interop.callback.JavetCallbackType; import com.caoccao.javet.values.V8Value; /** @@ -82,17 +84,14 @@ public boolean register(IListener listener) throws JavetException { checkV8Runtime(); try { JavetCallbackContext contextOnCatch = new JavetCallbackContext( - IListener.ON_CATCH, - listener, - listener.getClass().getMethod(IListener.ON_CATCH, V8Value.class)); + IListener.ON_CATCH, listener, JavetCallbackType.DirectCallNoThisAndNoResult, + (IJavetDirectCallable.NoThisAndNoResult) (v8Values) -> listener.onCatch(v8Values[0])); JavetCallbackContext contextOnFulfilled = new JavetCallbackContext( - IListener.ON_FULFILLED, - listener, - listener.getClass().getMethod(IListener.ON_FULFILLED, V8Value.class)); + IListener.ON_FULFILLED,listener, JavetCallbackType.DirectCallNoThisAndNoResult, + (IJavetDirectCallable.NoThisAndNoResult) (v8Values) -> listener.onFulfilled(v8Values[0])); JavetCallbackContext contextOnRejected = new JavetCallbackContext( - IListener.ON_REJECTED, - listener, - listener.getClass().getMethod(IListener.ON_REJECTED, V8Value.class)); + IListener.ON_REJECTED,listener, JavetCallbackType.DirectCallNoThisAndNoResult, + (IJavetDirectCallable.NoThisAndNoResult) (v8Values) -> listener.onRejected(v8Values[0])); try (V8ValueFunction functionOnCatch = v8Runtime.createV8ValueFunction(contextOnCatch); V8ValueFunction functionOnFulfilled = v8Runtime.createV8ValueFunction(contextOnFulfilled); V8ValueFunction functionOnRejected = v8Runtime.createV8ValueFunction(contextOnRejected); diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueProxy.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueProxy.java index d3148b47b..71aea8f50 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueProxy.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueReference.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueReference.java index b226d312e..5784bef1d 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueReference.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueRegExp.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueRegExp.java index fb1bc2755..ec40c58c8 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueRegExp.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueRegExp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueSet.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueSet.java index 91e4eb3d4..f8759a223 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueSet.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueSharedArrayBuffer.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueSharedArrayBuffer.java index d76c70348..f7080ea6d 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueSharedArrayBuffer.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueSharedArrayBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueSymbol.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueSymbol.java index 3bb27e83c..66e568148 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueSymbol.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueSymbol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueSymbolObject.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueSymbolObject.java index 038ace479..d0e254e5a 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueSymbolObject.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueSymbolObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueTypedArray.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueTypedArray.java index 45a5e7512..d9c0fb502 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueTypedArray.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueTypedArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueWeakMap.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueWeakMap.java index 7d43a5c83..dda5a30c9 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueWeakMap.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueWeakMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/V8ValueWeakSet.java b/src/main/java/com/caoccao/javet/values/reference/V8ValueWeakSet.java index 1b3e58716..17c9a6c40 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8ValueWeakSet.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8ValueWeakSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInJson.java b/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInJson.java index 95b26c909..28f17db53 100644 --- a/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInJson.java +++ b/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInJson.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInObject.java b/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInObject.java index 2c25a2e27..c89a5cbd7 100644 --- a/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInObject.java +++ b/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInPromise.java b/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInPromise.java index 05f59f51c..0772fb950 100644 --- a/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInPromise.java +++ b/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInPromise.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInSymbol.java b/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInSymbol.java index eb424504a..0209bab4c 100644 --- a/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInSymbol.java +++ b/src/main/java/com/caoccao/javet/values/reference/builtin/V8ValueBuiltInSymbol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/builtin/package-info.java b/src/main/java/com/caoccao/javet/values/reference/builtin/package-info.java index 988596224..8d2a06db6 100644 --- a/src/main/java/com/caoccao/javet/values/reference/builtin/package-info.java +++ b/src/main/java/com/caoccao/javet/values/reference/builtin/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/reference/package-info.java b/src/main/java/com/caoccao/javet/values/reference/package-info.java index 21e33bdc2..dc0ead9bd 100644 --- a/src/main/java/com/caoccao/javet/values/reference/package-info.java +++ b/src/main/java/com/caoccao/javet/values/reference/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/virtual/V8VirtualIterator.java b/src/main/java/com/caoccao/javet/values/virtual/V8VirtualIterator.java index 4f705a8f8..a9e94d2cb 100644 --- a/src/main/java/com/caoccao/javet/values/virtual/V8VirtualIterator.java +++ b/src/main/java/com/caoccao/javet/values/virtual/V8VirtualIterator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,8 @@ import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.primitive.V8ValueString; import com.caoccao.javet.values.reference.V8ValueArray; +import com.caoccao.javet.values.reference.V8ValueSymbol; +import com.caoccao.javet.values.reference.builtin.V8ValueBuiltInSymbol; import java.util.Iterator; import java.util.Objects; @@ -75,7 +77,7 @@ public class V8VirtualIterator * * @since 2.2.1 */ - protected Optional value; + protected T value; /** * Instantiates a new V8 virtual iterator. @@ -105,7 +107,7 @@ public V8Runtime getV8Runtime() { protected V8Value next(V8Value thisObject, V8Value... v8Values) { if (iterator != null) { if (iterator.hasNext()) { - value = Optional.ofNullable(iterator.next()); + value = iterator.next(); } else { iterator = null; value = null; @@ -121,21 +123,26 @@ public V8Value proxyGet(V8Value target, V8Value property, V8Value receiver) thro if (FUNCTION_NEXT.equals(propertyName)) { return v8Runtime.createV8ValueFunction( new JavetCallbackContext( - FUNCTION_NEXT, - JavetCallbackType.DirectCallThisAndResult, + FUNCTION_NEXT, this, JavetCallbackType.DirectCallThisAndResult, (IJavetDirectCallable.ThisAndResult) this::next)); } if (PROPERTY_DONE.equals(propertyName)) { - return v8Runtime.createV8ValueBoolean(iterator == null || !iterator.hasNext()); + return v8Runtime.createV8ValueBoolean(iterator == null); } if (PROPERTY_VALUE.equals(propertyName)) { - if (value == null) { + if (iterator == null) { return v8Runtime.createV8ValueUndefined(); } - if (value.isPresent()) { - return v8Runtime.toV8Value(value.get()); - } - return v8Runtime.createV8ValueNull(); + return v8Runtime.toV8Value(value); + } + } + if (property instanceof V8ValueSymbol) { + V8ValueSymbol propertySymbol = (V8ValueSymbol) property; + String description = propertySymbol.getDescription(); + if (V8ValueBuiltInSymbol.SYMBOL_PROPERTY_ITERATOR.equals(description)) { + return v8Runtime.createV8ValueFunction(new JavetCallbackContext( + FUNCTION_NEXT, this, JavetCallbackType.DirectCallThisAndResult, + (IJavetDirectCallable.ThisAndResult) (thisObject, v8Values) -> thisObject)); } } return IJavetDirectProxyHandler.super.proxyGet(target, property, receiver); diff --git a/src/main/java/com/caoccao/javet/values/virtual/V8VirtualValue.java b/src/main/java/com/caoccao/javet/values/virtual/V8VirtualValue.java index b2d4fd37d..d13920d4e 100644 --- a/src/main/java/com/caoccao/javet/values/virtual/V8VirtualValue.java +++ b/src/main/java/com/caoccao/javet/values/virtual/V8VirtualValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/caoccao/javet/values/virtual/V8VirtualValueList.java b/src/main/java/com/caoccao/javet/values/virtual/V8VirtualValueList.java index d81dffa97..5e11dfde5 100644 --- a/src/main/java/com/caoccao/javet/values/virtual/V8VirtualValueList.java +++ b/src/main/java/com/caoccao/javet/values/virtual/V8VirtualValueList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.caoccao.javet.interfaces.IJavetClosable; import com.caoccao.javet.interop.V8Runtime; import com.caoccao.javet.interop.converters.IJavetConverter; +import com.caoccao.javet.utils.ArrayUtils; import com.caoccao.javet.utils.JavetResourceUtils; import com.caoccao.javet.values.V8Value; @@ -58,7 +59,7 @@ public class V8VirtualValueList implements IJavetClosable { */ public V8VirtualValueList(V8Runtime v8Runtime, IJavetConverter converter, Object... objects) throws JavetException { Objects.requireNonNull(v8Runtime); - if (objects == null || objects.length == 0) { + if (ArrayUtils.isEmpty(objects)) { toBeClosedValues = null; values = null; } else { diff --git a/src/main/java/com/caoccao/javet/values/virtual/package-info.java b/src/main/java/com/caoccao/javet/values/virtual/package-info.java index 0365a728c..60de6588f 100644 --- a/src/main/java/com/caoccao/javet/values/virtual/package-info.java +++ b/src/main/java/com/caoccao/javet/values/virtual/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/BaseTestJavet.java b/src/test/java/com/caoccao/javet/BaseTestJavet.java index 426d3c9ba..4b2df5305 100644 --- a/src/test/java/com/caoccao/javet/BaseTestJavet.java +++ b/src/test/java/com/caoccao/javet/BaseTestJavet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/BaseTestJavetPool.java b/src/test/java/com/caoccao/javet/BaseTestJavetPool.java index 3368e5843..1b4256fb5 100644 --- a/src/test/java/com/caoccao/javet/BaseTestJavetPool.java +++ b/src/test/java/com/caoccao/javet/BaseTestJavetPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/BaseTestJavetRuntime.java b/src/test/java/com/caoccao/javet/BaseTestJavetRuntime.java index 9fff4097c..3096439c2 100644 --- a/src/test/java/com/caoccao/javet/BaseTestJavetRuntime.java +++ b/src/test/java/com/caoccao/javet/BaseTestJavetRuntime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/exceptions/TestJavetCompilationException.java b/src/test/java/com/caoccao/javet/exceptions/TestJavetCompilationException.java index 2a852c365..4a65c6056 100644 --- a/src/test/java/com/caoccao/javet/exceptions/TestJavetCompilationException.java +++ b/src/test/java/com/caoccao/javet/exceptions/TestJavetCompilationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/exceptions/TestJavetError.java b/src/test/java/com/caoccao/javet/exceptions/TestJavetError.java index 0226ecd16..8e7e39062 100644 --- a/src/test/java/com/caoccao/javet/exceptions/TestJavetError.java +++ b/src/test/java/com/caoccao/javet/exceptions/TestJavetError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.caoccao.javet.exceptions; import com.caoccao.javet.utils.JavetOSUtils; +import com.caoccao.javet.utils.StringUtils; import org.junit.jupiter.api.Test; import java.io.File; @@ -33,8 +34,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class TestJavetError { @Test @@ -85,20 +85,20 @@ public void generateDocument() throws IllegalAccessException, IOException { row[3] = cell; } } - assertTrue(table.size() > 0); + assertFalse(table.isEmpty()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(fileContent, 0, startPosition); String separator = Arrays.stream(maxLengths) - .mapToObj(length -> String.join("", Collections.nCopies(length, "="))) + .mapToObj(length -> String.join(StringUtils.EMPTY, Collections.nCopies(length, "="))) .collect(Collectors.joining(" ")); stringBuilder.append(separator).append("\n"); stringBuilder.append(IntStream.range(0, maxLengths.length) - .mapToObj(i -> String.format("%1$-" + Integer.toString(maxLengths[i]) + "s", headerRow[i])) + .mapToObj(i -> String.format("%1$-" + maxLengths[i] + "s", headerRow[i])) .collect(Collectors.joining(" "))).append("\n"); stringBuilder.append(separator).append("\n"); for (String[] row : table.values()) { stringBuilder.append(IntStream.range(0, maxLengths.length) - .mapToObj(i -> String.format("%1$-" + Integer.toString(maxLengths[i]) + "s", row[i])) + .mapToObj(i -> String.format("%1$-" + maxLengths[i] + "s", row[i])) .collect(Collectors.joining(" "))).append("\n"); } stringBuilder.append(separator).append("\n\n\n"); diff --git a/src/test/java/com/caoccao/javet/exceptions/TestJavetException.java b/src/test/java/com/caoccao/javet/exceptions/TestJavetException.java index 226a79a6a..cb1eb015a 100644 --- a/src/test/java/com/caoccao/javet/exceptions/TestJavetException.java +++ b/src/test/java/com/caoccao/javet/exceptions/TestJavetException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/exceptions/TestJavetExecutionException.java b/src/test/java/com/caoccao/javet/exceptions/TestJavetExecutionException.java index bc4438b6e..9c670ee23 100644 --- a/src/test/java/com/caoccao/javet/exceptions/TestJavetExecutionException.java +++ b/src/test/java/com/caoccao/javet/exceptions/TestJavetExecutionException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interception/jvm/TestJavetJVMInterceptor.java b/src/test/java/com/caoccao/javet/interception/jvm/TestJavetJVMInterceptor.java new file mode 100644 index 000000000..2f308f3a7 --- /dev/null +++ b/src/test/java/com/caoccao/javet/interception/jvm/TestJavetJVMInterceptor.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2021-2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.interception.jvm; + +import com.caoccao.javet.BaseTestJavetRuntime; +import com.caoccao.javet.exceptions.JavetException; +import com.caoccao.javet.interop.converters.JavetProxyConverter; +import com.caoccao.javet.interop.proxy.JavetReflectionObjectFactory; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +public class TestJavetJVMInterceptor extends BaseTestJavetRuntime { + protected JavetJVMInterceptor javetJVMInterceptor; + + @AfterEach + @Override + public void afterEach() throws JavetException { + assertTrue(javetJVMInterceptor.unregister(v8Runtime.getGlobalObject())); + v8Runtime.lowMemoryNotification(); + super.afterEach(); + } + + @BeforeEach + @Override + public void beforeEach() throws JavetException { + super.beforeEach(); + JavetProxyConverter javetProxyConverter = new JavetProxyConverter(); + javetProxyConverter.getConfig().setReflectionObjectFactory(JavetReflectionObjectFactory.getInstance()); + v8Runtime.setConverter(javetProxyConverter); + javetJVMInterceptor = new JavetJVMInterceptor(v8Runtime); + assertTrue(javetJVMInterceptor.register(v8Runtime.getGlobalObject())); + } + + @Test + public void testGC() throws JavetException { + int initialCallbackContextCount = v8Runtime.getCallbackContextCount(); + v8Runtime.getGlobalObject().set("test", String.class); + // The proxy creates 5 callback contexts. + assertEquals(initialCallbackContextCount + 5, v8Runtime.getCallbackContextCount()); + v8Runtime.getGlobalObject().delete("test"); + // The 5 callback contexts are not recycled. + assertEquals(initialCallbackContextCount + 5, v8Runtime.getCallbackContextCount()); + v8Runtime.getExecutor("javet.v8.gc()").executeVoid(); + // javet.v8 creates another 5 callback contexts while the gc() collects 5 callback contexts. + assertEquals(initialCallbackContextCount + 5, v8Runtime.getCallbackContextCount()); + v8Runtime.lowMemoryNotification(); + assertEquals(initialCallbackContextCount, v8Runtime.getCallbackContextCount()); + } + + @Test + public void testPackage() throws JavetException { + // Test java + v8Runtime.getExecutor("let java = javet.package.java").executeVoid(); + assertFalse(v8Runtime.getExecutor("java['.valid']").executeBoolean()); + assertEquals("java", v8Runtime.getExecutor("java['.name']").executeString()); + // Test java.util + v8Runtime.getExecutor("let javaUtil = java.util").executeVoid(); + assertTrue(v8Runtime.getExecutor("javaUtil['.valid']").executeBoolean()); + assertFalse(v8Runtime.getExecutor("javaUtil['.sealed']").executeBoolean()); + assertEquals("java.util", v8Runtime.getExecutor("javaUtil['.name']").executeString()); + // Test java.lang.Object + assertEquals(Object.class, v8Runtime.getExecutor("java.lang.Object").executeObject()); + // Test invalid cases + assertInstanceOf( + JavetJVMInterceptor.JavetVirtualPackage.class, + v8Runtime.getExecutor("javet.package.abc.def").executeObject()); + assertInstanceOf( + JavetJVMInterceptor.JavetVirtualPackage.class, + v8Runtime.getExecutor("java.lang.abcdefg").executeObject()); + // Clean up + v8Runtime.getExecutor("java = undefined; javaUtil = undefined").executeVoid(); + } + + @Test + public void testStringBuilder() throws JavetException { + v8Runtime.getExecutor("let java = javet.package.java").executeVoid(); + assertEquals( + "a1", + v8Runtime.getExecutor("let sb = new java.lang.StringBuilder(); sb.append('a').append(1); sb.toString();").executeString()); + v8Runtime.getExecutor("java = undefined; sb = undefined;").executeVoid(); + } + + @Test + public void testThread() throws JavetException, InterruptedException { + Thread thread = v8Runtime.getExecutor( + "let java = javet.package.java;" + + "let count = 0;" + + "let thread = new java.lang.Thread(() => { count++; });" + + "thread.start();" + + "thread; " + ).executeObject(); + thread.join(); + assertEquals(1, v8Runtime.getExecutor("count").executeInteger()); + v8Runtime.getExecutor("java = undefined; thread = undefined;").executeVoid(); + System.gc(); + System.runFinalization(); + System.gc(); + System.runFinalization(); + } +} diff --git a/src/test/java/com/caoccao/javet/interception/logging/TestJavetStandardConsoleInterceptor.java b/src/test/java/com/caoccao/javet/interception/logging/TestJavetStandardConsoleInterceptor.java index 090b0d4a3..a4d9de271 100644 --- a/src/test/java/com/caoccao/javet/interception/logging/TestJavetStandardConsoleInterceptor.java +++ b/src/test/java/com/caoccao/javet/interception/logging/TestJavetStandardConsoleInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/TestJavetLibLoader.java b/src/test/java/com/caoccao/javet/interop/TestJavetLibLoader.java index 4d356126e..9e7f990dd 100644 --- a/src/test/java/com/caoccao/javet/interop/TestJavetLibLoader.java +++ b/src/test/java/com/caoccao/javet/interop/TestJavetLibLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java b/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java index 6db4d8d88..b7c27f15e 100644 --- a/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java +++ b/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ public void testModuleProcess() throws JavetException { Path path4 = nodeModuleProcess.getWorkingDirectory().toPath(); assertNotEquals(path1.toAbsolutePath().toString(), path3.toAbsolutePath().toString()); assertEquals(path1.toAbsolutePath().toString(), path4.toAbsolutePath().toString()); - assertEquals("v20.10.0", nodeModuleProcess.getVersion()); + assertEquals("v20.11.0", nodeModuleProcess.getVersion()); } @Test diff --git a/src/test/java/com/caoccao/javet/interop/TestV8Host.java b/src/test/java/com/caoccao/javet/interop/TestV8Host.java index a2e0f5b1a..4046a13f9 100644 --- a/src/test/java/com/caoccao/javet/interop/TestV8Host.java +++ b/src/test/java/com/caoccao/javet/interop/TestV8Host.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/TestV8Inspector.java b/src/test/java/com/caoccao/javet/interop/TestV8Inspector.java index 8e6c3ff74..0eb020749 100644 --- a/src/test/java/com/caoccao/javet/interop/TestV8Inspector.java +++ b/src/test/java/com/caoccao/javet/interop/TestV8Inspector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/TestV8Locker.java b/src/test/java/com/caoccao/javet/interop/TestV8Locker.java index fa25af201..480789a00 100644 --- a/src/test/java/com/caoccao/javet/interop/TestV8Locker.java +++ b/src/test/java/com/caoccao/javet/interop/TestV8Locker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/TestV8Native.java b/src/test/java/com/caoccao/javet/interop/TestV8Native.java index d1d4092be..a9ded912f 100644 --- a/src/test/java/com/caoccao/javet/interop/TestV8Native.java +++ b/src/test/java/com/caoccao/javet/interop/TestV8Native.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/TestV8Runtime.java b/src/test/java/com/caoccao/javet/interop/TestV8Runtime.java index b6775c451..3cfabd24f 100644 --- a/src/test/java/com/caoccao/javet/interop/TestV8Runtime.java +++ b/src/test/java/com/caoccao/javet/interop/TestV8Runtime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,13 +24,14 @@ import com.caoccao.javet.exceptions.JavetExecutionException; import com.caoccao.javet.exceptions.JavetTerminatedException; import com.caoccao.javet.interop.callback.IJavetGCCallback; +import com.caoccao.javet.interop.options.RuntimeOptions; import com.caoccao.javet.interop.options.V8RuntimeOptions; +import com.caoccao.javet.utils.SimpleList; import com.caoccao.javet.values.reference.V8ValueGlobalObject; import com.caoccao.javet.values.reference.V8ValueObject; import org.junit.jupiter.api.Test; import java.util.ArrayList; -import java.util.Arrays; import java.util.EnumSet; import java.util.List; import java.util.concurrent.TimeUnit; @@ -40,7 +41,7 @@ public class TestV8Runtime extends BaseTestJavet { @Test public void testAllowEval() throws JavetException { - List codeStrings = Arrays.asList( + List codeStrings = SimpleList.of( "(() => eval('1'))()", "(() => Function('return 1')())()"); try (V8Runtime v8Runtime = v8Host.createV8Runtime()) { @@ -201,6 +202,65 @@ public void testResetIsolate() throws JavetException { } } + @Test + public void testSnapshot() throws JavetException { + if (v8Host.getJSRuntimeType().isV8()) { + RuntimeOptions options = v8Host.getJSRuntimeType().getRuntimeOptions(); + // Set create snapshot enabled. + options.setCreateSnapshotEnabled(true); + byte[] snapshotBlob1; + byte[] snapshotBlob2; + try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) { + // Prepare function add. + v8Runtime.getExecutor("const add = (a, b) => a + b;").executeVoid(); + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + // Create a snapshot with function add. + snapshotBlob1 = v8Runtime.createSnapshot(); + assertNotNull(snapshotBlob1); + assertTrue(snapshotBlob1.length > 0); + // Test the runtime is still usable after the snapshot is created. + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + } + // Set the snapshot blob. + options.setSnapshotBlob(snapshotBlob1); + for (int i = 0; i < 5; ++i) { + // Create a new V8 runtime with the snapshot 5 times. + try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) { + // Test the function add. + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + } + } + // Create a new V8 runtime with the snapshot. + try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) { + // Test the function add. + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + // Prepare function subtract. + v8Runtime.getExecutor("const subtract = (a, b) => a - b;").executeVoid(); + // Create a new snapshot with function add and subtract. + snapshotBlob2 = v8Runtime.createSnapshot(); + assertNotNull(snapshotBlob2); + assertTrue(snapshotBlob2.length > 0); + } + // Set the new snapshot blob. + options.setSnapshotBlob(snapshotBlob2); + for (int i = 0; i < 5; ++i) { + // Create a new V8 runtime with the snapshot 5 times. + try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) { + // Test the function add and subtract. + assertEquals(3, v8Runtime.getExecutor("add(1, 2)").executeInteger()); + assertEquals(1, v8Runtime.getExecutor("subtract(3, 2)").executeInteger()); + } + } + options.setCreateSnapshotEnabled(false).setSnapshotBlob(null); + try (V8Runtime v8Runtime = v8Host.createV8Runtime(options)) { + v8Runtime.createSnapshot(); + fail("Failed to report create snapshot disabled"); + } catch (JavetException e) { + assertEquals(JavetError.RuntimeCreateSnapshotDisabled.getCode(), e.getError().getCode()); + } + } + } + @Test public void testTerminateExecution() throws JavetException { final int maxCycle = 3; diff --git a/src/test/java/com/caoccao/javet/interop/TestV8Scope.java b/src/test/java/com/caoccao/javet/interop/TestV8Scope.java index 08f6075e3..b0754ea0d 100644 --- a/src/test/java/com/caoccao/javet/interop/TestV8Scope.java +++ b/src/test/java/com/caoccao/javet/interop/TestV8Scope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/callback/TestV8FunctionCallback.java b/src/test/java/com/caoccao/javet/interop/callback/TestV8FunctionCallback.java index 4e1d0c28e..317257af3 100644 --- a/src/test/java/com/caoccao/javet/interop/callback/TestV8FunctionCallback.java +++ b/src/test/java/com/caoccao/javet/interop/callback/TestV8FunctionCallback.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/converters/TestJavetBridgeConverter.java b/src/test/java/com/caoccao/javet/interop/converters/TestJavetBridgeConverter.java index b9d65b478..4b9762fa1 100644 --- a/src/test/java/com/caoccao/javet/interop/converters/TestJavetBridgeConverter.java +++ b/src/test/java/com/caoccao/javet/interop/converters/TestJavetBridgeConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ import com.caoccao.javet.BaseTestJavetRuntime; import com.caoccao.javet.exceptions.JavetException; +import com.caoccao.javet.utils.SimpleList; +import com.caoccao.javet.utils.SimpleSet; import com.caoccao.javet.values.virtual.V8VirtualIterator; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -30,7 +32,6 @@ import static org.junit.jupiter.api.Assertions.*; public class TestJavetBridgeConverter extends BaseTestJavetRuntime { - protected String functionCastString; protected JavetBridgeConverter javetBridgeConverter; public TestJavetBridgeConverter() { @@ -78,9 +79,9 @@ public void testIntArray() throws JavetException { assertEquals(Integer.valueOf(1), v8Runtime.getExecutor("a[Symbol.iterator]().next().value").executeObject()); assertFalse(v8Runtime.getExecutor("a[Symbol.iterator]().next().done").executeBoolean()); assertEquals(Integer.valueOf(2), v8Runtime.getExecutor("a[Symbol.iterator]().next().next().value").executeObject()); - assertTrue(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().done").executeBoolean()); - assertTrue(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().next().value").execute().isUndefined()); + assertFalse(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().done").executeBoolean()); assertTrue(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().next().done").executeBoolean()); + assertTrue(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().next().value").execute().isUndefined()); assertArrayEquals(intArray, v8Runtime.getExecutor("a.toV8Value()").executeObject()); v8Runtime.getGlobalObject().delete("a"); } @@ -108,9 +109,9 @@ public void testIntegerArray() throws JavetException { assertEquals(Integer.valueOf(1), v8Runtime.getExecutor("a[Symbol.iterator]().next().value").executeObject()); assertFalse(v8Runtime.getExecutor("a[Symbol.iterator]().next().done").executeBoolean()); assertEquals(Integer.valueOf(2), v8Runtime.getExecutor("a[Symbol.iterator]().next().next().value").executeObject()); - assertTrue(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().done").executeBoolean()); - assertTrue(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().next().value").execute().isUndefined()); + assertFalse(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().done").executeBoolean()); assertTrue(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().next().done").executeBoolean()); + assertTrue(v8Runtime.getExecutor("a[Symbol.iterator]().next().next().next().value").execute().isUndefined()); assertEquals("[1,2]", v8Runtime.getExecutor("JSON.stringify(a.toV8Value())").executeString()); v8Runtime.getGlobalObject().delete("a"); } @@ -144,7 +145,7 @@ public void testLong() throws JavetException { @Test public void testLongList() throws JavetException { - List longList = Collections.unmodifiableList(Arrays.asList(1L, 2L)); + List longList = Collections.unmodifiableList(SimpleList.of(1L, 2L)); v8Runtime.getGlobalObject().set("a", longList); assertEquals(2, (Integer) v8Runtime.getExecutor("a.size()").executeObject()); assertEquals(1L, (Long) v8Runtime.getExecutor("a[0]").executeObject()); @@ -178,10 +179,7 @@ public void testMap() throws JavetException { @Test public void testSet() throws JavetException { - Set set = new HashSet() {{ - add("x"); - add("y"); - }}; + Set set = SimpleSet.of("x", "y"); v8Runtime.getGlobalObject().set("set", set); assertSame(set, v8Runtime.getGlobalObject().getObject("set")); assertTrue((Boolean) v8Runtime.getExecutor("set.contains('x')").executeObject()); diff --git a/src/test/java/com/caoccao/javet/interop/converters/TestJavetCustomConverter.java b/src/test/java/com/caoccao/javet/interop/converters/TestJavetCustomConverter.java index 93cd00a37..52e588f93 100644 --- a/src/test/java/com/caoccao/javet/interop/converters/TestJavetCustomConverter.java +++ b/src/test/java/com/caoccao/javet/interop/converters/TestJavetCustomConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/converters/TestJavetObjectConverter.java b/src/test/java/com/caoccao/javet/interop/converters/TestJavetObjectConverter.java index d9998da4b..9c3563f1e 100644 --- a/src/test/java/com/caoccao/javet/interop/converters/TestJavetObjectConverter.java +++ b/src/test/java/com/caoccao/javet/interop/converters/TestJavetObjectConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,12 +27,17 @@ import com.caoccao.javet.exceptions.JavetException; import com.caoccao.javet.interfaces.IJavetMappable; import com.caoccao.javet.utils.JavetDateTimeUtils; +import com.caoccao.javet.utils.SimpleList; +import com.caoccao.javet.utils.SimpleSet; import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.reference.*; import org.junit.jupiter.api.Test; import java.time.ZonedDateTime; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; @@ -90,7 +95,7 @@ public void testArray() throws JavetException { } // ArrayList try (V8ValueArray v8ValueArray = converter.toV8Value( - v8Runtime, Arrays.asList("abc", 123))) { + v8Runtime, SimpleList.of("abc", 123))) { assertEquals(2, v8ValueArray.getLength()); assertEquals("abc", v8ValueArray.getString(0)); assertEquals(123, v8ValueArray.getInteger(1)); @@ -187,19 +192,6 @@ v8Runtime, new JavetEntityMap() {{ assertEquals(1, v8ValueMap.getSize()); assertEquals("abc", v8ValueMap.getString("x")); } - converter.getConfig().setProxyMapEnabled(true); - Map map = new HashMap() {{ - put("x", "abc"); - }}; - try (V8ValueProxy v8ValueProxy = converter.toV8Value(v8Runtime, map)) { - v8Runtime.getGlobalObject().set("a", v8ValueProxy); - assertEquals(map, v8Runtime.getGlobalObject().getObject("a")); - } - assertEquals("abc", v8Runtime.getExecutor("a['x']").executeString()); - assertEquals("abc", v8Runtime.getExecutor("a.x").executeString()); - assertEquals(1, v8Runtime.getExecutor("a['y'] = 1; a['y'];").executeInteger()); - assertEquals(1, map.get("y")); - v8Runtime.getGlobalObject().delete("a"); v8Runtime.lowMemoryNotification(); } @@ -237,8 +229,7 @@ public void testSet() throws JavetException { assertEquals(1, set.size()); assertTrue(set.contains("abc")); } - try (V8ValueSet v8ValueSet = converter.toV8Value( - v8Runtime, new HashSet(Arrays.asList("a", "b", "c")))) { + try (V8ValueSet v8ValueSet = converter.toV8Value(v8Runtime, SimpleSet.of("a", "b", "c"))) { assertEquals(3, v8ValueSet.getSize()); assertTrue(v8ValueSet.has("a")); assertTrue(v8ValueSet.has("b")); diff --git a/src/test/java/com/caoccao/javet/interop/converters/TestJavetPrimitiveConverter.java b/src/test/java/com/caoccao/javet/interop/converters/TestJavetPrimitiveConverter.java index 72cf33422..9c965484e 100644 --- a/src/test/java/com/caoccao/javet/interop/converters/TestJavetPrimitiveConverter.java +++ b/src/test/java/com/caoccao/javet/interop/converters/TestJavetPrimitiveConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/converters/TestJavetProxyConverter.java b/src/test/java/com/caoccao/javet/interop/converters/TestJavetProxyConverter.java index f13241dd1..2b97ce384 100644 --- a/src/test/java/com/caoccao/javet/interop/converters/TestJavetProxyConverter.java +++ b/src/test/java/com/caoccao/javet/interop/converters/TestJavetProxyConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,9 @@ import com.caoccao.javet.mock.MockDirectProxyFunctionHandler; import com.caoccao.javet.mock.MockDirectProxyObjectHandler; import com.caoccao.javet.utils.JavetDateTimeUtils; +import com.caoccao.javet.utils.SimpleList; +import com.caoccao.javet.utils.SimpleMap; +import com.caoccao.javet.utils.SimpleSet; import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.primitive.V8ValueInteger; import com.caoccao.javet.values.primitive.V8ValueString; @@ -51,7 +54,10 @@ import java.nio.file.Path; import java.text.MessageFormat; import java.time.ZonedDateTime; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.regex.Pattern; import static org.junit.jupiter.api.Assertions.*; @@ -99,13 +105,6 @@ public void expectListOfStrings(List list) { assertEquals(2, list.size()); assertEquals("a", list.get(0)); assertNull(list.get(1)); - if (list instanceof AutoCloseable) { - try { - ((AutoCloseable) list).close(); - } catch (Exception e) { - fail(e.getMessage()); - } - } } public void expectLong(Long value1, long value2) { @@ -566,6 +565,83 @@ public void testInterface() throws JavetException { v8Runtime.getGlobalObject().delete("IJavetClosable"); } + @Test + public void testList() throws JavetException { + try { + javetProxyConverter.getConfig().setProxyListEnabled(true); + List list = SimpleList.of("x", "y"); + v8Runtime.getGlobalObject().set("list", list); + assertSame(list, v8Runtime.getGlobalObject().getObject("list")); + // contains() + assertTrue(v8Runtime.getExecutor("list.contains('x')").executeBoolean()); + assertTrue(v8Runtime.getExecutor("list.contains('y')").executeBoolean()); + assertFalse(v8Runtime.getExecutor("list.contains('z')").executeBoolean()); + // includes() + assertTrue(v8Runtime.getExecutor("list.includes('x')").executeBoolean()); + assertFalse(v8Runtime.getExecutor("list.includes('x', 1)").executeBoolean()); + assertTrue(v8Runtime.getExecutor("list.includes('y', 1)").executeBoolean()); + // push() + assertEquals(4, v8Runtime.getExecutor("list.push('z', '1')").executeInteger()); + assertTrue(v8Runtime.getExecutor("list.includes('z')").executeBoolean()); + // pop() + assertEquals("1", v8Runtime.getExecutor("list.pop()").executeString()); + // toJSON() + assertEquals( + "[\"x\",\"y\",\"z\"]", + v8Runtime.getExecutor("JSON.stringify(list)").executeString()); + // Symbol.iterator + assertEquals( + "[\"x\",\"y\",\"z\"]", + v8Runtime.getExecutor("JSON.stringify([...list])").executeString()); + // with() + assertEquals( + "[\"1\",\"y\",\"z\"]", + v8Runtime.getExecutor("JSON.stringify(list.with(0, '1'))").executeString()); + // toString() + assertEquals("[x, y, z]", v8Runtime.getExecutor("list.toString()").executeString()); + // values() + assertEquals("x", v8Runtime.getExecutor("list.values().next().value").executeString()); + // keys() + assertEquals("0,1,2", v8Runtime.getExecutor("[...list.keys()].toString()").executeString()); + // reverse() + assertEquals("[z, y, x]", v8Runtime.getExecutor("list.reverse().toString()").executeString()); + assertEquals("[x, y, z]", v8Runtime.getExecutor("list.reverse().toString()").executeString()); + // toReversed() + assertEquals("z,y,x", v8Runtime.getExecutor("list.toReversed().toString()").executeString()); + assertEquals("[x, y, z]", v8Runtime.getExecutor("list.toString()").executeString()); + // map() + assertEquals("x0,y1,z2", v8Runtime.getExecutor("list.map((x, i) => x+i).toString()").executeString()); + // every() + assertFalse(v8Runtime.getExecutor("list.every((x, i) => x == 'x' && i == 0)").executeBoolean()); + assertTrue(v8Runtime.getExecutor("list.every((x, i) => x >= 'x' && i >= 0)").executeBoolean()); + // some() + assertTrue(v8Runtime.getExecutor("list.some((x, i) => x == 'x' && i == 0)").executeBoolean()); + assertFalse(v8Runtime.getExecutor("list.some((x, i) => x < 'x' && i < 0)").executeBoolean()); + // at() + assertEquals("x", v8Runtime.getExecutor("list.at(0)").executeString()); + assertEquals("y", v8Runtime.getExecutor("list.at(1)").executeString()); + assertEquals("z", v8Runtime.getExecutor("list.at(-1)").executeString()); + assertEquals("x", v8Runtime.getExecutor("list.at(-3)").executeString()); + assertTrue(v8Runtime.getExecutor("list.at(3)").execute().isUndefined()); + assertTrue(v8Runtime.getExecutor("list.at(-4)").execute().isUndefined()); + // unshift() + assertEquals(5, v8Runtime.getExecutor("list.unshift('1', '2')").executeInteger()); + // [] + assertEquals("3", v8Runtime.getExecutor("list[0] = '3'; list[0]").executeString()); + // shift() + assertEquals("3", v8Runtime.getExecutor("list.shift()").executeString()); + assertEquals("2", v8Runtime.getExecutor("list.shift()").executeString()); + // delete() + assertTrue(v8Runtime.getExecutor("delete list[2]").executeBoolean()); + assertEquals(2, v8Runtime.getExecutor("list.size()").executeInteger()); + // length + assertEquals(2, v8Runtime.getExecutor("list.length").executeInteger()); + v8Runtime.getGlobalObject().delete("list"); + } finally { + javetProxyConverter.getConfig().setProxyListEnabled(false); + } + } + @Test public void testListOfStrings() throws JavetException { v8Runtime.getGlobalObject().set("a", anonymous); @@ -577,6 +653,10 @@ public void testListOfStrings() throws JavetException { String codeStringWithoutCast = "a.expectListOfStrings(['a', null]);"; v8Runtime.getExecutor(codeStringWithoutCast).executeVoid(); v8Runtime.getGlobalObject().delete("a"); + System.gc(); + System.runFinalization(); + System.gc(); + System.runFinalization(); } @Test @@ -593,10 +673,7 @@ public void testLong() throws JavetException { public void testMap() throws JavetException { try { javetProxyConverter.getConfig().setProxyMapEnabled(true); - Map map = new HashMap() {{ - put("x", 1); - put("y", "2"); - }}; + Map map = SimpleMap.of("x", 1, "y", "2"); v8Runtime.getGlobalObject().set("map", map); assertSame(map, v8Runtime.getGlobalObject().getObject("map")); assertTrue(v8Runtime.getExecutor("map.containsKey('x')").executeBoolean()); @@ -611,6 +688,13 @@ public void testMap() throws JavetException { assertEquals( "[\"x\",\"y\",\"z\"]", v8Runtime.getExecutor("JSON.stringify(Object.getOwnPropertyNames(map));").executeString()); + assertTrue(v8Runtime.getExecutor("delete map['x']").executeBoolean()); + assertFalse(map.containsKey("x")); + assertTrue(v8Runtime.getExecutor("delete map['y']").executeBoolean()); + assertFalse(map.containsKey("y")); + assertEquals( + "{\"z\":\"z\"}", + v8Runtime.getExecutor("JSON.stringify(map);").executeString()); v8Runtime.getGlobalObject().delete("map"); } finally { javetProxyConverter.getConfig().setProxyMapEnabled(false); @@ -727,20 +811,28 @@ public void setV8Runtime(V8Runtime v8Runtime) { public void testSet() throws JavetException { try { javetProxyConverter.getConfig().setProxySetEnabled(true); - Set set = new HashSet() {{ - add("x"); - add("y"); - }}; + Set set = SimpleSet.of("x", "y"); v8Runtime.getGlobalObject().set("set", set); assertSame(set, v8Runtime.getGlobalObject().getObject("set")); assertTrue(v8Runtime.getExecutor("set.contains('x')").executeBoolean()); assertTrue(v8Runtime.getExecutor("set.contains('y')").executeBoolean()); assertFalse(v8Runtime.getExecutor("set.contains('z')").executeBoolean()); + assertFalse(v8Runtime.getExecutor("set.has('z')").executeBoolean()); assertTrue(v8Runtime.getExecutor("set.add('z')").executeBoolean()); assertTrue(v8Runtime.getExecutor("set.contains('z')").executeBoolean()); + assertTrue(v8Runtime.getExecutor("set.has('z')").executeBoolean()); + assertEquals( + "{}", + v8Runtime.getExecutor("JSON.stringify(set);").executeString()); assertEquals( "[\"x\",\"y\",\"z\"]", v8Runtime.getExecutor("JSON.stringify(Object.getOwnPropertyNames(set));").executeString()); + assertEquals( + "[\"x\",\"y\",\"z\"]", + v8Runtime.getExecutor("const keys = []; for (let key of set.keys()) { keys.push(key); } JSON.stringify(keys);").executeString()); + assertTrue(v8Runtime.getExecutor("set.delete('z')").executeBoolean()); + assertFalse(v8Runtime.getExecutor("set.delete('z')").executeBoolean()); + assertFalse(v8Runtime.getExecutor("set.has('z')").executeBoolean()); v8Runtime.getGlobalObject().delete("set"); } finally { javetProxyConverter.getConfig().setProxySetEnabled(false); diff --git a/src/test/java/com/caoccao/javet/interop/engine/TestJavetEngineGuard.java b/src/test/java/com/caoccao/javet/interop/engine/TestJavetEngineGuard.java index 6dacc6ecc..decf15a45 100644 --- a/src/test/java/com/caoccao/javet/interop/engine/TestJavetEngineGuard.java +++ b/src/test/java/com/caoccao/javet/interop/engine/TestJavetEngineGuard.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/engine/TestJavetEnginePerformance.java b/src/test/java/com/caoccao/javet/interop/engine/TestJavetEnginePerformance.java index d918b82d3..687c354c1 100644 --- a/src/test/java/com/caoccao/javet/interop/engine/TestJavetEnginePerformance.java +++ b/src/test/java/com/caoccao/javet/interop/engine/TestJavetEnginePerformance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.caoccao.javet.interop.V8Runtime; import com.caoccao.javet.interop.executors.IV8Executor; import com.caoccao.javet.utils.JavetOSUtils; +import com.caoccao.javet.utils.StringUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -220,7 +221,7 @@ protected void updateDoc(String prefix, long tps) throws IOException { DecimalFormat decimalFormat = new DecimalFormat("#,###"); File docFile = new File( JavetOSUtils.WORKING_DIRECTORY, - "docs/reference/resource_management/performance.rst"); + "docs/development/performance.rst"); List lines = new ArrayList<>(); for (String line : Files.readAllLines(docFile.toPath(), StandardCharsets.UTF_8)) { if (line.startsWith(prefix)) { @@ -228,7 +229,7 @@ protected void updateDoc(String prefix, long tps) throws IOException { } lines.add(line); } - lines.add(""); + lines.add(StringUtils.EMPTY); try (FileWriter fileWriter = new FileWriter(docFile, false)) { fileWriter.write(String.join("\n", lines)); } diff --git a/src/test/java/com/caoccao/javet/interop/engine/TestJavetEnginePool.java b/src/test/java/com/caoccao/javet/interop/engine/TestJavetEnginePool.java index 3da334c51..72aa5bb6e 100644 --- a/src/test/java/com/caoccao/javet/interop/engine/TestJavetEnginePool.java +++ b/src/test/java/com/caoccao/javet/interop/engine/TestJavetEnginePool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/loader/TestJavetLibLoadingListener.java b/src/test/java/com/caoccao/javet/interop/loader/TestJavetLibLoadingListener.java index 421551fdd..d85b037b0 100644 --- a/src/test/java/com/caoccao/javet/interop/loader/TestJavetLibLoadingListener.java +++ b/src/test/java/com/caoccao/javet/interop/loader/TestJavetLibLoadingListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/monitoring/TestV8HeapSpaceStatistics.java b/src/test/java/com/caoccao/javet/interop/monitoring/TestV8HeapSpaceStatistics.java index 0d0c9d863..ae11f36cb 100644 --- a/src/test/java/com/caoccao/javet/interop/monitoring/TestV8HeapSpaceStatistics.java +++ b/src/test/java/com/caoccao/javet/interop/monitoring/TestV8HeapSpaceStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/monitoring/TestV8HeapStatistics.java b/src/test/java/com/caoccao/javet/interop/monitoring/TestV8HeapStatistics.java index dc0571018..5f9212678 100644 --- a/src/test/java/com/caoccao/javet/interop/monitoring/TestV8HeapStatistics.java +++ b/src/test/java/com/caoccao/javet/interop/monitoring/TestV8HeapStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/monitoring/TestV8SharedMemoryStatistics.java b/src/test/java/com/caoccao/javet/interop/monitoring/TestV8SharedMemoryStatistics.java index b263236d1..85453a044 100644 --- a/src/test/java/com/caoccao/javet/interop/monitoring/TestV8SharedMemoryStatistics.java +++ b/src/test/java/com/caoccao/javet/interop/monitoring/TestV8SharedMemoryStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/options/TestV8Flags.java b/src/test/java/com/caoccao/javet/interop/options/TestV8Flags.java index af4975749..4f2e0c27f 100644 --- a/src/test/java/com/caoccao/javet/interop/options/TestV8Flags.java +++ b/src/test/java/com/caoccao/javet/interop/options/TestV8Flags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/interop/proxy/JavetReflectionObjectFactory.java b/src/test/java/com/caoccao/javet/interop/proxy/JavetReflectionObjectFactory.java index cf0dc5423..a49313435 100644 --- a/src/test/java/com/caoccao/javet/interop/proxy/JavetReflectionObjectFactory.java +++ b/src/test/java/com/caoccao/javet/interop/proxy/JavetReflectionObjectFactory.java @@ -145,6 +145,11 @@ public void close() throws Exception { v8ValueObject = null; } + @Override + protected void finalize() throws Throwable { + close(); + } + /** * Gets dynamic object. * diff --git a/src/test/java/com/caoccao/javet/mock/MockAnnotationBasedCallbackReceiver.java b/src/test/java/com/caoccao/javet/mock/MockAnnotationBasedCallbackReceiver.java index b4ba8bc03..7c90a2d2c 100644 --- a/src/test/java/com/caoccao/javet/mock/MockAnnotationBasedCallbackReceiver.java +++ b/src/test/java/com/caoccao/javet/mock/MockAnnotationBasedCallbackReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/mock/MockCallbackReceiver.java b/src/test/java/com/caoccao/javet/mock/MockCallbackReceiver.java index 769bfa503..7843b3366 100644 --- a/src/test/java/com/caoccao/javet/mock/MockCallbackReceiver.java +++ b/src/test/java/com/caoccao/javet/mock/MockCallbackReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/mock/MockDirectProxyFunctionHandler.java b/src/test/java/com/caoccao/javet/mock/MockDirectProxyFunctionHandler.java index d8247bc55..2228a89dc 100644 --- a/src/test/java/com/caoccao/javet/mock/MockDirectProxyFunctionHandler.java +++ b/src/test/java/com/caoccao/javet/mock/MockDirectProxyFunctionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/mock/MockDirectProxyObjectHandler.java b/src/test/java/com/caoccao/javet/mock/MockDirectProxyObjectHandler.java index b84d72d12..806fb539f 100644 --- a/src/test/java/com/caoccao/javet/mock/MockDirectProxyObjectHandler.java +++ b/src/test/java/com/caoccao/javet/mock/MockDirectProxyObjectHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/mock/MockFS.java b/src/test/java/com/caoccao/javet/mock/MockFS.java index e64e50876..076fef7ca 100644 --- a/src/test/java/com/caoccao/javet/mock/MockFS.java +++ b/src/test/java/com/caoccao/javet/mock/MockFS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/mock/MockModuleResolver.java b/src/test/java/com/caoccao/javet/mock/MockModuleResolver.java index 28493ed7a..64427a404 100644 --- a/src/test/java/com/caoccao/javet/mock/MockModuleResolver.java +++ b/src/test/java/com/caoccao/javet/mock/MockModuleResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/mock/MockPojo.java b/src/test/java/com/caoccao/javet/mock/MockPojo.java index f580004af..23da2dbec 100644 --- a/src/test/java/com/caoccao/javet/mock/MockPojo.java +++ b/src/test/java/com/caoccao/javet/mock/MockPojo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/mock/MockPojoWithGenericGetterAndSetter.java b/src/test/java/com/caoccao/javet/mock/MockPojoWithGenericGetterAndSetter.java index 7413d3f71..9de8d0947 100644 --- a/src/test/java/com/caoccao/javet/mock/MockPojoWithGenericGetterAndSetter.java +++ b/src/test/java/com/caoccao/javet/mock/MockPojoWithGenericGetterAndSetter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/DecimalJavetInNodeJSMode.java b/src/test/java/com/caoccao/javet/tutorial/DecimalJavetInNodeJSMode.java index de8862e06..2fe84adff 100644 --- a/src/test/java/com/caoccao/javet/tutorial/DecimalJavetInNodeJSMode.java +++ b/src/test/java/com/caoccao/javet/tutorial/DecimalJavetInNodeJSMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/DecimalJavetInV8Mode.java b/src/test/java/com/caoccao/javet/tutorial/DecimalJavetInV8Mode.java index f242a1ae8..63e84cafc 100644 --- a/src/test/java/com/caoccao/javet/tutorial/DecimalJavetInV8Mode.java +++ b/src/test/java/com/caoccao/javet/tutorial/DecimalJavetInV8Mode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/HelloJavet.java b/src/test/java/com/caoccao/javet/tutorial/HelloJavet.java index 1617905c4..2d8dae1af 100644 --- a/src/test/java/com/caoccao/javet/tutorial/HelloJavet.java +++ b/src/test/java/com/caoccao/javet/tutorial/HelloJavet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/TestAccessTheWholeJVM.java b/src/test/java/com/caoccao/javet/tutorial/TestAccessTheWholeJVM.java new file mode 100644 index 000000000..ee74cfbd4 --- /dev/null +++ b/src/test/java/com/caoccao/javet/tutorial/TestAccessTheWholeJVM.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2021-2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.tutorial; + +import com.caoccao.javet.annotations.V8Function; +import com.caoccao.javet.exceptions.JavetException; +import com.caoccao.javet.interception.jvm.JavetJVMInterceptor; +import com.caoccao.javet.interfaces.IJavetAnonymous; +import com.caoccao.javet.interop.V8Host; +import com.caoccao.javet.interop.V8Runtime; +import com.caoccao.javet.interop.converters.JavetProxyConverter; +import com.caoccao.javet.interop.proxy.JavetReflectionObjectFactory; + +public class TestAccessTheWholeJVM { + + public static void main(String[] args) throws JavetException, InterruptedException { + // Step 1: Create a V8 runtime from V8 host in try-with-resource. + try (V8Runtime v8Runtime = V8Host.getV8Instance().createV8Runtime()) { + // Step 2: Create a proxy converter. + JavetProxyConverter javetProxyConverter = new JavetProxyConverter(); + // Step 3: Enable the dynamic object capability. (Optional) + javetProxyConverter.getConfig().setReflectionObjectFactory(JavetReflectionObjectFactory.getInstance()); + // Step 4: Set the proxy converter to the V8 runtime. + v8Runtime.setConverter(javetProxyConverter); + // Step 5: Create and register the JVM interceptor. + JavetJVMInterceptor javetJVMInterceptor = new JavetJVMInterceptor(v8Runtime); + javetJVMInterceptor.register(v8Runtime.getGlobalObject()); + // Step 6: Create package 'java'. + v8Runtime.getExecutor("let java = javet.package.java").executeVoid(); + + // Play with StringBuilder. + System.out.println(v8Runtime.getExecutor("let sb = new java.lang.StringBuilder();" + + "sb.append('abc').append(123);" + + "sb.toString();").executeString()); + // Output: abc123 + System.out.println(v8Runtime.getExecutor("java.lang['.name']").executeString()); + // Output: java.lang + System.out.println(v8Runtime.getExecutor("java.lang.StringBuilder['.name']").executeString()); + // Output: java.lang.StringBuilder + System.out.println(v8Runtime.getExecutor("java.io['.valid']").executeBoolean()); + // Output: true + System.out.println(v8Runtime.getExecutor("java.abc['.valid']").executeBoolean()); + // Output: false + System.out.println(v8Runtime.getExecutor("javet.package.javax.annotation['.name']").executeString()); + // Output: javax.annotation + + // Play with dynamic interface. + Thread thread = v8Runtime.getExecutor( + "let count = 0;" + + "let thread = new java.lang.Thread(() => { count++; });" + + "thread.start();" + + "thread; " + ).executeObject(); + thread.join(); + System.out.println(v8Runtime.getExecutor("count").executeInteger()); + // Output: 1 + + // Play with dynamic object. (Optional) + IJavetAnonymous anonymous = new IJavetAnonymous() { + @V8Function + public void test(DynamicClass dynamicClass) { + System.out.println(dynamicClass.add(1, 2)); + } + }; + v8Runtime.getGlobalObject().set("a", anonymous); + v8Runtime.getExecutor("a.test({ add: (a, b) => a + b });").executeVoid(); + v8Runtime.getGlobalObject().delete("a"); + // Output: 3 + + // Step 7: Dispose everything. + v8Runtime.getExecutor("java = sb = thread = undefined;").executeVoid(); + // Step 8: Unregister the JVM interceptor. + javetJVMInterceptor.unregister(v8Runtime.getGlobalObject()); + // Step 9: Enforce the GC to avoid memory leak. (Optional) + System.gc(); + System.runFinalization(); + System.gc(); + System.runFinalization(); + v8Runtime.lowMemoryNotification(); + } + } + + public static class DynamicClass { + public int add(int a, int b) { + return 0; + } + } +} diff --git a/src/test/java/com/caoccao/javet/tutorial/TestES5.java b/src/test/java/com/caoccao/javet/tutorial/TestES5.java index 41b7f4f4a..e7afab4a8 100644 --- a/src/test/java/com/caoccao/javet/tutorial/TestES5.java +++ b/src/test/java/com/caoccao/javet/tutorial/TestES5.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/TestES6.java b/src/test/java/com/caoccao/javet/tutorial/TestES6.java index 1f5db5733..387e01c2b 100644 --- a/src/test/java/com/caoccao/javet/tutorial/TestES6.java +++ b/src/test/java/com/caoccao/javet/tutorial/TestES6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/TestInterception.java b/src/test/java/com/caoccao/javet/tutorial/TestInterception.java index 0abe54eeb..13776340e 100644 --- a/src/test/java/com/caoccao/javet/tutorial/TestInterception.java +++ b/src/test/java/com/caoccao/javet/tutorial/TestInterception.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/TestJavaAndJSInterop.java b/src/test/java/com/caoccao/javet/tutorial/TestJavaAndJSInterop.java index ee7b398f6..4219093d0 100644 --- a/src/test/java/com/caoccao/javet/tutorial/TestJavaAndJSInterop.java +++ b/src/test/java/com/caoccao/javet/tutorial/TestJavaAndJSInterop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/TestJsonNodeInV8.java b/src/test/java/com/caoccao/javet/tutorial/TestJsonNodeInV8.java index f8029414c..671d3ea95 100644 --- a/src/test/java/com/caoccao/javet/tutorial/TestJsonNodeInV8.java +++ b/src/test/java/com/caoccao/javet/tutorial/TestJsonNodeInV8.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023. caoccao.com Sam Cao + * Copyright (c) 2023-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/TestModuleResolver.java b/src/test/java/com/caoccao/javet/tutorial/TestModuleResolver.java index 1e846620c..d5ae6f2d9 100644 --- a/src/test/java/com/caoccao/javet/tutorial/TestModuleResolver.java +++ b/src/test/java/com/caoccao/javet/tutorial/TestModuleResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/TestObjectConverter.java b/src/test/java/com/caoccao/javet/tutorial/TestObjectConverter.java index f42557526..076caa000 100644 --- a/src/test/java/com/caoccao/javet/tutorial/TestObjectConverter.java +++ b/src/test/java/com/caoccao/javet/tutorial/TestObjectConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/tutorial/cdt/CDTConfig.java b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTConfig.java index 2dae20bca..393171a8a 100644 --- a/src/test/java/com/caoccao/javet/tutorial/cdt/CDTConfig.java +++ b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,40 +16,24 @@ package com.caoccao.javet.tutorial.cdt; -import com.caoccao.javet.interop.V8Runtime; - public final class CDTConfig { public static final String COMMAND_EXIT = ".exit"; public static final String PATH_ROOT = "/"; public static final String PATH_JSON = "/json"; + public static final String PATH_JSON_LIST = "/json/list"; public static final String PATH_JSON_VERSION = "/json/version"; public static final String PATH_JAVET = "/javet"; - private static int port = 0; - private static V8Runtime v8Runtime = null; - private static String webSocketUrl = null; - - static { - setPort(9229); - } + private static int port = 9229; public static int getPort() { return port; } - public static V8Runtime getV8Runtime() { - return v8Runtime; - } - public static String getWebSocketUrl() { - return webSocketUrl; + return "localhost:" + port + PATH_JAVET; } public static void setPort(int port) { CDTConfig.port = port; - webSocketUrl = "ws://127.0.0.1:" + Integer.toString(port) + PATH_JAVET; - } - - public static void setV8Runtime(V8Runtime v8Runtime) { - CDTConfig.v8Runtime = v8Runtime; } } diff --git a/src/test/java/com/caoccao/javet/tutorial/cdt/CDTHttpServlet.java b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTHttpServlet.java index dd88e312c..18d4fd5d5 100644 --- a/src/test/java/com/caoccao/javet/tutorial/cdt/CDTHttpServlet.java +++ b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTHttpServlet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,16 +39,16 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) String requestURI = request.getRequestURI(); response.setContentType(APPLICATION_JSON_CHARSET_UTF_8); response.setStatus(HttpServletResponse.SC_OK); - if (CDTConfig.PATH_JSON.equals(requestURI)) { + if (CDTConfig.PATH_JSON.equals(requestURI) || CDTConfig.PATH_JSON_LIST.equals(requestURI)) { response.getWriter().println("[ {\n" + " \"description\": \"javet\",\n" + - " \"devtoolsFrontendUrl\": \"devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&" + CDTConfig.getWebSocketUrl() + "\",\n" + - " \"devtoolsFrontendUrlCompat\": \"devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&" + CDTConfig.getWebSocketUrl() + "\",\n" + + " \"devtoolsFrontendUrl\": \"devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=" + CDTConfig.getWebSocketUrl() + "\",\n" + + " \"devtoolsFrontendUrlCompat\": \"devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=" + CDTConfig.getWebSocketUrl() + "\",\n" + " \"id\": \"javet\",\n" + " \"title\": \"javet\",\n" + " \"type\": \"node\",\n" + // Type must be node " \"url\": \"file://\",\n" + - " \"webSocketDebuggerUrl\": \"" + CDTConfig.getWebSocketUrl() + "\"\n" + + " \"webSocketDebuggerUrl\": \"ws://" + CDTConfig.getWebSocketUrl() + "\"\n" + "} ]\n"); } else if (CDTConfig.PATH_JSON_VERSION.equals(requestURI)) { response.getWriter().println("{\n" + diff --git a/src/test/java/com/caoccao/javet/tutorial/cdt/CDTShell.java b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTShell.java index a34f0e16c..226a581cc 100644 --- a/src/test/java/com/caoccao/javet/tutorial/cdt/CDTShell.java +++ b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTShell.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,52 +36,48 @@ public CDTShell() { } public void run() { - Server jsonServer = new Server(CDTConfig.getPort()); - ServletContextHandler jsonServletContextHandler = new ServletContextHandler( + Server inspectorServer = new Server(CDTConfig.getPort()); + ServletContextHandler inspectorServletContextHandler = new ServletContextHandler( ServletContextHandler.SESSIONS | ServletContextHandler.NO_SECURITY); - jsonServletContextHandler.setContextPath(CDTConfig.PATH_ROOT); - jsonServer.setHandler(jsonServletContextHandler); - try { - jsonServletContextHandler.addServlet(CDTHttpServlet.class, CDTConfig.PATH_JSON); - jsonServletContextHandler.addServlet(CDTHttpServlet.class, CDTConfig.PATH_JSON_VERSION); - NativeWebSocketServletContainerInitializer.configure(jsonServletContextHandler, + inspectorServletContextHandler.setContextPath(CDTConfig.PATH_ROOT); + inspectorServer.setHandler(inspectorServletContextHandler); + try (V8Runtime v8Runtime = V8Host.getV8Instance().createV8Runtime()) { + inspectorServletContextHandler.addServlet(CDTHttpServlet.class, CDTConfig.PATH_ROOT); + NativeWebSocketServletContainerInitializer.configure(inspectorServletContextHandler, (servletContext, nativeWebSocketConfiguration) -> { nativeWebSocketConfiguration.getPolicy().setMaxTextMessageBufferSize(0xFFFFFF); - nativeWebSocketConfiguration.addMapping(CDTConfig.PATH_JAVET, CDTWebSocketAdapter.class); + nativeWebSocketConfiguration.addMapping( + CDTConfig.PATH_JAVET, + new CDTWebSocketCreator(v8Runtime)); }); - WebSocketUpgradeFilter.configure(jsonServletContextHandler); - try (V8Runtime v8Runtime = V8Host.getV8Instance().createV8Runtime()) { - jsonServer.start(); - logger.logInfo("Server is started. Please press any key to stop the server."); - System.out.println("Welcome to CDT Shell!"); - System.out.println("Input the script or '" + CDTConfig.COMMAND_EXIT + "' to exit."); - CDTConfig.setV8Runtime(v8Runtime); - try (Scanner scanner = new Scanner(System.in)) { - while (true) { - System.out.print("> "); - String command = scanner.nextLine(); - if (CDTConfig.COMMAND_EXIT.equals(command)) { - break; - } - try (V8Value v8Value = v8Runtime.getExecutor(command).execute()) { - if (v8Value != null) { - System.out.println(v8Value.toString()); - } - } catch (Throwable t) { - System.err.println(t.getMessage()); + WebSocketUpgradeFilter.configure(inspectorServletContextHandler); + inspectorServer.start(); + logger.logInfo("Server is started. Please press any key to stop the server."); + System.out.println("Welcome to CDT Shell!"); + System.out.println("Input the script or '" + CDTConfig.COMMAND_EXIT + "' to exit."); + try (Scanner scanner = new Scanner(System.in)) { + while (true) { + System.out.print("> "); + String command = scanner.nextLine(); + if (CDTConfig.COMMAND_EXIT.equals(command)) { + break; + } + try (V8Value v8Value = v8Runtime.getExecutor(command).execute()) { + if (v8Value != null) { + System.out.println(v8Value); } + } catch (Throwable t) { + System.err.println(t.getMessage()); } } - } finally { - CDTConfig.setV8Runtime(null); } } catch (Throwable t) { logger.logError(t, t.getMessage()); } finally { - if (jsonServer.isStarted() || jsonServer.isStarting()) { + if (inspectorServer.isStarted() || inspectorServer.isStarting()) { logger.logInfo("Server is being stopped."); try { - jsonServer.stop(); + inspectorServer.stop(); } catch (Throwable t) { logger.logError(t, t.getMessage()); } diff --git a/src/test/java/com/caoccao/javet/tutorial/cdt/CDTWebSocketAdapter.java b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTWebSocketAdapter.java index 61c73b90a..b6feefb15 100644 --- a/src/test/java/com/caoccao/javet/tutorial/cdt/CDTWebSocketAdapter.java +++ b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTWebSocketAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,36 +18,41 @@ import com.caoccao.javet.interfaces.IJavetLogger; import com.caoccao.javet.interop.IV8InspectorListener; +import com.caoccao.javet.interop.V8Runtime; import com.caoccao.javet.utils.JavetDefaultLogger; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; public class CDTWebSocketAdapter extends WebSocketAdapter implements IV8InspectorListener { protected IJavetLogger logger; - protected Session session; + protected V8Runtime v8Runtime; - public CDTWebSocketAdapter() { + public CDTWebSocketAdapter(V8Runtime v8Runtime) { this.logger = new JavetDefaultLogger(getClass().getName()); + this.v8Runtime = v8Runtime; logger.logInfo("CDTWebSocketAdapter()"); - session = null; } @Override public void flushProtocolNotifications() { } + public V8Runtime getV8Runtime() { + return v8Runtime; + } + @Override public void onWebSocketClose(int statusCode, String reason) { logger.logInfo("onWebSocketClose(): {0} {1}", Integer.toString(statusCode), reason); - session = null; - CDTConfig.getV8Runtime().getV8Inspector().removeListeners(this); + v8Runtime.getV8Inspector().removeListeners(this); + super.onWebSocketClose(statusCode, reason); } @Override public void onWebSocketConnect(Session session) { + super.onWebSocketConnect(session); logger.logInfo("onWebSocketConnect(): {0}", session.getRemoteAddress().toString()); - this.session = session; - CDTConfig.getV8Runtime().getV8Inspector().addListeners(this); + v8Runtime.getV8Inspector().addListeners(this); } @Override @@ -59,7 +64,7 @@ public void onWebSocketError(Throwable cause) { public void onWebSocketText(String message) { logger.logInfo("onWebSocketText(): {0}", message); try { - CDTConfig.getV8Runtime().getV8Inspector().sendRequest(message); + v8Runtime.getV8Inspector().sendRequest(message); } catch (Exception e) { logger.logError(e, e.getMessage()); } @@ -69,7 +74,7 @@ public void onWebSocketText(String message) { public void receiveNotification(String message) { logger.logInfo("receiveNotification(): {0}", message); try { - session.getRemote().sendString(message); + getRemote().sendString(message); } catch (Exception e) { logger.logError(e, e.getMessage()); } @@ -79,7 +84,7 @@ public void receiveNotification(String message) { public void receiveResponse(String message) { logger.logInfo("receiveResponse(): {0}", message); try { - session.getRemote().sendString(message); + getRemote().sendString(message); } catch (Exception e) { logger.logError(e, e.getMessage()); } @@ -88,7 +93,7 @@ public void receiveResponse(String message) { @Override public void runIfWaitingForDebugger(int contextGroupId) { try { - CDTConfig.getV8Runtime().getExecutor( + v8Runtime.getExecutor( "console.log('Welcome to Javet Debugging Environment!');").executeVoid(); } catch (Exception e) { logger.logError(e, e.getMessage()); diff --git a/src/test/java/com/caoccao/javet/tutorial/cdt/CDTWebSocketCreator.java b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTWebSocketCreator.java new file mode 100644 index 000000000..161105822 --- /dev/null +++ b/src/test/java/com/caoccao/javet/tutorial/cdt/CDTWebSocketCreator.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023-2024. caoccao.com Sam Cao + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.caoccao.javet.tutorial.cdt; + +import com.caoccao.javet.interop.V8Runtime; +import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; +import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse; +import org.eclipse.jetty.websocket.servlet.WebSocketCreator; + +public class CDTWebSocketCreator implements WebSocketCreator { + protected V8Runtime v8Runtime; + + public CDTWebSocketCreator(V8Runtime v8Runtime) { + this.v8Runtime = v8Runtime; + } + + @Override + public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { + return new CDTWebSocketAdapter(v8Runtime); + } +} diff --git a/src/test/java/com/caoccao/javet/tutorial/cdt/TestCDT.java b/src/test/java/com/caoccao/javet/tutorial/cdt/TestCDT.java index 864636056..3d17f07ce 100644 --- a/src/test/java/com/caoccao/javet/tutorial/cdt/TestCDT.java +++ b/src/test/java/com/caoccao/javet/tutorial/cdt/TestCDT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/utils/TestJavetDateTimeUtils.java b/src/test/java/com/caoccao/javet/utils/TestJavetDateTimeUtils.java index 645b5770f..222101aa8 100644 --- a/src/test/java/com/caoccao/javet/utils/TestJavetDateTimeUtils.java +++ b/src/test/java/com/caoccao/javet/utils/TestJavetDateTimeUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/utils/TestSimpleFreeMarkerFormat.java b/src/test/java/com/caoccao/javet/utils/TestSimpleFreeMarkerFormat.java index fd227c385..34ac4e5fe 100644 --- a/src/test/java/com/caoccao/javet/utils/TestSimpleFreeMarkerFormat.java +++ b/src/test/java/com/caoccao/javet/utils/TestSimpleFreeMarkerFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueBigInteger.java b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueBigInteger.java index 65a531025..4628a8c38 100644 --- a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueBigInteger.java +++ b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueBigInteger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueBoolean.java b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueBoolean.java index 0b30e52d3..5c7b86674 100644 --- a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueBoolean.java +++ b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueDouble.java b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueDouble.java index 27044a707..11613e7ce 100644 --- a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueDouble.java +++ b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueInteger.java b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueInteger.java index cb021777c..3e7bdcbbe 100644 --- a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueInteger.java +++ b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueInteger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueLong.java b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueLong.java index d276eb219..b9457941e 100644 --- a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueLong.java +++ b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueNull.java b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueNull.java index c00c47e9a..ee992fa2d 100644 --- a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueNull.java +++ b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueNull.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueString.java b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueString.java index 65b1c8ded..12e472d0d 100644 --- a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueString.java +++ b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueUndefined.java b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueUndefined.java index 235b87ea2..cee25ad3d 100644 --- a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueUndefined.java +++ b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueUndefined.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import com.caoccao.javet.BaseTestJavetRuntime; import com.caoccao.javet.exceptions.JavetException; +import com.caoccao.javet.utils.StringUtils; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -25,10 +26,10 @@ public class TestV8ValueUndefined extends BaseTestJavetRuntime { @Test public void testEquals() throws JavetException { - V8ValueUndefined v8ValueUndefined = v8Runtime.getExecutor("undefined").execute(); - assertTrue(v8ValueUndefined.equals(v8Runtime.createV8ValueUndefined())); - assertFalse(v8ValueUndefined.equals(null)); - assertFalse(v8ValueUndefined.equals(v8Runtime.createV8ValueNull())); + try (V8ValueUndefined v8ValueUndefined = v8Runtime.getExecutor("undefined").execute()) { + assertTrue(v8ValueUndefined.equals(v8Runtime.createV8ValueUndefined())); + assertFalse(v8ValueUndefined.equals(v8Runtime.createV8ValueNull())); + } } @Test @@ -37,7 +38,7 @@ public void testUndefined() throws JavetException { assertNotNull(v8ValueUndefined); assertEquals(v8Runtime, v8ValueUndefined.getV8Runtime()); } - try (V8ValueUndefined v8ValueUndefined = v8Runtime.getExecutor("").execute()) { + try (V8ValueUndefined v8ValueUndefined = v8Runtime.getExecutor(StringUtils.EMPTY).execute()) { assertNotNull(v8ValueUndefined); assertEquals(v8Runtime, v8ValueUndefined.getV8Runtime()); } diff --git a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueZonedDateTime.java b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueZonedDateTime.java index 4dadad74d..26f0dc9ff 100644 --- a/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueZonedDateTime.java +++ b/src/test/java/com/caoccao/javet/values/primitive/TestV8ValueZonedDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8Module.java b/src/test/java/com/caoccao/javet/values/reference/TestV8Module.java index 6dbd43e45..0534ac7dd 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8Module.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8Module.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -162,8 +162,7 @@ public void testImportValidModuleAndExecute() throws JavetException { assertTrue(v8Module.isSourceTextModule()); assertFalse(v8Module.isSyntheticModule()); if (v8Runtime.getJSRuntimeType().isNode()) { - v8Runtime.getExecutor("const process = require('process');\n" + - "var globalReason = null;\n" + + v8Runtime.getExecutor("var globalReason = null;\n" + "process.on('unhandledRejection', (reason, promise) => {\n" + " globalReason = reason;\n" + "});").executeVoid(); @@ -315,11 +314,9 @@ public void testStatusConversion() throws JavetException { @Test public void testSyntheticModule() throws JavetException { if (v8Runtime.getJSRuntimeType().isNode()) { - v8Runtime.getExecutor( - "const process = require('process');\n" + - "process.on('unhandledRejection', (reason, promise) => {\n" + - " globalThis.reason = reason.toString();\n" + - "});") + v8Runtime.getExecutor("process.on('unhandledRejection', (reason, promise) => {\n" + + " globalThis.reason = reason.toString();\n" + + "});") .executeVoid(); } else { v8Runtime.setPromiseRejectCallback((event, promise, value) -> { diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8Script.java b/src/test/java/com/caoccao/javet/values/reference/TestV8Script.java index 5f64a63c3..9368493f3 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8Script.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8Script.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArguments.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArguments.java index 1f3abd63b..e207e1a31 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArguments.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArguments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArray.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArray.java index feec0a429..c648c0c37 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArray.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.caoccao.javet.BaseTestJavetRuntime; import com.caoccao.javet.exceptions.JavetException; import com.caoccao.javet.utils.JavetResourceUtils; +import com.caoccao.javet.utils.StringUtils; import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.primitive.*; import org.junit.jupiter.api.Tag; @@ -192,7 +193,7 @@ public void testPushPop() throws JavetException { assertEquals(1.23, v8ValueArray.popDouble(), 0.001); assertEquals(true, v8ValueArray.popBoolean()); assertEquals(0, v8ValueArray.getLength()); - assertEquals("", v8ValueArray.toString()); + assertEquals(StringUtils.EMPTY, v8ValueArray.toString()); } } diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArrayBuffer.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArrayBuffer.java index 38fd22d2a..8b94bc5a1 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArrayBuffer.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueArrayBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueDataView.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueDataView.java index e200dca45..512f9ae5a 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueDataView.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueDataView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueError.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueError.java index 497b3821a..215e934e5 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueError.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueFunction.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueFunction.java index 6faed883f..f8712f882 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueFunction.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueFunction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,9 @@ import com.caoccao.javet.interop.executors.IV8Executor; import com.caoccao.javet.mock.MockAnnotationBasedCallbackReceiver; import com.caoccao.javet.mock.MockCallbackReceiver; +import com.caoccao.javet.utils.SimpleList; +import com.caoccao.javet.utils.SimpleSet; +import com.caoccao.javet.utils.StringUtils; import com.caoccao.javet.values.V8Value; import com.caoccao.javet.values.primitive.V8ValueInteger; import com.caoccao.javet.values.primitive.V8ValueString; @@ -465,7 +468,7 @@ public void testCallbackEchoStringWithoutThis() throws JavetException, NoSuchMet globalObject.bindFunction(javetCallbackContext); assertEquals("abc", v8Runtime.getExecutor("echoString('abc')").executeString()); assertEquals("abc,def", v8Runtime.getExecutor("echoString('abc', 'def')").executeString()); - assertEquals("", v8Runtime.getExecutor("echoString()").executeString()); + assertEquals(StringUtils.EMPTY, v8Runtime.getExecutor("echoString()").executeString()); globalObject.delete("echoString"); v8Runtime.lowMemoryNotification(); } @@ -1589,7 +1592,7 @@ public void testGetArguments() throws JavetException { @Test public void testGetScopeInfosWith1Closure() throws JavetException { - List options = Arrays.asList(true, false); + List options = SimpleList.of(true, false); String codeString = "(() => { let a = 1; return () => { const b = 0; return a; } })()"; try (V8ValueFunction v8ValueFunction = v8Runtime.getExecutor(codeString).execute()) { assertEquals(1, v8ValueFunction.callInteger(null)); @@ -1619,10 +1622,10 @@ public void testGetScopeInfosWith1Closure() throws JavetException { IV8ValueFunction.ScopeInfo scopeInfo2 = scopeInfos.get(2); List keys = scopeInfo2.getScopeObject().getOwnPropertyNameStrings(); if (v8Runtime.getJSRuntimeType().isNode()) { - Set globalVariables = new HashSet<>(Arrays.asList(( + Set globalVariables = SimpleSet.of(( "global,queueMicrotask,clearImmediate,setImmediate," + "structuredClone,clearInterval,clearTimeout,setInterval," + - "setTimeout,atob,btoa,crypto,performance,fetch,require").split(","))); + "setTimeout,atob,btoa,crypto,performance,fetch,require").split(",")); assertEquals(globalVariables.size(), keys.size()); keys.forEach(key -> assertTrue(globalVariables.contains(key), key + " is not found")); } else { @@ -1635,7 +1638,7 @@ public void testGetScopeInfosWith1Closure() throws JavetException { @Test public void testGetScopeInfosWith2Closures() throws JavetException { - List options = Arrays.asList(true, false); + List options = SimpleList.of(true, false); String codeString = "let a1 = 1;\n" + "let a2 = 2;\n" + "let ax = 1;\n" + @@ -1665,9 +1668,9 @@ public void testGetScopeInfosWith2Closures() throws JavetException { Map map0 = v8Runtime.toObject(scopeInfos.get(0).getScopeObject()); Map map1 = v8Runtime.toObject(scopeInfos.get(1).getScopeObject()); Map map2 = v8Runtime.toObject(scopeInfos.get(2).getScopeObject()); - assertEquals(Arrays.asList("c1", "c2"), scopeInfos.get(0).getScopeObject().getOwnPropertyNameStrings()); - assertEquals(Arrays.asList("b1", "b2"), scopeInfos.get(1).getScopeObject().getOwnPropertyNameStrings()); - assertEquals(Arrays.asList("a1", "a2", "ax"), scopeInfos.get(2).getScopeObject().getOwnPropertyNameStrings()); + assertEquals(SimpleList.of("c1", "c2"), scopeInfos.get(0).getScopeObject().getOwnPropertyNameStrings()); + assertEquals(SimpleList.of("b1", "b2"), scopeInfos.get(1).getScopeObject().getOwnPropertyNameStrings()); + assertEquals(SimpleList.of("a1", "a2", "ax"), scopeInfos.get(2).getScopeObject().getOwnPropertyNameStrings()); assertEquals(100, map0.get("c1")); assertEquals(200, map0.get("c2")); assertEquals(10, map1.get("b1")); @@ -1678,9 +1681,9 @@ public void testGetScopeInfosWith2Closures() throws JavetException { assertTrue(scopeInfos.hasVariablesInClosure()); List> variablesList = scopeInfos.getVariablesInClosure(); assertEquals(3, variablesList.size()); - assertEquals(Arrays.asList("c1", "c2"), variablesList.get(0)); - assertEquals(Arrays.asList("b1", "b2"), variablesList.get(1)); - assertEquals(Arrays.asList("a1", "a2", "ax"), variablesList.get(2)); + assertEquals(SimpleList.of("c1", "c2"), variablesList.get(0)); + assertEquals(SimpleList.of("b1", "b2"), variablesList.get(1)); + assertEquals(SimpleList.of("a1", "a2", "ax"), variablesList.get(2)); } } } @@ -1688,7 +1691,7 @@ public void testGetScopeInfosWith2Closures() throws JavetException { @Test public void testGetScopeInfosWithoutClosures() throws JavetException { - List options = Arrays.asList(true, false); + List options = SimpleList.of(true, false); String codeString = "function f1() {\n" + " let b = 2;\n" + " function f2() {\n" + diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueGlobalObject.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueGlobalObject.java index 4a32f57b3..bd59be703 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueGlobalObject.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueGlobalObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueMap.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueMap.java index f5d4d16fd..3baa140a6 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueMap.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueObject.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueObject.java index f532bd282..0622ec7d2 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueObject.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValuePromise.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValuePromise.java index d3ad9591a..d2443e2ad 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValuePromise.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValuePromise.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -157,7 +157,7 @@ public void reset() { } }; if (v8Runtime.getJSRuntimeType().isNode()) { - v8Runtime.getExecutor("const process = require('process'); process.on('unhandledRejection', () => {});").executeVoid(); + v8Runtime.getExecutor("process.on('unhandledRejection', () => {});").executeVoid(); } else { v8Runtime.setPromiseRejectCallback((event, promise, value) -> { }); @@ -215,8 +215,7 @@ public void testNoHandler() throws JavetException { List events = new ArrayList<>(); IJavetPromiseRejectCallback callback = (event, promise, value) -> events.add(event); if (v8Host.getJSRuntimeType().isNode()) { - v8Runtime.getExecutor("const process = require('process');\n" + - "var globalReason = null;\n" + + v8Runtime.getExecutor("var globalReason = null;\n" + "process.on('unhandledRejection', (reason, promise) => {\n" + " globalReason = reason;\n" + "});").executeVoid(); @@ -245,8 +244,7 @@ public void testNoHandlerAndHandlerAddedAfterReject() throws JavetException { List events = new ArrayList<>(); IJavetPromiseRejectCallback callback = (event, promise, value) -> events.add(event); if (v8Host.getJSRuntimeType().isNode()) { - v8Runtime.getExecutor("const process = require('process');\n" + - "process.on('unhandledRejection', (reason, promise) => {\n" + + v8Runtime.getExecutor("process.on('unhandledRejection', (reason, promise) => {\n" + " console.log(reason);\n" + "});").executeVoid(); } else { @@ -361,7 +359,7 @@ public void testResolverResolve() throws Exception { @ValueSource(booleans = {true, false}) public void testThen(boolean fulfilled) throws JavetException { if (v8Runtime.getJSRuntimeType().isNode()) { - v8Runtime.getExecutor("const process = require('process'); process.on('unhandledRejection', () => {});").executeVoid(); + v8Runtime.getExecutor(" process.on('unhandledRejection', () => {});").executeVoid(); } v8Runtime.getExecutor("const result = { fulfilled: false, rejected: false }").executeVoid(); try (V8ValuePromise v8ValuePromiseResolver = v8Runtime.createV8ValuePromise(); diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueProxy.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueProxy.java index e9ebcc555..bc4b92a72 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueProxy.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueRegExp.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueRegExp.java index b25f0371c..41752e671 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueRegExp.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueRegExp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueSet.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueSet.java index a5552f4d9..9e8fb5a6f 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueSet.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueSymbol.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueSymbol.java index 75edac902..a37a5e134 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueSymbol.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueSymbol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueTypedArray.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueTypedArray.java index 18056f6a2..961b481e3 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueTypedArray.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueTypedArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueWeakMap.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueWeakMap.java index a5e263481..8ab363980 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueWeakMap.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueWeakMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueWeakSet.java b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueWeakSet.java index 5a79632c0..61b29e1a0 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueWeakSet.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueWeakSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInJson.java b/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInJson.java index c9f93287f..c7b2a534a 100644 --- a/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInJson.java +++ b/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInJson.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInObject.java b/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInObject.java index 7a87c78a1..bfdbecd65 100644 --- a/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInObject.java +++ b/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInSymbol.java b/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInSymbol.java index ce636bd8a..54f1e5701 100644 --- a/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInSymbol.java +++ b/src/test/java/com/caoccao/javet/values/reference/builtin/TestV8ValueBuiltInSymbol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023. caoccao.com Sam Cao + * Copyright (c) 2021-2024. caoccao.com Sam Cao * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.