diff --git a/.github/workflows/android_node_build.yml b/.github/workflows/android_node_build.yml index 78893fd3..a4c90ecf 100644 --- a/.github/workflows/android_node_build.yml +++ b/.github/workflows/android_node_build.yml @@ -8,8 +8,8 @@ on: workflow_dispatch: env: - JAVET_NODE_VERSION: 22.11.0 - JAVET_VERSION: 4.1.0 + JAVET_NODE_VERSION: 22.12.0 + JAVET_VERSION: 4.1.1 ROOT: /home/runner/work/Javet jobs: diff --git a/.github/workflows/android_v8_build.yml b/.github/workflows/android_v8_build.yml index 950f3c1b..e9e9edf4 100644 --- a/.github/workflows/android_v8_build.yml +++ b/.github/workflows/android_v8_build.yml @@ -8,8 +8,8 @@ on: workflow_dispatch: env: - JAVET_V8_VERSION: 13.1.201.8 - JAVET_VERSION: 4.1.0 + JAVET_V8_VERSION: 13.2.152.16 + JAVET_VERSION: 4.1.1 ROOT: /home/runner/work/Javet jobs: @@ -192,12 +192,24 @@ jobs: mkdir -p android/javet-android/src/main/jniLibs/x86 mkdir -p android/javet-android/src/main/jniLibs/x86_64 + - name: Download Javet arm i18n + uses: actions/download-artifact@v4 + with: + name: javet-android-v8-arm-${{ env.JAVET_VERSION }}-i18n + path: android/javet-android/src/main/jniLibs/armeabi-v7a + - name: Download Javet arm64 i18n uses: actions/download-artifact@v4 with: name: javet-android-v8-arm64-${{ env.JAVET_VERSION }}-i18n path: android/javet-android/src/main/jniLibs/arm64-v8a + - name: Download Javet x86 i18n + uses: actions/download-artifact@v4 + with: + name: javet-android-v8-x86-${{ env.JAVET_VERSION }}-i18n + path: android/javet-android/src/main/jniLibs/x86 + - name: Download Javet x86_64 i18n uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/linux_build_artifact.yml b/.github/workflows/linux_build_artifact.yml index 45be2058..7f726d78 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: 22.11.0 - JAVET_V8_VERSION: 13.1.201.8 - JAVET_VERSION: 4.1.0 + JAVET_NODE_VERSION: 22.12.0 + JAVET_V8_VERSION: 13.2.152.16 + JAVET_VERSION: 4.1.1 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 6a583f3c..957df363 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: 22.11.0 - JAVET_V8_VERSION: 13.1.201.8 - JAVET_VERSION: 4.1.0 + JAVET_NODE_VERSION: 22.12.0 + JAVET_V8_VERSION: 13.2.152.16 + JAVET_VERSION: 4.1.1 # 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 148154a6..c7e82cea 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: 22.11.0 - JAVET_V8_VERSION: 13.1.201.8 - JAVET_VERSION: 4.1.0 + JAVET_NODE_VERSION: 22.12.0 + JAVET_V8_VERSION: 13.2.152.16 + JAVET_VERSION: 4.1.1 ROOT: /home/runner/work/Javet jobs: @@ -62,6 +62,7 @@ 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 ${{ matrix.v8_flag }} v8_enable_pointer_compression=false v8_static_library=true symbol_level=0 use_custom_libcxx=false v8_enable_sandbox=false + gn gen out.gn/x64.release 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 ./ diff --git a/.github/workflows/macos_arm64_build.yml b/.github/workflows/macos_arm64_build.yml index 520ee48e..934ddcc5 100644 --- a/.github/workflows/macos_arm64_build.yml +++ b/.github/workflows/macos_arm64_build.yml @@ -7,9 +7,9 @@ on: workflow_dispatch: env: - JAVET_NODE_VERSION: 22.11.0 - JAVET_V8_VERSION: 13.1.201.8 - JAVET_VERSION: 4.1.0 + JAVET_NODE_VERSION: 22.12.0 + JAVET_V8_VERSION: 13.2.152.16 + JAVET_VERSION: 4.1.1 ROOT: /Users/runner/work/Javet jobs: diff --git a/.github/workflows/macos_x86_64_build.yml b/.github/workflows/macos_x86_64_build.yml index 61e229f3..5d06a12d 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: 22.11.0 - JAVET_V8_VERSION: 13.1.201.8 - JAVET_VERSION: 4.1.0 + JAVET_NODE_VERSION: 22.12.0 + JAVET_V8_VERSION: 13.2.152.16 + JAVET_VERSION: 4.1.1 ROOT: /Users/runner/work/Javet jobs: diff --git a/.github/workflows/windows_x86_64_build.yml b/.github/workflows/windows_x86_64_build.yml index 192daf12..d521977f 100644 --- a/.github/workflows/windows_x86_64_build.yml +++ b/.github/workflows/windows_x86_64_build.yml @@ -7,9 +7,9 @@ on: workflow_dispatch: env: - JAVET_NODE_VERSION: 22.11.0 - JAVET_V8_VERSION: 13.1.201.8 - JAVET_VERSION: 4.1.0 + JAVET_NODE_VERSION: 22.12.0 + JAVET_V8_VERSION: 13.2.152.16 + JAVET_VERSION: 4.1.1 ROOT: D:\a\Javet jobs: @@ -93,6 +93,8 @@ jobs: run: | cd ../google/v8 sed -i '/static_assert(alignof(Type) <= alignof(decltype(/d' src/objects/tagged-field.h + sed -i 's/__attribute__((tls_model(V8_TLS_MODEL)))/ /g' src/execution/isolate.h + sed -i 's/__attribute__((tls_model(V8_TLS_MODEL)))/ /g' src/heap/local-heap.h - name: Build Javet JNI run: | diff --git a/README.rst b/README.rst index 2d038c52..0900086a 100644 --- a/README.rst +++ b/README.rst @@ -50,7 +50,7 @@ arm ✔️ ❌ ❌ ❌ arm64 ✔️ ✔️ ✔️ ❌ =========== ======= ======= ======= ======= -* Node.js ``v22.11.0`` + V8 ``v13.1.201.8`` +* Node.js ``v22.12.0`` + V8 ``v13.2.152.16`` * i18n and non-i18n * Dynamic switch between Node.js and V8 mode * Polyfill V8 mode with `Javenode `_ @@ -80,77 +80,77 @@ Maven com.caoccao.javet javet - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-linux-x86_64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-linux-arm64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-macos-x86_64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-macos-arm64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-windows-x86_64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-linux-x86_64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-linux-arm64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-macos-x86_64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-macos-arm64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-windows-x86_64 - 4.1.0 + 4.1.1 Gradle Kotlin DSL @@ -158,34 +158,34 @@ Gradle Kotlin DSL .. code-block:: kotlin - implementation("com.caoccao.javet:javet:4.1.0") // Core (Must-have) - implementation("com.caoccao.javet:javet-node-linux-arm64:4.1.0") - implementation("com.caoccao.javet:javet-node-linux-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-node-macos-arm64:4.1.0") - implementation("com.caoccao.javet:javet-node-macos-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-node-windows-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-v8-linux-arm64:4.1.0") - implementation("com.caoccao.javet:javet-v8-linux-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-v8-macos-arm64:4.1.0") - implementation("com.caoccao.javet:javet-v8-macos-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-v8-windows-x86_64:4.1.0") + implementation("com.caoccao.javet:javet:4.1.1") // Core (Must-have) + implementation("com.caoccao.javet:javet-node-linux-arm64:4.1.1") + implementation("com.caoccao.javet:javet-node-linux-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-node-macos-arm64:4.1.1") + implementation("com.caoccao.javet:javet-node-macos-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-node-windows-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-v8-linux-arm64:4.1.1") + implementation("com.caoccao.javet:javet-v8-linux-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-v8-macos-arm64:4.1.1") + implementation("com.caoccao.javet:javet-v8-macos-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-v8-windows-x86_64:4.1.1") Gradle Groovy DSL ^^^^^^^^^^^^^^^^^ .. code-block:: groovy - implementation 'com.caoccao.javet:javet:4.1.0' // Core (Must-have) - implementation 'com.caoccao.javet:javet-node-linux-arm64:4.1.0' - implementation 'com.caoccao.javet:javet-node-linux-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-node-macos-arm64:4.1.0' - implementation 'com.caoccao.javet:javet-node-macos-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-node-windows-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-linux-arm64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-linux-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-macos-arm64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-macos-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-windows-x86_64:4.1.0' + implementation 'com.caoccao.javet:javet:4.1.1' // Core (Must-have) + implementation 'com.caoccao.javet:javet-node-linux-arm64:4.1.1' + implementation 'com.caoccao.javet:javet-node-linux-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-node-macos-arm64:4.1.1' + implementation 'com.caoccao.javet:javet-node-macos-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-node-windows-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-linux-arm64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-linux-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-macos-arm64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-macos-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-windows-x86_64:4.1.1' For more detail, please visit the `installation `_ page. @@ -222,6 +222,7 @@ Blog * `How to Compromise V8 on JVM `_ * `Is TypeScript a Good Choice for a Script Engine? `_ * `Run TypeScript Directly in Java `_ +* `SSR — React + Spring Boot with Javet `_ Documents ========= diff --git a/android/javet-android/build.gradle.kts b/android/javet-android/build.gradle.kts index 2dc9e3c0..b5cd93df 100644 --- a/android/javet-android/build.gradle.kts +++ b/android/javet-android/build.gradle.kts @@ -73,7 +73,7 @@ object Config { const val ANDROIDX_TEST = "1.1.5" const val APPCOMPAT = "1.3.1" const val DESUGAR_JDK_LIBS = "2.0.4" - const val JAVET = "4.1.0" + const val JAVET = "4.1.1" const val JUNIT = "5.10.1" } } diff --git a/android/javet-android/src/main/AndroidManifest.xml b/android/javet-android/src/main/AndroidManifest.xml index a5604407..661818c7 100644 --- a/android/javet-android/src/main/AndroidManifest.xml +++ b/android/javet-android/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/android/pom.xml b/android/pom.xml index 2d9d1973..409f93eb 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -3,7 +3,7 @@ com.caoccao.javet javet-android - 4.1.0 + 4.1.1 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 - 4.1.0 + 4.1.1 diff --git a/build.gradle.kts b/build.gradle.kts index dac7f2be..318da3d3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -66,7 +66,7 @@ object Config { const val BYTE_BUDDY = "1.15.5" const val JACKSON_DATABIND = "2.16.0" const val JAVA_VERSION = "1.8" - const val JAVET = "4.1.0" + const val JAVET = "4.1.1" const val JAVET_BUDDY = "0.4.0" const val JETTY_WEBSOCKET = "9.4.53.v20231009" const val JUNIT = "5.11.3" diff --git a/cpp/build-android.sh b/cpp/build-android.sh index 1a90b28c..ae0ab55f 100755 --- a/cpp/build-android.sh +++ b/cpp/build-android.sh @@ -2,7 +2,7 @@ # 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=4.1.0 +JAVET_VERSION=4.1.1 rm -rf build_android mkdir build_android cd build_android diff --git a/cpp/build-linux-arm64.sh b/cpp/build-linux-arm64.sh index e819a47c..d9daf3ce 100644 --- a/cpp/build-linux-arm64.sh +++ b/cpp/build-linux-arm64.sh @@ -2,7 +2,7 @@ # 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=4.1.0 +JAVET_VERSION=4.1.1 rm -rf build_linux_arm64 mkdir build_linux_arm64 cd build_linux_arm64 diff --git a/cpp/build-linux-x86_64.sh b/cpp/build-linux-x86_64.sh index 13479ae3..abd36519 100644 --- a/cpp/build-linux-x86_64.sh +++ b/cpp/build-linux-x86_64.sh @@ -2,7 +2,7 @@ # 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=4.1.0 +JAVET_VERSION=4.1.1 rm -rf build_linux_x86_64 mkdir build_linux_x86_64 cd build_linux_x86_64 diff --git a/cpp/build-macos.sh b/cpp/build-macos.sh index 4a20d250..879d6d4c 100755 --- a/cpp/build-macos.sh +++ b/cpp/build-macos.sh @@ -2,7 +2,7 @@ # Usage for V8: sh build-macos.sh -DV8_DIR=${HOME}/v8 # Usage for Node: sh build-macos.sh -DNODE_DIR=${HOME}/node -JAVET_VERSION=4.1.0 +JAVET_VERSION=4.1.1 rm -rf build_macos mkdir build_macos cd build_macos diff --git a/cpp/build-windows.cmd b/cpp/build-windows.cmd index e75dda16..59fbab92 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=4.1.0 +SET JAVET_VERSION=4.1.1 rd /s/q build_windows mkdir build_windows cd build_windows diff --git a/cpp/jni/javet_callbacks.cpp b/cpp/jni/javet_callbacks.cpp index 261e6973..4b942613 100644 --- a/cpp/jni/javet_callbacks.cpp +++ b/cpp/jni/javet_callbacks.cpp @@ -134,8 +134,11 @@ namespace Javet { else { FETCH_JNI_ENV(GlobalJavaVM); auto externalV8Runtime = v8Runtime->externalV8Runtime; - jobject mIV8Module = jniEnv->CallObjectMethod( - externalV8Runtime, jmethodIDV8RuntimeReceiveGCEpilogueCallback, (jint)v8GCType, (jint)v8GCCallbackFlags); + jniEnv->CallVoidMethod( + externalV8Runtime, + jmethodIDV8RuntimeReceiveGCEpilogueCallback, + (jint)v8GCType, + (jint)v8GCCallbackFlags); } } } @@ -156,8 +159,11 @@ namespace Javet { else { FETCH_JNI_ENV(GlobalJavaVM); auto externalV8Runtime = v8Runtime->externalV8Runtime; - jobject mIV8Module = jniEnv->CallObjectMethod( - externalV8Runtime, jmethodIDV8RuntimeReceiveGCPrologueCallback, (jint)v8GCType, (jint)v8GCCallbackFlags); + jniEnv->CallVoidMethod( + externalV8Runtime, + jmethodIDV8RuntimeReceiveGCPrologueCallback, + (jint)v8GCType, + (jint)v8GCCallbackFlags); } } } @@ -224,9 +230,11 @@ namespace Javet { auto v8PersistentModule = TO_V8_PERSISTENT_MODULE_POINTER(mHandle); LOG_DEBUG("JavetModuleResolveCallback: module '" << moduleNamePointer.get() << "' found"); resolvedV8MaybeLocalModule = v8PersistentModule->Get(v8Context->GetIsolate()); + DELETE_LOCAL_REF(jniEnv, mIV8Module); } if (mReferrerV8Module != nullptr) { jniEnv->CallVoidMethod(mReferrerV8Module, jmethodIDIV8ValueReferenceClose, true); + DELETE_LOCAL_REF(jniEnv, mReferrerV8Module); } } } @@ -389,7 +397,7 @@ namespace Javet { if (jniEnv->ExceptionCheck()) { if (mResult != nullptr) { jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult); - jniEnv->DeleteLocalRef(mResult); + DELETE_LOCAL_REF(jniEnv, mResult); } Javet::Exceptions::ThrowV8Exception(jniEnv, v8Context, "Uncaught JavaError in function callback"); } @@ -404,7 +412,7 @@ namespace Javet { } if (mResult != nullptr) { jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult); - jniEnv->DeleteLocalRef(mResult); + DELETE_LOCAL_REF(jniEnv, mResult); } } } @@ -457,7 +465,7 @@ namespace Javet { } if (mResult != nullptr) { jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult); - jniEnv->DeleteLocalRef(mResult); + DELETE_LOCAL_REF(jniEnv, mResult); if (jniEnv->ExceptionCheck()) { Javet::Exceptions::ThrowV8Exception(jniEnv, v8Context, "Uncaught JavaError in property getter callback"); } @@ -511,7 +519,7 @@ namespace Javet { } if (mResult != nullptr) { jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult); - jniEnv->DeleteLocalRef(mResult); + DELETE_LOCAL_REF(jniEnv, mResult); if (jniEnv->ExceptionCheck()) { Javet::Exceptions::ThrowV8Exception(jniEnv, v8Context, "Uncaught JavaError in property setter callback"); } diff --git a/cpp/jni/javet_converter.cpp b/cpp/jni/javet_converter.cpp index 0b3d68cc..7c3f40cb 100644 --- a/cpp/jni/javet_converter.cpp +++ b/cpp/jni/javet_converter.cpp @@ -720,21 +720,31 @@ namespace Javet { } if (v8Value->IsArrayBuffer()) { auto v8ArrayBuffer = v8Value.As(); - return jniEnv->NewObject( + jobject directByteBuffer = jniEnv->NewDirectByteBuffer( + v8ArrayBuffer->GetBackingStore()->Data(), + v8ArrayBuffer->ByteLength()); + jobject v8ValueArrayBuffer = jniEnv->NewObject( jclassV8ValueArrayBuffer, jmethodIDV8ValueArrayBufferConstructor, v8Runtime->externalV8Runtime, ToV8PersistentReference(v8Context, v8Value), - jniEnv->NewDirectByteBuffer(v8ArrayBuffer->GetBackingStore()->Data(), v8ArrayBuffer->ByteLength())); + directByteBuffer); + DELETE_LOCAL_REF(jniEnv, directByteBuffer); + return v8ValueArrayBuffer; } if (v8Value->IsSharedArrayBuffer()) { auto v8SharedArrayBuffer = v8Value.As(); - return jniEnv->NewObject( + jobject directByteBuffer = jniEnv->NewDirectByteBuffer( + v8SharedArrayBuffer->GetBackingStore()->Data(), + v8SharedArrayBuffer->ByteLength()); + jobject v8ValueSharedArrayBuffer = jniEnv->NewObject( jclassV8ValueSharedArrayBuffer, jmethodIDV8ValueSharedArrayBufferConstructor, v8Runtime->externalV8Runtime, ToV8PersistentReference(v8Context, v8Value), - jniEnv->NewDirectByteBuffer(v8SharedArrayBuffer->GetBackingStore()->Data(), v8SharedArrayBuffer->ByteLength())); + directByteBuffer); + DELETE_LOCAL_REF(jniEnv, directByteBuffer); + return v8ValueSharedArrayBuffer; } if (v8Value->IsArrayBufferView()) { /* @@ -939,12 +949,14 @@ namespace Javet { v8LocalBigInt->ToWordsArray(&signBit, &wordCount, reinterpret_cast(mLongArrayPointer)); jniEnv->ReleaseLongArrayElements(mLongArray, mLongArrayPointer, 0); jint signum = signBit == 0 ? 1 : -1; - return jniEnv->NewObject( + jobject v8ValueBigInteger = jniEnv->NewObject( jclassV8ValueBigInteger, jmethodIDV8ValueBigIntegerConstructor, v8Runtime->externalV8Runtime, signum, mLongArray); + DELETE_LOCAL_REF(jniEnv, mLongArray); + return v8ValueBigInteger; } } // Something is wrong. It defaults to toString(). @@ -968,7 +980,9 @@ namespace Javet { // TODO: Memory leak might take place. v8ValueArray = jniEnv->NewObjectArray(argLength, jclassV8Value, nullptr); for (int i = 0; i < argLength; ++i) { - jniEnv->SetObjectArrayElement(v8ValueArray, i, ToExternalV8Value(jniEnv, v8Runtime, v8Context, args[i])); + jobject v8Value = ToExternalV8Value(jniEnv, v8Runtime, v8Context, args[i]); + jniEnv->SetObjectArrayElement(v8ValueArray, i, v8Value); + DELETE_LOCAL_REF(jniEnv, v8Value); } } return v8ValueArray; @@ -1016,8 +1030,9 @@ namespace Javet { else { v8LocalValue = v8MaybeLocalValue.ToLocalChecked(); } - jniEnv->SetObjectArrayElement( - v8Values, i, ToExternalV8Value(jniEnv, v8Runtime, v8Context, v8LocalValue)); + jobject v8Value = ToExternalV8Value(jniEnv, v8Runtime, v8Context, v8LocalValue); + jniEnv->SetObjectArrayElement(v8Values, i, v8Value); + DELETE_LOCAL_REF(jniEnv, v8Value); } return actualLength; } diff --git a/cpp/jni/javet_converter.h b/cpp/jni/javet_converter.h index c0d29930..0fb025cf 100644 --- a/cpp/jni/javet_converter.h +++ b/cpp/jni/javet_converter.h @@ -202,7 +202,7 @@ namespace Javet { jmethodIDV8ValuePrimitiveConstructor, v8Runtime->externalV8Runtime, mStringValue); - jniEnv->DeleteLocalRef(mStringValue); + DELETE_LOCAL_REF(jniEnv, mStringValue); return mV8ValuePrimitive; } diff --git a/cpp/jni/javet_jni_function.cpp b/cpp/jni/javet_jni_function.cpp index 478f2375..7af52d13 100644 --- a/cpp/jni/javet_jni_function.cpp +++ b/cpp/jni/javet_jni_function.cpp @@ -216,9 +216,6 @@ JNIEXPORT jobjectArray JNICALL Java_com_caoccao_javet_interop_V8Native_functionG auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); #ifdef ENABLE_NODE auto v8InternalScript = V8InternalScript::cast(v8InternalShared->script()); -#else - auto v8InternalScript = v8::internal::Cast(v8InternalShared->script()); -#endif auto wrappedArguments = *v8InternalScript->wrapped_arguments(); auto length = wrappedArguments.length(); if (length > 0) { @@ -231,6 +228,21 @@ JNIEXPORT jobjectArray JNICALL Java_com_caoccao_javet_interop_V8Native_functionG } return arguments; } +#else + auto v8InternalScript = v8::internal::Cast(v8InternalShared->script()); + auto wrappedArguments = v8InternalScript->wrapped_arguments(); + auto length = wrappedArguments->length(); + if (length > 0) { + jobjectArray arguments = jniEnv->NewObjectArray(length, Javet::Converter::jclassString, nullptr); + for (int i = 0; i < length; ++i) { + auto v8InternalObjectHandle = v8::internal::handle(wrappedArguments->get(i), v8InternalIsolate); + auto v8LocalString = v8::Utils::ToLocal(v8InternalObjectHandle).As(); + jstring argument = Javet::Converter::ToJavaString(jniEnv, v8Context, v8LocalString); + jniEnv->SetObjectArrayElement(arguments, i, argument); + } + return arguments; + } +#endif } } return nullptr; @@ -383,9 +395,13 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetScr const int startPosition = v8InternalShared->StartPosition(); const int endPosition = v8InternalShared->EndPosition(); const int sourceLength = v8InternalSource->length(); +#ifdef ENABLE_NODE auto sourceCode = v8InternalSource->ToCString( V8InternalAllowNullsFlag::DISALLOW_NULLS, V8InternalRobustnessFlag::ROBUST_STRING_TRAVERSAL, 0, sourceLength); +#else + auto sourceCode = v8InternalSource->ToCString(0, sourceLength); +#endif return jniEnv->NewObject( Javet::Converter::jclassIV8ValueFunctionScriptSource, Javet::Converter::jmethodIDIV8ValueFunctionScriptSourceConstructor, @@ -413,9 +429,13 @@ JNIEXPORT jstring JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetSou #endif const int startPosition = v8InternalShared->StartPosition(); const int endPosition = v8InternalShared->EndPosition(); +#ifdef ENABLE_NODE auto sourceCode = v8InternalSource->ToCString( V8InternalAllowNullsFlag::DISALLOW_NULLS, V8InternalRobustnessFlag::ROBUST_STRING_TRAVERSAL, startPosition, endPosition - startPosition); +#else + auto sourceCode = v8InternalSource->ToCString(startPosition, endPosition - startPosition); +#endif return Javet::Converter::ToJavaString(jniEnv, sourceCode.get()); } } @@ -542,10 +562,15 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetSo V8LocalString newSourceCode; if (startPosition > 0) { +#ifdef ENABLE_NODE int utf8Length = 0; auto stdStringHeader(v8InternalSource->ToCString( V8InternalAllowNullsFlag::DISALLOW_NULLS, V8InternalRobustnessFlag::ROBUST_STRING_TRAVERSAL, 0, startPosition, &utf8Length)); +#else + uint32_t utf8Length = 0; + auto stdStringHeader(v8InternalSource->ToCString(0, startPosition, &utf8Length)); +#endif auto v8MaybeLocalStringHeader = v8::String::NewFromUtf8( v8Context->GetIsolate(), stdStringHeader.get(), v8::NewStringType::kNormal, utf8Length); if (v8MaybeLocalStringHeader.IsEmpty()) { @@ -562,10 +587,15 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetSo newSourceCode = v8::String::Concat(v8Context->GetIsolate(), newSourceCode, umSourceCode); } if (endPosition < sourceLength) { +#ifdef ENABLE_NODE int utf8Length = 0; auto stdStringFooter(v8InternalSource->ToCString( V8InternalAllowNullsFlag::DISALLOW_NULLS, V8InternalRobustnessFlag::ROBUST_STRING_TRAVERSAL, endPosition, sourceLength - endPosition, &utf8Length)); +#else + uint32_t utf8Length = 0; + auto stdStringFooter(v8InternalSource->ToCString(endPosition, sourceLength - endPosition, &utf8Length)); +#endif auto v8MaybeLocalStringFooter = v8::String::NewFromUtf8( v8Context->GetIsolate(), stdStringFooter.get(), v8::NewStringType::kNormal, utf8Length); if (v8MaybeLocalStringFooter.IsEmpty()) { diff --git a/cpp/jni/javet_resource_node.rc b/cpp/jni/javet_resource_node.rc index 9c89e1ec..ed4bc6b5 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 4,1,0,0 - PRODUCTVERSION 4,1,0,0 + FILEVERSION 4,1,1,0 + PRODUCTVERSION 4,1,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -79,12 +79,12 @@ BEGIN BEGIN VALUE "CompanyName", "caoccao.com" VALUE "FileDescription", "caoccao.com" - VALUE "FileVersion", "4.1.0.0" - VALUE "InternalName", "libjavet-node-windows-x86_64.v.4.1.0.dll" + VALUE "FileVersion", "4.1.1.0" + VALUE "InternalName", "libjavet-node-windows-x86_64.v.4.1.1.dll" VALUE "LegalCopyright", "Copyright (c) 2021-2024." - VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.4.1.0.dll" + VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.4.1.1.dll" VALUE "ProductName", "Javet Windows" - VALUE "ProductVersion", "4.1.0.0" + VALUE "ProductVersion", "4.1.1.0" END END BLOCK "VarFileInfo" diff --git a/cpp/jni/javet_resource_v8.rc b/cpp/jni/javet_resource_v8.rc index ee2ebd80..c8f163a3 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 4,1,0,0 - PRODUCTVERSION 4,1,0,0 + FILEVERSION 4,1,1,0 + PRODUCTVERSION 4,1,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -79,12 +79,12 @@ BEGIN BEGIN VALUE "CompanyName", "caoccao.com" VALUE "FileDescription", "caoccao.com" - VALUE "FileVersion", "4.1.0.0" - VALUE "InternalName", "libjavet-v8-windows-x86_64.v.4.1.0.dll" + VALUE "FileVersion", "4.1.1.0" + VALUE "InternalName", "libjavet-v8-windows-x86_64.v.4.1.1.dll" VALUE "LegalCopyright", "Copyright (c) 2021-2024." - VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.4.1.0.dll" + VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.4.1.1.dll" VALUE "ProductName", "Javet Windows" - VALUE "ProductVersion", "4.1.0.0" + VALUE "ProductVersion", "4.1.1.0" END END BLOCK "VarFileInfo" diff --git a/cpp/jni/javet_v8_internal.h b/cpp/jni/javet_v8_internal.h index 3f6ea1b8..d34ea904 100644 --- a/cpp/jni/javet_v8_internal.h +++ b/cpp/jni/javet_v8_internal.h @@ -57,7 +57,9 @@ #pragma warning(default: 4819) #pragma warning(default: 4996) +#ifdef ENABLE_NODE using V8InternalAllowNullsFlag = v8::internal::AllowNullsFlag; +#endif using V8internalBlockingBehavior = v8::internal::BlockingBehavior; using V8InternalBuiltin = v8::internal::Builtin; using V8InternalDisallowCompilation = v8::internal::DisallowCompilation; @@ -71,7 +73,9 @@ using V8InternalJSObject = v8::internal::JSObject; using V8InternalModule = v8::internal::Module; using V8InternalNativeContext = v8::internal::NativeContext; using V8InternalObject = v8::internal::Object; +#ifdef ENABLE_NODE using V8InternalRobustnessFlag = v8::internal::RobustnessFlag; +#endif using V8InternalScopeInfo = v8::internal::ScopeInfo; using V8InternalScopeIterator = v8::internal::ScopeIterator; using V8InternalScopeType = v8::internal::ScopeType; diff --git a/docker/android/base.Dockerfile b/docker/android/base.Dockerfile index d0806b8d..a411ad8f 100644 --- a/docker/android/base.Dockerfile +++ b/docker/android/base.Dockerfile @@ -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:4.1.0 -f docker/android/base.Dockerfile . +# Usage: docker build -t sjtucaocao/javet-android:4.1.1 -f docker/android/base.Dockerfile . -ARG JAVET_V8_VERSION=13.1.201.8 +ARG JAVET_V8_VERSION=13.2.152.16 FROM ubuntu:20.04 WORKDIR / diff --git a/docker/android/build.Dockerfile b/docker/android/build.Dockerfile index 81702907..9b3e9d2a 100644 --- a/docker/android/build.Dockerfile +++ b/docker/android/build.Dockerfile @@ -15,7 +15,7 @@ # Usage: docker build -t javet-android:local -f docker/android/build.Dockerfile . -FROM sjtucaocao/javet-android:4.1.0 +FROM sjtucaocao/javet-android:4.1.1 WORKDIR / # Copy Javet diff --git a/docker/linux-arm64/base_all_in_one.Dockerfile b/docker/linux-arm64/base_all_in_one.Dockerfile index 98754838..af9ad706 100644 --- a/docker/linux-arm64/base_all_in_one.Dockerfile +++ b/docker/linux-arm64/base_all_in_one.Dockerfile @@ -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:4.1.0 -f docker/linux-arm64/base_all_in_one.Dockerfile . +# Usage: docker build -t sjtucaocao/javet-arm64:4.1.1 -f docker/linux-arm64/base_all_in_one.Dockerfile . ARG JAVET_NODE_VERSION=18.15.0 -ARG JAVET_V8_VERSION=13.1.201.8 +ARG JAVET_V8_VERSION=13.2.152.16 FROM ubuntu:20.04 WORKDIR / diff --git a/docker/linux-arm64/base_gradle.Dockerfile b/docker/linux-arm64/base_gradle.Dockerfile index 73b3dabc..f95abdc5 100644 --- a/docker/linux-arm64/base_gradle.Dockerfile +++ b/docker/linux-arm64/base_gradle.Dockerfile @@ -14,7 +14,7 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:arm64-4.1.0 \ +# -t sjtucaocao/javet:arm64-4.1.1 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ # -f docker/linux-arm64/base_gradle.Dockerfile . diff --git a/docker/linux-arm64/base_v8.Dockerfile b/docker/linux-arm64/base_v8.Dockerfile index 5b842a6f..0409532a 100644 --- a/docker/linux-arm64/base_v8.Dockerfile +++ b/docker/linux-arm64/base_v8.Dockerfile @@ -14,13 +14,13 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:arm64-base-v8_13.1.201.8 \ +# -t sjtucaocao/javet:arm64-base-v8_13.2.152.16 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ -# --build-arg JAVET_V8_VERSION=13.1.201.8 \ +# --build-arg JAVET_V8_VERSION=13.2.152.16 \ # -f docker/linux-arm64/base_v8.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet -ARG JAVET_V8_VERSION=13.1.201.8 +ARG JAVET_V8_VERSION=13.2.152.16 FROM ${JAVET_REPO}:arm64-base-jvm diff --git a/docker/linux-arm64/build_artifact.Dockerfile b/docker/linux-arm64/build_artifact.Dockerfile index 7cd2ca51..8aa44188 100644 --- a/docker/linux-arm64/build_artifact.Dockerfile +++ b/docker/linux-arm64/build_artifact.Dockerfile @@ -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=4.1.0 \ +# --build-arg JAVET_VERSION=4.1.1 \ # -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=4.1.0 +ARG JAVET_VERSION=4.1.1 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 460405db..bacb1075 100644 --- a/docker/linux-x86_64/base_all_in_one.Dockerfile +++ b/docker/linux-x86_64/base_all_in_one.Dockerfile @@ -13,13 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Usage: docker build -t sjtucaocao/javet:4.1.0 -f docker/linux-x86_64/base_all_in_one.Dockerfile . +# Usage: docker build -t sjtucaocao/javet:4.1.1 -f docker/linux-x86_64/base_all_in_one.Dockerfile . FROM ubuntu:20.04 WORKDIR / -ARG JAVET_NODE_VERSION=22.11.0 -ARG JAVET_V8_VERSION=13.1.201.8 +ARG JAVET_NODE_VERSION=22.12.0 +ARG JAVET_V8_VERSION=13.2.152.16 # Update Ubuntu ENV DEBIAN_FRONTEND=noninteractive diff --git a/docker/linux-x86_64/base_gradle.Dockerfile b/docker/linux-x86_64/base_gradle.Dockerfile index 5940a411..7fd1362d 100644 --- a/docker/linux-x86_64/base_gradle.Dockerfile +++ b/docker/linux-x86_64/base_gradle.Dockerfile @@ -14,7 +14,7 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:x86_64-4.1.0 \ +# -t sjtucaocao/javet:x86_64-4.1.1 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ # -f docker/linux-x86_64/base_gradle.Dockerfile . diff --git a/docker/linux-x86_64/base_node.Dockerfile b/docker/linux-x86_64/base_node.Dockerfile index d433ec63..78b0fb27 100644 --- a/docker/linux-x86_64/base_node.Dockerfile +++ b/docker/linux-x86_64/base_node.Dockerfile @@ -14,13 +14,13 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:x86_64-base-node_22.11.0 \ +# -t sjtucaocao/javet:x86_64-base-node_22.12.0 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ -# --build-arg JAVET_NODE_VERSION=22.11.0 \ +# --build-arg JAVET_NODE_VERSION=22.12.0 \ # -f docker/linux-x86_64/base_node.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet -ARG JAVET_NODE_VERSION=22.11.0 +ARG JAVET_NODE_VERSION=22.12.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 4efdebfb..2979c610 100644 --- a/docker/linux-x86_64/base_v8.Dockerfile +++ b/docker/linux-x86_64/base_v8.Dockerfile @@ -14,13 +14,13 @@ # limitations under the License. # Usage: docker build \ -# -t sjtucaocao/javet:x86_64-base-v8_13.1.201.8 \ +# -t sjtucaocao/javet:x86_64-base-v8_13.2.152.16 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ -# --build-arg JAVET_V8_VERSION=13.1.201.8 \ +# --build-arg JAVET_V8_VERSION=13.2.152.16 \ # -f docker/linux-x86_64/base_v8.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet -ARG JAVET_V8_VERSION=13.1.201.8 +ARG JAVET_V8_VERSION=13.2.152.16 FROM ${JAVET_REPO}:x86_64-base-jvm diff --git a/docker/linux-x86_64/build.env b/docker/linux-x86_64/build.env index b46235f2..91f311c6 100644 --- a/docker/linux-x86_64/build.env +++ b/docker/linux-x86_64/build.env @@ -1,4 +1,4 @@ JAVET_REPO=sjtucaocao/javet -JAVET_VERSION=4.1.0 -JAVET_V8_VERSION=13.1.201.8 -JAVET_NODE_VERSION=22.11.0 +JAVET_VERSION=4.1.1 +JAVET_V8_VERSION=13.2.152.16 +JAVET_NODE_VERSION=22.12.0 diff --git a/docker/linux-x86_64/build_all_in_one.Dockerfile b/docker/linux-x86_64/build_all_in_one.Dockerfile index a61e7f34..82c8ee92 100644 --- a/docker/linux-x86_64/build_all_in_one.Dockerfile +++ b/docker/linux-x86_64/build_all_in_one.Dockerfile @@ -15,7 +15,7 @@ # Usage: docker build -t javet:local -f docker/linux-x86_64/build_all_in_one.Dockerfile . -FROM sjtucaocao/javet:4.1.0 +FROM sjtucaocao/javet:4.1.1 WORKDIR / # Copy Javet diff --git a/docker/linux-x86_64/build_artifact.Dockerfile b/docker/linux-x86_64/build_artifact.Dockerfile index 87ae4a4d..2dd1ec52 100644 --- a/docker/linux-x86_64/build_artifact.Dockerfile +++ b/docker/linux-x86_64/build_artifact.Dockerfile @@ -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=4.1.0 \ +# --build-arg JAVET_VERSION=4.1.1 \ # -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=4.1.0 +ARG JAVET_VERSION=4.1.1 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 066cc5a7..3f5d4c9c 100644 --- a/docker/windows-x86_64/base.Dockerfile +++ b/docker/windows-x86_64/base.Dockerfile @@ -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:4.1.0 -m 4G -f docker/windows-x86_64/base.Dockerfile . +# Usage: docker build -t sjtucaocao/javet-windows:4.1.1 -m 4G -f docker/windows-x86_64/base.Dockerfile . -ARG JAVET_NODE_VERSION=22.11.0 -ARG JAVET_V8_VERSION=13.1.201.8 +ARG JAVET_NODE_VERSION=22.12.0 +ARG JAVET_V8_VERSION=13.2.152.16 # 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 c1206fd0..b0698f95 100644 --- a/docker/windows-x86_64/build.Dockerfile +++ b/docker/windows-x86_64/build.Dockerfile @@ -15,7 +15,7 @@ # Usage: docker build -t javet:local -f docker/windows-x86_64/build.Dockerfile . -FROM sjtucaocao/javet-windows:4.1.0 +FROM sjtucaocao/javet-windows:4.1.1 SHELL ["cmd", "/S", "/C"] WORKDIR / diff --git a/docs/conf.py b/docs/conf.py index 0bd30ec3..82008184 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 = '4.1.0' +release = '4.1.1' # -- General configuration --------------------------------------------------- diff --git a/docs/index.rst b/docs/index.rst index 92f29659..ca308aeb 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,6 +1,6 @@ .. include:: ../README.rst :start-line: 0 - :end-line: 229 + :end-line: 230 .. toctree:: :maxdepth: 2 diff --git a/docs/release_notes/release_notes_4_0.rst b/docs/release_notes/release_notes_4_0.rst index f5d4cf0e..69665920 100644 --- a/docs/release_notes/release_notes_4_0.rst +++ b/docs/release_notes/release_notes_4_0.rst @@ -2,6 +2,18 @@ Release Notes 4.0.x - 4.1.x =========================== +4.1.1 +----- + +* Upgraded Node.js to ``v22.12.0`` `(2024-12-03) `_ +* Upgraded V8 to ``v13.2.152.16`` (2024-12-05) +* Upgraded Visual Studio 2022 to `v17.12.3 `_ +* Added ``getAbsoluteResourceName()`` to ``IV8ModuleResolver`` +* Fixed memory leaks in function callback in edge cases +* ``require(esm)`` is enabled by default +* Removed ``isExperimentalRequireModule()``, ``setExperimentalRequireModule`` from ``NodeFlags`` +* Added ``isNoExperimentalRequireModule()``, ``setNoExperimentalRequireModule`` to ``NodeFlags`` + 4.1.0 ----- diff --git a/docs/tutorial/advanced/internationalization_i18n.rst b/docs/tutorial/advanced/internationalization_i18n.rst index 817c7014..714cf359 100644 --- a/docs/tutorial/advanced/internationalization_i18n.rst +++ b/docs/tutorial/advanced/internationalization_i18n.rst @@ -16,6 +16,14 @@ How to Enable i18n? * Follow :doc:`../basic/installation` to turn i18n on. * Download and save ``icudt*.dat`` files from somewhere to a local directory. E.g. ``v8/third_party/icu``, ``node/deps/icu-tmp``. + +.. note:: + + There are 2 typical ways of getting the i18n files. + + 1. Clone Node.js or V8, then copy the files over. + 2. Visit `Actions `_, then download the files from the latest successful builds. + * Set a flag as follows before the first Node.js or V8 runtime is created. .. code-block:: java diff --git a/docs/tutorial/basic/installation.rst b/docs/tutorial/basic/installation.rst index 07cf6f5e..a17f315d 100644 --- a/docs/tutorial/basic/installation.rst +++ b/docs/tutorial/basic/installation.rst @@ -22,7 +22,7 @@ The following dependency must be added. com.caoccao.javet javet - 4.1.0 + 4.1.1 The following dependencies contain the non-i18n binaries for various OS / JS Runtime Type. @@ -35,35 +35,35 @@ The following dependencies contain the non-i18n binaries for various OS / JS Run com.caoccao.javet javet-node-linux-x86_64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-linux-arm64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-macos-x86_64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-macos-arm64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-windows-x86_64 - 4.1.0 + 4.1.1 .. tab:: V8 (Express) @@ -74,35 +74,35 @@ The following dependencies contain the non-i18n binaries for various OS / JS Run com.caoccao.javet javet-v8-linux-x86_64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-linux-arm64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-macos-x86_64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-macos-arm64 - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-windows-x86_64 - 4.1.0 + 4.1.1 .. tab:: Node (Complete) @@ -110,7 +110,7 @@ The following dependencies contain the non-i18n binaries for various OS / JS Run .. code-block:: xml - 4.1.0 + 4.1.1 @@ -202,7 +202,7 @@ The following dependencies contain the non-i18n binaries for various OS / JS Run .. code-block:: xml - 4.1.0 + 4.1.1 @@ -299,35 +299,35 @@ The following dependencies contain the i18n binaries for various OS / JS Runtime com.caoccao.javet javet-node-linux-x86_64-i18n - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-linux-arm64-i18n - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-macos-x86_64-i18n - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-macos-arm64-i18n - 4.1.0 + 4.1.1 com.caoccao.javet javet-node-windows-x86_64-i18n - 4.1.0 + 4.1.1 .. tab:: V8 i18n (Express) @@ -338,35 +338,35 @@ The following dependencies contain the i18n binaries for various OS / JS Runtime com.caoccao.javet javet-v8-linux-x86_64-i18n - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-linux-arm64-i18n - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-macos-x86_64-i18n - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-macos-arm64-i18n - 4.1.0 + 4.1.1 com.caoccao.javet javet-v8-windows-x86_64-i18n - 4.1.0 + 4.1.1 .. tab:: Node i18n (Complete) @@ -374,7 +374,7 @@ The following dependencies contain the i18n binaries for various OS / JS Runtime .. code-block:: xml - 4.1.0 + 4.1.1 @@ -466,7 +466,7 @@ The following dependencies contain the i18n binaries for various OS / JS Runtime .. code-block:: xml - 4.1.0 + 4.1.1 @@ -560,27 +560,27 @@ Gradle Kotlin DSL - Desktop .. code-block:: kotlin - implementation("com.caoccao.javet:javet:4.1.0") // Must-have - implementation("com.caoccao.javet:javet-node-linux-arm64:4.1.0") - implementation("com.caoccao.javet:javet-node-linux-arm64-i18n:4.1.0") - implementation("com.caoccao.javet:javet-node-linux-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-node-linux-x86_64-i18n:4.1.0") - implementation("com.caoccao.javet:javet-node-macos-arm64:4.1.0") - implementation("com.caoccao.javet:javet-node-macos-arm64-i18n:4.1.0") - implementation("com.caoccao.javet:javet-node-macos-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-node-macos-x86_64-i18n:4.1.0") - implementation("com.caoccao.javet:javet-node-windows-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-node-windows-x86_64-i18n:4.1.0") - implementation("com.caoccao.javet:javet-v8-linux-arm64:4.1.0") - implementation("com.caoccao.javet:javet-v8-linux-arm64-i18n:4.1.0") - implementation("com.caoccao.javet:javet-v8-linux-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-v8-linux-x86_64-i18n:4.1.0") - implementation("com.caoccao.javet:javet-v8-macos-arm64:4.1.0") - implementation("com.caoccao.javet:javet-v8-macos-arm64-i18n:4.1.0") - implementation("com.caoccao.javet:javet-v8-macos-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-v8-macos-x86_64-i18n:4.1.0") - implementation("com.caoccao.javet:javet-v8-windows-x86_64:4.1.0") - implementation("com.caoccao.javet:javet-v8-windows-x86_64-i18n:4.1.0") + implementation("com.caoccao.javet:javet:4.1.1") // Must-have + implementation("com.caoccao.javet:javet-node-linux-arm64:4.1.1") + implementation("com.caoccao.javet:javet-node-linux-arm64-i18n:4.1.1") + implementation("com.caoccao.javet:javet-node-linux-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-node-linux-x86_64-i18n:4.1.1") + implementation("com.caoccao.javet:javet-node-macos-arm64:4.1.1") + implementation("com.caoccao.javet:javet-node-macos-arm64-i18n:4.1.1") + implementation("com.caoccao.javet:javet-node-macos-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-node-macos-x86_64-i18n:4.1.1") + implementation("com.caoccao.javet:javet-node-windows-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-node-windows-x86_64-i18n:4.1.1") + implementation("com.caoccao.javet:javet-v8-linux-arm64:4.1.1") + implementation("com.caoccao.javet:javet-v8-linux-arm64-i18n:4.1.1") + implementation("com.caoccao.javet:javet-v8-linux-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-v8-linux-x86_64-i18n:4.1.1") + implementation("com.caoccao.javet:javet-v8-macos-arm64:4.1.1") + implementation("com.caoccao.javet:javet-v8-macos-arm64-i18n:4.1.1") + implementation("com.caoccao.javet:javet-v8-macos-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-v8-macos-x86_64-i18n:4.1.1") + implementation("com.caoccao.javet:javet-v8-windows-x86_64:4.1.1") + implementation("com.caoccao.javet:javet-v8-windows-x86_64-i18n:4.1.1") .. tab:: Complete @@ -598,35 +598,35 @@ Gradle Kotlin DSL - Desktop if (os.isMacOsX) "macos" else if (os.isLinux) "linux" else "" val archType = if (arch == "aarch64" || arch == "arm64") "arm64" else "x86_64" - implementation("com.caoccao.javet:javet:4.1.0") - implementation("com.caoccao.javet:javet-$jsRuntimeTimeType-$osType-$archType$i18nType:4.0.0") + implementation("com.caoccao.javet:javet:4.1.1") + implementation("com.caoccao.javet:javet-$jsRuntimeTimeType-$osType-$archType$i18nType:4.1.1") Gradle Groovy DSL - Desktop --------------------------- .. code-block:: groovy - implementation 'com.caoccao.javet:javet:4.1.0' // Must-have - implementation 'com.caoccao.javet:javet-node-linux-arm64:4.1.0' - implementation 'com.caoccao.javet:javet-node-linux-arm64-i18n:4.1.0' - implementation 'com.caoccao.javet:javet-node-linux-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-node-linux-x86_64-i18n:4.1.0' - implementation 'com.caoccao.javet:javet-node-macos-arm64:4.1.0' - implementation 'com.caoccao.javet:javet-node-macos-arm64-i18n:4.1.0' - implementation 'com.caoccao.javet:javet-node-macos-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-node-macos-x86_64-i18n:4.1.0' - implementation 'com.caoccao.javet:javet-node-windows-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-node-windows-x86_64-i18n:4.1.0' - implementation 'com.caoccao.javet:javet-v8-linux-arm64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-linux-arm64-i18n:4.1.0' - implementation 'com.caoccao.javet:javet-v8-linux-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-linux-x86_64-i18n:4.1.0' - implementation 'com.caoccao.javet:javet-v8-macos-arm64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-macos-arm64-i18n:4.1.0' - implementation 'com.caoccao.javet:javet-v8-macos-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-macos-x86_64-i18n:4.1.0' - implementation 'com.caoccao.javet:javet-v8-windows-x86_64:4.1.0' - implementation 'com.caoccao.javet:javet-v8-windows-x86_64-i18n:4.1.0' + implementation 'com.caoccao.javet:javet:4.1.1' // Must-have + implementation 'com.caoccao.javet:javet-node-linux-arm64:4.1.1' + implementation 'com.caoccao.javet:javet-node-linux-arm64-i18n:4.1.1' + implementation 'com.caoccao.javet:javet-node-linux-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-node-linux-x86_64-i18n:4.1.1' + implementation 'com.caoccao.javet:javet-node-macos-arm64:4.1.1' + implementation 'com.caoccao.javet:javet-node-macos-arm64-i18n:4.1.1' + implementation 'com.caoccao.javet:javet-node-macos-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-node-macos-x86_64-i18n:4.1.1' + implementation 'com.caoccao.javet:javet-node-windows-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-node-windows-x86_64-i18n:4.1.1' + implementation 'com.caoccao.javet:javet-v8-linux-arm64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-linux-arm64-i18n:4.1.1' + implementation 'com.caoccao.javet:javet-v8-linux-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-linux-x86_64-i18n:4.1.1' + implementation 'com.caoccao.javet:javet-v8-macos-arm64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-macos-arm64-i18n:4.1.1' + implementation 'com.caoccao.javet:javet-v8-macos-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-macos-x86_64-i18n:4.1.1' + implementation 'com.caoccao.javet:javet-v8-windows-x86_64:4.1.1' + implementation 'com.caoccao.javet:javet-v8-windows-x86_64-i18n:4.1.1' Dependencies - Android ====================== @@ -636,20 +636,20 @@ Gradle Kotlin DSL - Android .. code-block:: kotlin - implementation("com.caoccao.javet:javet-node-android:4.1.0") // Android Node (arm, arm64, x86 and x86_64) - implementation("com.caoccao.javet:javet-node-android-i18n:4.1.0") // Android Node (arm64 and x86_64) - implementation("com.caoccao.javet:javet-v8-android:4.1.0") // Android V8 (arm, arm64, x86 and x86_64) - implementation("com.caoccao.javet:javet-v8-android-i18n:4.1.0") // Android V8 (arm, arm64, x86 and x86_64) + implementation("com.caoccao.javet:javet-node-android:4.1.1") // Android Node (arm, arm64, x86 and x86_64) + implementation("com.caoccao.javet:javet-node-android-i18n:4.1.1") // Android Node (arm64 and x86_64) + implementation("com.caoccao.javet:javet-v8-android:4.1.1") // Android V8 (arm, arm64, x86 and x86_64) + implementation("com.caoccao.javet:javet-v8-android-i18n:4.1.1") // Android V8 (arm, arm64, x86 and x86_64) Gradle Groovy DSL - Android --------------------------- .. code-block:: groovy - implementation 'com.caoccao.javet:javet-node-android:4.1.0' // Android Node (arm, arm64, x86 and x86_64) - implementation 'com.caoccao.javet:javet-node-android-i18n:4.1.0' // Android Node (arm64 and x86_64) - implementation 'com.caoccao.javet:javet-v8-android:4.1.0' // Android V8 (arm, arm64, x86 and x86_64) - implementation 'com.caoccao.javet:javet-v8-android-i18n:4.1.0' // Android V8 (arm, arm64, x86 and x86_64) + implementation 'com.caoccao.javet:javet-node-android:4.1.1' // Android Node (arm, arm64, x86 and x86_64) + implementation 'com.caoccao.javet:javet-node-android-i18n:4.1.1' // Android Node (arm64 and x86_64) + implementation 'com.caoccao.javet:javet-v8-android:4.1.1' // Android V8 (arm, arm64, x86 and x86_64) + implementation 'com.caoccao.javet:javet-v8-android-i18n:4.1.1' // Android V8 (arm, arm64, x86 and x86_64) OS Compatibility ================ diff --git a/scripts/node/javet-rebuild/rebuild.cmd b/scripts/node/javet-rebuild/rebuild.cmd index c0f5fc96..6d8dcdd2 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.4.1.0.lib" +SET NODE_LIB_FILE="..\..\..\..\..\..\build\libs\libjavet-node-windows-x86_64.v.4.1.1.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 595f7cfc..2eb678a2 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.4.1.0.so ${NODE_MODULE_FILE} +patchelf --add-needed libjavet-node-linux-x86_64.v.4.1.1.so ${NODE_MODULE_FILE} diff --git a/scripts/python/change_javet_version.py b/scripts/python/change_javet_version.py index 4470b981..94c4e8ea 100644 --- a/scripts/python/change_javet_version.py +++ b/scripts/python/change_javet_version.py @@ -116,7 +116,7 @@ def update(self): 'docs/tutorial/basic/installation.rst', '\n', re.compile(r'(?P\d+\.\d+\.\d+)'), re.compile(r'(?P\d+\.\d+\.\d+)$'), - re.compile(r'javet[\-\w]*:(?P\d+\.\d+\.\d+)["\'@]{1}'), + re.compile(r'javet[\-\w$]*:(?P\d+\.\d+\.\d+)["\'@]{1}'), re.compile(r'version: \'(?P\d+\.\d+\.\d+)\'')) self._update( 'android/pom.xml', '\n', @@ -189,7 +189,7 @@ def _update(self, relative_file_path: str, line_separator: str, *patterns: list) logging.info(' Updated.') def main(): - change_javet_version = ChangeJavetVersion('4.1.0') + change_javet_version = ChangeJavetVersion('4.1.1') 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 b5468fb1..ffd3fb8c 100644 --- a/scripts/python/change_node_v8_version.py +++ b/scripts/python/change_node_v8_version.py @@ -170,9 +170,9 @@ def update(self) -> None: re.compile(r'"(?P\d+\.\d+\.\d+\.\d+)",')) def main(): - change_node_version = ChangeNodeVersion('22.11.0') + change_node_version = ChangeNodeVersion('22.12.0') change_node_version.update() - change_v8_version = ChangeV8Version('13.1.201.8') + change_v8_version = ChangeV8Version('13.2.152.16') change_v8_version.update() return 0 diff --git a/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java b/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java index 206dd398..91d588fc 100644 --- a/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java +++ b/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java @@ -60,7 +60,7 @@ public enum JSRuntimeType { V8( "v8", false, - "13.1.201.8", + "13.2.152.16", V8RuntimeOptions::new, o -> o instanceof V8RuntimeOptions), /** @@ -71,7 +71,7 @@ public enum JSRuntimeType { V8I18n( "v8", true, - "13.1.201.8", + "13.2.152.16", V8RuntimeOptions::new, o -> o instanceof V8RuntimeOptions); diff --git a/src/main/java/com/caoccao/javet/interop/NodeRuntime.java b/src/main/java/com/caoccao/javet/interop/NodeRuntime.java index e5b0bd39..6378bff4 100644 --- a/src/main/java/com/caoccao/javet/interop/NodeRuntime.java +++ b/src/main/java/com/caoccao/javet/interop/NodeRuntime.java @@ -134,9 +134,7 @@ public Module getNodeModule( if (nodeModuleClass == NodeModuleProcess.class) { moduleObject = getGlobalObject().get(name); } else { - try (V8ValueFunction requireFunction = getGlobalObject().get(FUNCTION_REQUIRE)) { - moduleObject = requireFunction.call(null, name); - } + moduleObject = getGlobalObject().invoke(FUNCTION_REQUIRE, name); } try { Constructor constructor = nodeModuleClass.getConstructor( diff --git a/src/main/java/com/caoccao/javet/interop/V8Runtime.java b/src/main/java/com/caoccao/javet/interop/V8Runtime.java index d7994418..1a24b657 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Runtime.java +++ b/src/main/java/com/caoccao/javet/interop/V8Runtime.java @@ -1689,9 +1689,12 @@ public V8Locker getV8Locker() throws JavetException { @CheckReturnValue IV8Module getV8Module(String resourceName, IV8Module v8ModuleReferrer) throws JavetException { IV8Module iV8Module = null; - if (!StringUtils.isEmpty(resourceName)) { + String absoluteResourceName = v8ModuleResolver == null + ? resourceName + : v8ModuleResolver.getAbsoluteResourceName(this, resourceName, v8ModuleReferrer); + if (!StringUtils.isEmpty(absoluteResourceName)) { synchronized (v8ModuleLock) { - iV8Module = v8ModuleMap.get(resourceName); + iV8Module = v8ModuleMap.get(absoluteResourceName); } if (iV8Module == null && v8ModuleResolver != null) { iV8Module = v8ModuleResolver.resolve(this, resourceName, v8ModuleReferrer); 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 84e713fb..698de7c7 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/IV8ModuleResolver.java +++ b/src/main/java/com/caoccao/javet/interop/callback/IV8ModuleResolver.java @@ -26,6 +26,24 @@ * @since 0.9.3 */ public interface IV8ModuleResolver { + /** + * Gets absolute resource name that is used as a key of the internal V8 module cache. + * + * @param v8Runtime the V8 runtime + * @param resourceName the resource name + * @param v8ModuleReferrer the V8 module referrer + * @return the absolute resource name + * @throws JavetException the javet exception + * @since 4.1.1 + */ + default String getAbsoluteResourceName( + V8Runtime v8Runtime, + String resourceName, + IV8Module v8ModuleReferrer) + throws JavetException { + return resourceName; + } + /** * Resolve V8 module. * @@ -36,5 +54,9 @@ public interface IV8ModuleResolver { * @throws JavetException the javet exception * @since 0.9.3 */ - IV8Module resolve(V8Runtime v8Runtime, String resourceName, IV8Module v8ModuleReferrer) throws JavetException; + IV8Module resolve( + V8Runtime v8Runtime, + String resourceName, + IV8Module v8ModuleReferrer) + throws JavetException; } 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 79787ecf..035857b8 100644 --- a/src/main/java/com/caoccao/javet/interop/callback/JavetBuiltInModuleResolver.java +++ b/src/main/java/com/caoccao/javet/interop/callback/JavetBuiltInModuleResolver.java @@ -20,6 +20,7 @@ import com.caoccao.javet.interop.NodeRuntime; import com.caoccao.javet.interop.V8Runtime; import com.caoccao.javet.node.modules.NodeModuleAny; +import com.caoccao.javet.utils.StringUtils; import com.caoccao.javet.values.reference.IV8Module; import com.caoccao.javet.values.reference.V8ValueObject; @@ -48,7 +49,9 @@ public IV8Module resolve(V8Runtime v8Runtime, String resourceName, IV8Module v8M throws JavetException { IV8Module iV8Module = null; // It only works for Node.js runtime and module names starting with "node:". - if (v8Runtime.getJSRuntimeType().isNode() && resourceName != null && resourceName.startsWith(PREFIX_NODE)) { + if (v8Runtime.getJSRuntimeType().isNode() + && StringUtils.isNotEmpty(resourceName) + && resourceName.startsWith(PREFIX_NODE)) { NodeRuntime nodeRuntime = (NodeRuntime) v8Runtime; NodeModuleAny nodeModuleAny = nodeRuntime.getNodeModule(resourceName, NodeModuleAny.class); V8ValueObject v8ValueObject = nodeModuleAny.getModuleObject(); 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 1fe4430b..f20a088e 100644 --- a/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoader.java +++ b/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoader.java @@ -45,7 +45,7 @@ public final class JavetLibLoader { * * @since 0.8.0 */ - public static final String LIB_VERSION = "4.1.0"; + public static final String LIB_VERSION = "4.1.1"; 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"; diff --git a/src/main/java/com/caoccao/javet/interop/options/NodeFlags.java b/src/main/java/com/caoccao/javet/interop/options/NodeFlags.java index 0af23132..fb782b1a 100644 --- a/src/main/java/com/caoccao/javet/interop/options/NodeFlags.java +++ b/src/main/java/com/caoccao/javet/interop/options/NodeFlags.java @@ -50,11 +50,11 @@ public final class NodeFlags { */ public static final String EXPERIMENTAL_PERMISSION = "--experimental-permission"; /** - * The constant EXPERIMENTAL_REQUIRE_MODULE. + * The constant NO_EXPERIMENTAL_REQUIRE_MODULE. * - * @since 4.0.0 + * @since 4.1.1 */ - public static final String EXPERIMENTAL_REQUIRE_MODULE = "--experimental-require-module"; + public static final String NO_EXPERIMENTAL_REQUIRE_MODULE = "--no-experimental-require-module"; /** * The constant EXPERIMENTAL_SQLITE. * @@ -85,10 +85,10 @@ public final class NodeFlags { private String[] allowFsWrite; private String[] customFlags; private boolean experimentalPermission; - private boolean experimentalRequireModule; private boolean experimentalSqlite; private String icuDataDir; private boolean jsFloat16Array; + private boolean noExperimentalRequireModule; private boolean noWarnings; private boolean sealed; @@ -102,7 +102,7 @@ public final class NodeFlags { allowFsWrite = null; customFlags = null; experimentalPermission = false; - experimentalRequireModule = false; + noExperimentalRequireModule = false; experimentalSqlite = false; jsFloat16Array = false; noWarnings = false; @@ -176,16 +176,6 @@ public boolean isExperimentalPermission() { return experimentalPermission; } - /** - * Supports loading a synchronous ES module graph in require(). - * - * @return true : yes, false: no - * @since 4.0.0 - */ - public boolean isExperimentalRequireModule() { - return experimentalRequireModule; - } - /** * Is the experimental node:sqlite module enabled. * @@ -206,6 +196,16 @@ public boolean isJsFloat16Array() { return jsFloat16Array; } + /** + * Does not support loading a synchronous ES module graph in require(). + * + * @return true : yes, false: no + * @since 4.1.1 + */ + public boolean isNoExperimentalRequireModule() { + return noExperimentalRequireModule; + } + /** * Silence all process warnings (including deprecations). * @@ -315,20 +315,6 @@ public NodeFlags setExperimentalPermission(boolean experimentalPermission) { return this; } - /** - * Sets experimental require module. - * - * @param experimentalRequireModule the experimental require module - * @return the self - * @since 4.0.0 - */ - public NodeFlags setExperimentalRequireModule(boolean experimentalRequireModule) { - if (!sealed) { - this.experimentalRequireModule = experimentalRequireModule; - } - return this; - } - /** * Sets experimental sqlite. * @@ -371,6 +357,20 @@ public NodeFlags setJsFloat16Array(boolean jsFloat16Array) { return this; } + /** + * Sets no experimental require module. + * + * @param noExperimentalRequireModule the no experimental require module + * @return the self + * @since 4.1.1 + */ + public NodeFlags setNoExperimentalRequireModule(boolean noExperimentalRequireModule) { + if (!sealed) { + this.noExperimentalRequireModule = noExperimentalRequireModule; + } + return this; + } + /** * Sets no warnings. * @@ -407,8 +407,8 @@ public String[] toArray() { if (experimentalPermission) { tokens.add(EXPERIMENTAL_PERMISSION); } - if (experimentalRequireModule) { - tokens.add(EXPERIMENTAL_REQUIRE_MODULE); + if (noExperimentalRequireModule) { + tokens.add(NO_EXPERIMENTAL_REQUIRE_MODULE); } if (experimentalSqlite) { tokens.add(EXPERIMENTAL_SQLITE); 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 4ee2ed43..ed7c9ea9 100644 --- a/src/main/java/com/caoccao/javet/values/reference/V8Script.java +++ b/src/main/java/com/caoccao/javet/values/reference/V8Script.java @@ -63,7 +63,7 @@ public byte[] getCachedData() throws JavetException { @Override public String getResourceName() throws JavetException { if (resourceName == null) { - return checkV8Runtime().getV8Internal().scriptGetResourceName(this); + resourceName = checkV8Runtime().getV8Internal().scriptGetResourceName(this); } return resourceName; } diff --git a/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java b/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java index 89cd8bd5..b92aab45 100644 --- a/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java +++ b/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java @@ -212,7 +212,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("v22.11.0", nodeModuleProcess.getVersion()); + assertEquals("v22.12.0", nodeModuleProcess.getVersion()); } @Test diff --git a/src/test/java/com/caoccao/javet/interop/options/TestNodeFlags.java b/src/test/java/com/caoccao/javet/interop/options/TestNodeFlags.java index 9dc7b9a7..398b285a 100644 --- a/src/test/java/com/caoccao/javet/interop/options/TestNodeFlags.java +++ b/src/test/java/com/caoccao/javet/interop/options/TestNodeFlags.java @@ -27,9 +27,9 @@ public class TestNodeFlags { protected static final List SWITCHES = SimpleList.of( - new GetterAndSetter(NodeFlags::isExperimentalRequireModule, NodeFlags::setExperimentalRequireModule), new GetterAndSetter(NodeFlags::isExperimentalSqlite, NodeFlags::setExperimentalSqlite), new GetterAndSetter(NodeFlags::isJsFloat16Array, NodeFlags::setJsFloat16Array), + new GetterAndSetter(NodeFlags::isNoExperimentalRequireModule, NodeFlags::setNoExperimentalRequireModule), new GetterAndSetter(NodeFlags::isNoWarnings, NodeFlags::setNoWarnings) ); @@ -81,9 +81,9 @@ public void testToString() { assertEquals("--no-warnings", nodeFlags.setNoWarnings(true).toString()); nodeFlags.setNoWarnings(false); assertEquals( - "--experimental-require-module", - nodeFlags.setExperimentalRequireModule(true).toString()); - nodeFlags.setExperimentalRequireModule(false); + "--no-experimental-require-module", + nodeFlags.setNoExperimentalRequireModule(true).toString()); + nodeFlags.setNoExperimentalRequireModule(false); assertEquals("--icu-data-dir=abc", nodeFlags.setIcuDataDir("abc").toString()); nodeFlags.setIcuDataDir(null); assertEquals(