diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml index defc45b7a..d2b609b64 100644 --- a/.github/workflows/android_build.yml +++ b/.github/workflows/android_build.yml @@ -8,9 +8,9 @@ on: workflow_dispatch: env: - JAVET_NODE_VERSION: 18.17.1 - JAVET_V8_VERSION: 11.7.439.16 - JAVET_VERSION: 2.2.3 + JAVET_NODE_VERSION: 20.8.0 + JAVET_V8_VERSION: 11.8.172.15 + JAVET_VERSION: 3.0.0 ROOT: /home/runner/work/Javet jobs: diff --git a/.github/workflows/linux_build.yml b/.github/workflows/linux_build.yml index ece88575c..93ca6ec5c 100644 --- a/.github/workflows/linux_build.yml +++ b/.github/workflows/linux_build.yml @@ -7,9 +7,9 @@ on: workflow_dispatch: env: - JAVET_NODE_VERSION: 18.17.1 - JAVET_V8_VERSION: 11.7.439.16 - JAVET_VERSION: 2.2.3 + JAVET_NODE_VERSION: 20.8.0 + JAVET_V8_VERSION: 11.8.172.15 + JAVET_VERSION: 3.0.0 ROOT: /home/runner/work/Javet jobs: diff --git a/.github/workflows/linux_build_artifact.yml b/.github/workflows/linux_build_artifact.yml index 0898d177c..59c4e9e3e 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: 18.17.1 - JAVET_V8_VERSION: 11.7.439.16 - JAVET_VERSION: 2.2.3 + JAVET_NODE_VERSION: 20.8.0 + JAVET_V8_VERSION: 11.8.172.15 + JAVET_VERSION: 3.0.0 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 576a85d1a..59aa16c69 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: 18.17.1 - JAVET_V8_VERSION: 11.7.439.16 - JAVET_VERSION: 2.2.3 + JAVET_NODE_VERSION: 20.8.0 + JAVET_V8_VERSION: 11.8.172.15 + JAVET_VERSION: 3.0.0 # 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/macos_build.yml b/.github/workflows/macos_build.yml index d673e2dc6..7193901af 100644 --- a/.github/workflows/macos_build.yml +++ b/.github/workflows/macos_build.yml @@ -7,9 +7,9 @@ on: workflow_dispatch: env: - JAVET_NODE_VERSION: 18.17.1 - JAVET_V8_VERSION: 11.7.439.16 - JAVET_VERSION: 2.2.3 + JAVET_NODE_VERSION: 20.8.0 + JAVET_V8_VERSION: 11.8.172.15 + JAVET_VERSION: 3.0.0 ROOT: /Users/runner/work/Javet jobs: diff --git a/README.rst b/README.rst index be350012a..645a4197f 100644 --- a/README.rst +++ b/README.rst @@ -32,9 +32,16 @@ If you like my work, please **Star** this project. And, you may follow me `@sjtu Major Features ============== -* Linux (x86_64) + Mac OS (x86_64, arm64) + ️Windows (x86_64) -* Android (arm, arm64, x86 and x86_64) -* Node.js ``v18.17.1`` + V8 ``v11.7.439.16`` +=========== ======= ======= ======= ======= +CPU Arch Android Linux MacOS Windows +=========== ======= ======= ======= ======= +x86 ✔ ❌ ❌ ❌ +x86_64 ✔ ✔ ✔ ✔ +arm ✔ ❌ ❌ ❌ +arm64 ✔ ✔ ✔ ❌ +=========== ======= ======= ======= ======= + +* Node.js ``v20.8.0`` + V8 ``v11.8.172.15`` * Dynamic switch between Node.js and V8 mode (`Which mode do you prefer? `_) * Polyfill V8 mode with `Javenode `_ * V8 API exposure in JVM @@ -59,14 +66,21 @@ Maven com.caoccao.javet javet - 2.2.3 + 3.0.0 + + + + + com.caoccao.javet + javet-linux-arm64 + 3.0.0 com.caoccao.javet javet-macos - 2.2.3 + 3.0.0 Gradle Kotlin DSL @@ -74,18 +88,20 @@ Gradle Kotlin DSL .. code-block:: kotlin - implementation("com.caoccao.javet:javet:2.2.3") // Linux and Windows (x86_64) - implementation("com.caoccao.javet:javet-macos:2.2.3") // Mac OS (x86_64 and arm64) - implementation("com.caoccao.javet:javet-android:2.2.3") // Android (arm, arm64, x86 and x86_64) + implementation("com.caoccao.javet:javet:3.0.0") // Linux and Windows (x86_64) + implementation("com.caoccao.javet:javet-linux-arm64:3.0.0") // Linux (arm64) + implementation("com.caoccao.javet:javet-macos:3.0.0") // Mac OS (x86_64 and arm64) + implementation("com.caoccao.javet:javet-android:3.0.0") // Android (arm, arm64, x86 and x86_64) Gradle Groovy DSL ^^^^^^^^^^^^^^^^^ .. code-block:: groovy - implementation 'com.caoccao.javet:javet:2.2.3' // Linux and Windows (x86_64) - implementation 'com.caoccao.javet:javet-macos:2.2.3' // Mac OS (x86_64 and arm64) - implementation 'com.caoccao.javet:javet-android:2.2.3' // Android (arm, arm64, x86 and x86_64) + implementation 'com.caoccao.javet:javet:3.0.0' // Linux and Windows (x86_64) + implementation 'com.caoccao.javet:javet-linux-arm64:3.0.0' // Linux (arm64) + implementation 'com.caoccao.javet:javet-macos:3.0.0' // Mac OS (x86_64 and arm64) + implementation 'com.caoccao.javet:javet-android:3.0.0' // Android (arm, arm64, x86 and x86_64) Hello Javet ----------- @@ -102,6 +118,11 @@ Hello Javet System.out.println(v8Runtime.getExecutor("'Hello Javet'").executeString()); } +Sponsors +======== + +`HiveMQ `_ + License ======= @@ -111,5 +132,6 @@ Documents ========= * `Javet Intro `_ +* `Performance Comparison of GraalJS, Javet and Nashorn `_ * `Javet Javadoc `_ * `Javet Document Portal `_ diff --git a/android/javet-android/build.gradle.kts b/android/javet-android/build.gradle.kts index c55569f60..6b5867225 100644 --- a/android/javet-android/build.gradle.kts +++ b/android/javet-android/build.gradle.kts @@ -21,7 +21,7 @@ plugins { id("com.android.library") } -version = "2.2.3" +version = "3.0.0" android { compileSdk = 30 diff --git a/android/javet-android/src/main/AndroidManifest.xml b/android/javet-android/src/main/AndroidManifest.xml index 6ee23af7c..0e560ce5d 100644 --- a/android/javet-android/src/main/AndroidManifest.xml +++ b/android/javet-android/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ \ No newline at end of file diff --git a/android/pom.xml b/android/pom.xml index d9c5feb66..349bf20d7 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -3,7 +3,7 @@ com.caoccao.javet javet-android - 2.2.3 + 3.0.0 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 - 2.2.3 + 3.0.0 diff --git a/build.gradle.kts b/build.gradle.kts index 5a63fcaed..1ea619ca3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,7 +25,7 @@ repositories { } group = "com.caoccao.javet" -version = "2.2.3" +version = "3.0.0" dependencies { testImplementation("org.eclipse.jetty.websocket:websocket-server:9.4.49.v20220914") diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index b484e483b..70d5d3eef 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -116,7 +116,7 @@ if(DEFINED NODE_DIR) list(APPEND importLibraries ada base64 brotli cares histogram llhttp nghttp2 nghttp3 ngtcp2 openssl simdutf torque_base uvwasi v8_base_without_compiler v8_compiler v8_init v8_initializers - v8_libbase v8_libplatform v8_snapshot v8_zlib zlib zlib_adler32_simd zlib_inflate_chunk_simd) + v8_libbase v8_libplatform v8_snapshot v8_turboshaft v8_zlib zlib zlib_adler32_simd zlib_inflate_chunk_simd) if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "(arm64|aarch64)") list(APPEND importLibraries base64_neon64) else() @@ -135,8 +135,8 @@ if(DEFINED NODE_DIR) list(APPEND importLibraries zlib_arm_crc32) elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "(arm64|aarch64)") list(APPEND importLibraries zlib_arm_crc32) - else() - list(APPEND importLibraries zlib_crc32_simd) + # else() + # list(APPEND importLibraries zlib_crc32_simd) endif() add_definitions(-DENABLE_NODE) set(JAVET_LIB_TYPE "node") diff --git a/cpp/build-android.sh b/cpp/build-android.sh index 8448c14e5..5e12947a0 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=2.2.3 +JAVET_VERSION=3.0.0 rm -rf build mkdir build cd build diff --git a/cpp/build-linux.sh b/cpp/build-linux.sh index 27eda4fad..e11041c53 100755 --- a/cpp/build-linux.sh +++ b/cpp/build-linux.sh @@ -2,7 +2,7 @@ # Usage for V8: sh build-linux.sh -DV8_DIR=${HOME}/v8 # Usage for Node: sh build-linux.sh -DNODE_DIR=${HOME}/node -JAVET_VERSION=2.2.3 +JAVET_VERSION=3.0.0 rm -rf build mkdir build cd build diff --git a/cpp/build-macos.sh b/cpp/build-macos.sh index 2104da3b2..15a58286d 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=2.2.3 +JAVET_VERSION=3.0.0 rm -rf build mkdir build cd build diff --git a/cpp/build-windows.cmd b/cpp/build-windows.cmd index bcc2fc8a4..d2725b529 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=2.2.3 +SET JAVET_VERSION=3.0.0 rd /s/q build mkdir build cd build diff --git a/cpp/jni/com_caoccao_javet_interop_V8Native.h b/cpp/jni/com_caoccao_javet_interop_V8Native.h index aa8ec1621..b4f479e92 100644 --- a/cpp/jni/com_caoccao_javet_interop_V8Native.h +++ b/cpp/jni/com_caoccao_javet_interop_V8Native.h @@ -1090,10 +1090,10 @@ JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_removeJNIGlobalRe /* * Class: com_caoccao_javet_interop_V8Native * Method: removeReferenceHandle - * Signature: (JI)V + * Signature: (JJI)V */ JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_removeReferenceHandle - (JNIEnv *, jobject, jlong, jint); + (JNIEnv *, jobject, jlong, jlong, jint); /* * Class: com_caoccao_javet_interop_V8Native diff --git a/cpp/jni/javet_inspector.cpp b/cpp/jni/javet_inspector.cpp index 87a9acc9f..6c53d6323 100644 --- a/cpp/jni/javet_inspector.cpp +++ b/cpp/jni/javet_inspector.cpp @@ -100,18 +100,11 @@ namespace Javet { auto v8Context = v8Runtime->GetV8LocalContext(); javetInspectorChannel.reset(new JavetInspectorChannel(v8Runtime, mV8Inspector)); v8Inspector.reset(v8_inspector::V8Inspector::create(v8Runtime->v8Isolate, this).release()); -#ifdef ENABLE_NODE - v8InspectorSession.reset(v8Inspector->connect( - CONTEXT_GROUP_ID, - javetInspectorChannel.get(), - v8_inspector::StringView()).release()); -#else v8InspectorSession.reset(v8Inspector->connect( CONTEXT_GROUP_ID, javetInspectorChannel.get(), v8_inspector::StringView(), v8_inspector::V8Inspector::kFullyTrusted).release()); -#endif v8Context->SetAlignedPointerInEmbedderData(EMBEDDER_DATA_INDEX, this); auto humanReadableNamePointer = ConvertFromStdStringToStringViewPointer(name); v8Inspector->contextCreated(v8_inspector::V8ContextInfo(v8Context, CONTEXT_GROUP_ID, *humanReadableNamePointer.get())); diff --git a/cpp/jni/javet_jni_core_v8.cpp b/cpp/jni/javet_jni_core_v8.cpp index 130f18f04..d638eedc7 100644 --- a/cpp/jni/javet_jni_core_v8.cpp +++ b/cpp/jni/javet_jni_core_v8.cpp @@ -17,11 +17,11 @@ #include "javet_jni.h" - /* - * Development Guide: - * 1. Omitting namespace is not recommended in this project. - * 2. Methods are expected to be sorted alphabatically except JNI_OnLoad. - */ +/* + * Development Guide: + * 1. Omitting namespace is not recommended in this project. + * 2. Methods are expected to be sorted alphabatically except JNI_OnLoad. + */ JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_allowCodeGenerationFromStrings (JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jboolean allow) { @@ -333,7 +333,9 @@ JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_removeJNIGlobalRe } JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_removeReferenceHandle -(JNIEnv* jniEnv, jobject caller, jlong referenceHandle, jint referenceType) { +(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong referenceHandle, jint referenceType) { + auto v8Runtime = Javet::V8Runtime::FromHandle(v8RuntimeHandle); + auto v8Locker = v8Runtime->GetSharedV8Locker(); auto v8PersistentDataPointer = TO_V8_PERSISTENT_DATA_POINTER(referenceHandle); v8PersistentDataPointer->Reset(); delete v8PersistentDataPointer; diff --git a/cpp/jni/javet_jni_function.cpp b/cpp/jni/javet_jni_function.cpp index 888c4b57a..347f633fc 100644 --- a/cpp/jni/javet_jni_function.cpp +++ b/cpp/jni/javet_jni_function.cpp @@ -71,7 +71,11 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionCanDi RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); if (IS_V8_FUNCTION(v8ValueType)) { auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) { return v8InternalShared.CanDiscardCompiled(); } @@ -143,8 +147,13 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionCopyS auto sourceV8LocalValue = sourceV8PersistentValuePointer->Get(v8Context->GetIsolate()); auto targetV8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); auto sourceV8InternalFunction = Javet::Converter::ToV8InternalJSFunction(sourceV8LocalValue); +#ifdef ENABLE_NODE auto targetV8InternalShared = targetV8InternalFunction.shared(); auto sourceV8InternalShared = sourceV8InternalFunction.shared(); +#else + auto targetV8InternalShared = *targetV8InternalFunction.shared(); + auto sourceV8InternalShared = *sourceV8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(sourceV8InternalShared) && IS_USER_DEFINED_FUNCTION(targetV8InternalShared)) { V8InternalDisallowGarbageCollection disallowGarbageCollection; auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); @@ -200,7 +209,11 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionDisca RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); if (IS_V8_FUNCTION(v8ValueType)) { auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) { if (v8InternalShared.CanDiscardCompiled()) { auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); @@ -217,11 +230,20 @@ JNIEXPORT jobjectArray JNICALL Java_com_caoccao_javet_interop_V8Native_functionG RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); if (IS_V8_FUNCTION(v8ValueType)) { auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared) && v8InternalShared.is_wrapped()) { auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); +#ifdef ENABLE_NODE auto v8InternalScript = V8InternalScript::cast(v8InternalShared.script()); auto wrappedArguments = v8InternalScript.wrapped_arguments(); +#else + auto v8InternalScript = *V8InternalScript::cast(v8InternalShared.script()); + auto wrappedArguments = *v8InternalScript.wrapped_arguments(); +#endif auto length = wrappedArguments.length(); if (length > 0) { jobjectArray arguments = jniEnv->NewObjectArray(length, Javet::Converter::jclassString, nullptr); @@ -243,9 +265,17 @@ JNIEXPORT jbyteArray JNICALL Java_com_caoccao_javet_interop_V8Native_functionGet if (IS_V8_FUNCTION(v8ValueType)) { RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) { +#ifdef ENABLE_NODE auto v8InternalScript = V8InternalScript::cast(v8InternalShared.script()); +#else + auto v8InternalScript = *V8InternalScript::cast(v8InternalShared.script()); +#endif if (v8InternalScript.is_wrapped()) { V8TryCatch v8TryCatch(v8Context->GetIsolate()); std::unique_ptr cachedDataPointer; @@ -303,7 +333,11 @@ JNIEXPORT jint JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetJSFunc using namespace Javet::Enums::JSFunctionType; if (IS_V8_FUNCTION(v8ValueType)) { auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (v8InternalShared.native()) { return JSFunctionType::Native; } @@ -322,8 +356,13 @@ JNIEXPORT jint JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetJSScop RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); if (IS_V8_FUNCTION(v8ValueType)) { auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); auto v8InternalScopeInfo = v8InternalShared.scope_info(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); + auto v8InternalScopeInfo = *v8InternalShared.scope_info(); +#endif return v8InternalScopeInfo.scope_type(); } return Javet::Enums::JSScopeType::Unknown; @@ -338,8 +377,13 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetSco V8InternalDisallowGarbageCollection disallowGarbageCollection; auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); auto v8InternalScopeInfo = v8InternalShared.scope_info(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); + auto v8InternalScopeInfo = *v8InternalShared.scope_info(); +#endif V8InternalScopeIterator scopeIterator(v8InternalIsolate, v8::internal::handle(v8InternalFunction, v8InternalIsolate)); uint32_t index = 0; for (; !scopeIterator.Done(); scopeIterator.Next()) { @@ -369,10 +413,19 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetScr if (IS_V8_FUNCTION(v8ValueType)) { V8InternalDisallowGarbageCollection disallowGarbageCollection; auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) { +#ifdef ENABLE_NODE auto v8InternalScript = V8InternalScript::cast(v8InternalShared.script()); auto v8InternalSource = V8InternalString::cast(v8InternalScript.source()); +#else + auto v8InternalScript = *V8InternalScript::cast(v8InternalShared.script()); + auto v8InternalSource = *V8InternalString::cast(v8InternalScript.source()); +#endif const int startPosition = v8InternalShared.StartPosition(); const int endPosition = v8InternalShared.EndPosition(); const int sourceLength = v8InternalSource.length(); @@ -395,10 +448,19 @@ JNIEXPORT jstring JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetSou RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); if (IS_V8_FUNCTION(v8ValueType)) { auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) { +#ifdef ENABLE_NODE auto v8InternalScript = V8InternalScript::cast(v8InternalShared.script()); auto v8InternalSource = V8InternalString::cast(v8InternalScript.source()); +#else + auto v8InternalScript = *V8InternalScript::cast(v8InternalShared.script()); + auto v8InternalSource = *V8InternalString::cast(v8InternalScript.source()); +#endif const int startPosition = v8InternalShared.StartPosition(); const int endPosition = v8InternalShared.EndPosition(); auto sourceCode = v8InternalSource.ToCString( @@ -415,7 +477,11 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionIsCom RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); if (IS_V8_FUNCTION(v8ValueType)) { auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) { return v8InternalShared.is_compiled(); } @@ -428,7 +494,11 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionIsWra RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle); if (IS_V8_FUNCTION(v8ValueType)) { auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) { return v8InternalShared.is_wrapped(); } @@ -458,16 +528,28 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetSc if (IS_V8_FUNCTION(v8ValueType)) { V8InternalDisallowGarbageCollection disallowGarbageCollection; auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) { +#ifdef ENABLE_NODE auto v8InternalScopeInfo = v8InternalShared.scope_info(); +#else + auto v8InternalScopeInfo = *v8InternalShared.scope_info(); +#endif if (v8InternalScopeInfo.scope_type() == V8InternalScopeType::FUNCTION_SCOPE) { auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); auto mSourceCode = (jstring)jniEnv->CallObjectMethod(mScriptSource, Javet::Converter::jmethodIDIV8ValueFunctionScriptGetCode); auto umSourceCode = Javet::Converter::ToV8String(jniEnv, v8Context, mSourceCode); const int startPosition = jniEnv->CallIntMethod(mScriptSource, Javet::Converter::jmethodIDIV8ValueFunctionScriptGetStartPosition); const int endPosition = jniEnv->CallIntMethod(mScriptSource, Javet::Converter::jmethodIDIV8ValueFunctionScriptGetEndPosition); +#ifdef ENABLE_NODE auto v8InternalScript = V8InternalScript::cast(v8InternalShared.script()); +#else + auto v8InternalScript = *V8InternalScript::cast(v8InternalShared.script()); +#endif auto v8InternalSource = v8::Utils::OpenHandle(*umSourceCode); #ifdef ENABLE_NODE bool sourceCodeEquals = v8InternalScript.source().StrictEquals(*v8InternalSource); @@ -519,13 +601,26 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetSo if (IS_V8_FUNCTION(v8ValueType)) { V8InternalDisallowGarbageCollection disallowGarbageCollection; auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue); +#ifdef ENABLE_NODE auto v8InternalShared = v8InternalFunction.shared(); +#else + auto v8InternalShared = *v8InternalFunction.shared(); +#endif if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) { +#ifdef ENABLE_NODE auto v8InternalScopeInfo = v8InternalShared.scope_info(); +#else + auto v8InternalScopeInfo = *v8InternalShared.scope_info(); +#endif while (v8InternalScopeInfo.scope_type() == V8InternalScopeType::FUNCTION_SCOPE) { auto v8InternalIsolate = reinterpret_cast(v8Context->GetIsolate()); +#ifdef ENABLE_NODE auto v8InternalScript = V8InternalScript::cast(v8InternalShared.script()); auto v8InternalSource = V8InternalString::cast(v8InternalScript.source()); +#else + auto v8InternalScript = *V8InternalScript::cast(v8InternalShared.script()); + auto v8InternalSource = *V8InternalString::cast(v8InternalScript.source()); +#endif const int startPosition = v8InternalShared.StartPosition(); const int endPosition = v8InternalShared.EndPosition(); const int sourceLength = v8InternalSource.length(); diff --git a/cpp/jni/javet_native.cpp b/cpp/jni/javet_native.cpp index a02dd51ab..4fde233b0 100644 --- a/cpp/jni/javet_native.cpp +++ b/cpp/jni/javet_native.cpp @@ -107,13 +107,13 @@ namespace Javet { jmethodID jmethodIDV8HostIsLibraryReloadable; void Dispose(JNIEnv* jniEnv) noexcept { +#ifdef ENABLE_NODE + LOG_INFO("Calling cppgc::ShutdownProcess()."); + cppgc::ShutdownProcess(); +#endif if (!jniEnv->CallStaticBooleanMethod(jclassV8Host, jmethodIDV8HostIsLibraryReloadable)) { v8::V8::Dispose(); -#ifdef ENABLE_NODE - v8::V8::ShutdownPlatform(); -#else v8::V8::DisposePlatform(); -#endif GlobalV8Platform.reset(); } } @@ -129,6 +129,7 @@ namespace Javet { LOG_INFO("V8::Initialize() begins."); #ifdef ENABLE_I18N + LOG_INFO("Calling v8::V8::InitializeICU()."); v8::V8::InitializeICU(); #endif if (Javet::V8Native::GlobalV8Platform) { @@ -140,7 +141,12 @@ namespace Javet { std::vector args{ DEFAULT_SCRIPT_NAME }; std::vector execArgs; std::vector errors; - int exitCode = node::InitializeNodeWithArgs(&args, &execArgs, &errors); + auto flags = static_cast( + node::ProcessInitializationFlags::kNoFlags + | node::ProcessInitializationFlags::kNoInitializeV8 + | node::ProcessInitializationFlags::kNoInitializeNodeV8Platform + | node::ProcessInitializationFlags::kNoInitializeCppgc); + int exitCode = node::InitializeNodeWithArgs(&args, &execArgs, &errors, flags); if (exitCode != 0) { LOG_ERROR("Failed to call node::InitializeNodeWithArgs()."); } @@ -151,6 +157,11 @@ namespace Javet { v8::V8::InitializePlatform(Javet::V8Native::GlobalV8Platform.get()); v8::V8::Initialize(); } +#ifdef ENABLE_NODE + auto pageAllocator = Javet::V8Native::GlobalV8Platform->GetPageAllocator(); + LOG_INFO("Calling cppgc::InitializeProcess()."); + cppgc::InitializeProcess(pageAllocator); +#endif LOG_INFO("V8::Initialize() ends."); } } diff --git a/cpp/jni/javet_node.h b/cpp/jni/javet_node.h index bd2b4995e..ddde35db5 100644 --- a/cpp/jni/javet_node.h +++ b/cpp/jni/javet_node.h @@ -19,9 +19,11 @@ #ifdef ENABLE_NODE +#pragma warning(disable: 4244) #pragma warning(disable: 4251) #pragma warning(disable: 4267) #pragma warning(disable: 4275) +#pragma warning(disable: 4819) #define NODE_WANT_INTERNALS 1 #include #include @@ -49,9 +51,11 @@ #undef DCHECK_NULL #undef UNREACHABLE // Hack Ends +#pragma warning(default: 4244) #pragma warning(default: 4251) #pragma warning(default: 4267) #pragma warning(default: 4275) +#pragma warning(default: 4819) #ifdef _WIN32 #pragma comment(lib, "Crypt32.lib") diff --git a/cpp/jni/javet_resource_node.rc b/cpp/jni/javet_resource_node.rc index d2057bb17..e86b11691 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 2,2,3,0 - PRODUCTVERSION 2,2,3,0 + FILEVERSION 3,0,0,0 + PRODUCTVERSION 3,0,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -79,12 +79,12 @@ BEGIN BEGIN VALUE "CompanyName", "caoccao.com" VALUE "FileDescription", "caoccao.com" - VALUE "FileVersion", "2.2.3.0" - VALUE "InternalName", "libjavet-node-windows-x86_64.v.2.2.3.dll" - VALUE "LegalCopyright", "Copyright (C) 2021" - VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.2.2.3.dll" + VALUE "FileVersion", "3.0.0.0" + VALUE "InternalName", "libjavet-node-windows-x86_64.v.3.0.0.dll" + VALUE "LegalCopyright", "Copyright (C) 2021-2023" + VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.3.0.0.dll" VALUE "ProductName", "Javet Windows" - VALUE "ProductVersion", "2.2.3.0" + VALUE "ProductVersion", "3.0.0.0" END END BLOCK "VarFileInfo" diff --git a/cpp/jni/javet_resource_v8.rc b/cpp/jni/javet_resource_v8.rc index bb83cc9a1..607e0f1d8 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 2,2,3,0 - PRODUCTVERSION 2,2,3,0 + FILEVERSION 3,0,0,0 + PRODUCTVERSION 3,0,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -79,12 +79,12 @@ BEGIN BEGIN VALUE "CompanyName", "caoccao.com" VALUE "FileDescription", "caoccao.com" - VALUE "FileVersion", "2.2.3.0" - VALUE "InternalName", "libjavet-v8-windows-x86_64.v.2.2.3.dll" - VALUE "LegalCopyright", "Copyright (C) 2021" - VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.2.2.3.dll" + VALUE "FileVersion", "3.0.0.0" + VALUE "InternalName", "libjavet-v8-windows-x86_64.v.3.0.0.dll" + VALUE "LegalCopyright", "Copyright (C) 2021-2023" + VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.3.0.0.dll" VALUE "ProductName", "Javet Windows" - VALUE "ProductVersion", "2.2.3.0" + VALUE "ProductVersion", "3.0.0.0" END END BLOCK "VarFileInfo" diff --git a/docker/android/base.Dockerfile b/docker/android/base.Dockerfile index f97a4a282..dde3ae715 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:2.2.3 -f docker/android/base.Dockerfile . +# Usage: docker build -t sjtucaocao/javet-android:3.0.0 -f docker/android/base.Dockerfile . -ARG JAVET_V8_VERSION=11.7.439.16 +ARG JAVET_V8_VERSION=11.8.172.15 FROM ubuntu:20.04 WORKDIR / diff --git a/docker/android/build.Dockerfile b/docker/android/build.Dockerfile index 4bc73e5c2..bcc6db3d1 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:2.2.3 +FROM sjtucaocao/javet-android:3.0.0 WORKDIR / # Copy Javet diff --git a/docker/linux-arm64/base_all_in_one.Dockerfile b/docker/linux-arm64/base_all_in_one.Dockerfile index e6164d937..73043da28 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:2.2.3 -f docker/linux-arm64/base_all_in_one.Dockerfile . +# Usage: docker build -t sjtucaocao/javet-arm64:3.0.0 -f docker/linux-arm64/base_all_in_one.Dockerfile . ARG JAVET_NODE_VERSION=18.15.0 -ARG JAVET_V8_VERSION=11.7.439.16 +ARG JAVET_V8_VERSION=11.8.172.15 FROM ubuntu:20.04 WORKDIR / diff --git a/docker/linux-arm64/base_gradle.Dockerfile b/docker/linux-arm64/base_gradle.Dockerfile index d9e9e34c6..0327ca4f9 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-2.2.3 \ +# -t sjtucaocao/javet:arm64-3.0.0 \ # --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 a51def657..8717fc27a 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_11.7.439.16 \ +# -t sjtucaocao/javet:arm64-base-v8_11.8.172.15 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ -# --build-arg JAVET_V8_VERSION=11.7.439.16 \ +# --build-arg JAVET_V8_VERSION=11.8.172.15 \ # -f docker/linux-arm64/base_v8.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet -ARG JAVET_V8_VERSION=11.7.439.16 +ARG JAVET_V8_VERSION=11.8.172.15 FROM ${JAVET_REPO}:arm64-base-jvm diff --git a/docker/linux-arm64/build_artifact.Dockerfile b/docker/linux-arm64/build_artifact.Dockerfile index f57440243..83541cfe6 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=2.2.3 \ +# --build-arg JAVET_VERSION=3.0.0 \ # -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=2.2.3 +ARG JAVET_VERSION=3.0.0 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 2864d60b1..2f9507013 100644 --- a/docker/linux-x86_64/base_all_in_one.Dockerfile +++ b/docker/linux-x86_64/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:2.2.3 -f docker/linux-x86_64/base_all_in_one.Dockerfile . +# Usage: docker build -t sjtucaocao/javet:3.0.0 -f docker/linux-x86_64/base_all_in_one.Dockerfile . -ARG JAVET_NODE_VERSION=18.17.1 -ARG JAVET_V8_VERSION=11.7.439.16 +ARG JAVET_NODE_VERSION=20.8.0 +ARG JAVET_V8_VERSION=11.8.172.15 FROM ubuntu:20.04 WORKDIR / diff --git a/docker/linux-x86_64/base_gradle.Dockerfile b/docker/linux-x86_64/base_gradle.Dockerfile index ca502ceb9..7b6b2cc20 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-2.2.3 \ +# -t sjtucaocao/javet:x86_64-3.0.0 \ # --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 d70f74410..6f3ec482a 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_18.17.1 \ +# -t sjtucaocao/javet:x86_64-base-node_20.8.0 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ -# --build-arg JAVET_NODE_VERSION=18.17.1 \ +# --build-arg JAVET_NODE_VERSION=20.8.0 \ # -f docker/linux-x86_64/base_node.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet -ARG JAVET_NODE_VERSION=18.17.1 +ARG JAVET_NODE_VERSION=20.8.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 b547ddd4a..cb9049a81 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_11.7.439.16 \ +# -t sjtucaocao/javet:x86_64-base-v8_11.8.172.15 \ # --build-arg JAVET_REPO=sjtucaocao/javet \ -# --build-arg JAVET_V8_VERSION=11.7.439.16 \ +# --build-arg JAVET_V8_VERSION=11.8.172.15 \ # -f docker/linux-x86_64/base_v8.Dockerfile . ARG JAVET_REPO=sjtucaocao/javet -ARG JAVET_V8_VERSION=11.7.439.16 +ARG JAVET_V8_VERSION=11.8.172.15 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 ae9012fde..3271dd78a 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:2.2.3 +FROM sjtucaocao/javet:3.0.0 WORKDIR / # Copy Javet diff --git a/docker/linux-x86_64/build_artifact.Dockerfile b/docker/linux-x86_64/build_artifact.Dockerfile index 1533a48dd..9fa3342dd 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=2.2.3 \ +# --build-arg JAVET_VERSION=3.0.0 \ # -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=2.2.3 +ARG JAVET_VERSION=3.0.0 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 d34624aa8..e7735403a 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:2.2.3 -m 4G -f docker/windows-x86_64/base.Dockerfile . +# Usage: docker build -t sjtucaocao/javet-windows:3.0.0 -m 4G -f docker/windows-x86_64/base.Dockerfile . -ARG JAVET_NODE_VERSION=18.17.1 -ARG JAVET_V8_VERSION=11.7.439.16 +ARG JAVET_NODE_VERSION=20.8.0 +ARG JAVET_V8_VERSION=11.8.172.15 # 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 85b8e5ea5..d27791f63 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:2.2.3 +FROM sjtucaocao/javet-windows:3.0.0 SHELL ["cmd", "/S", "/C"] WORKDIR / diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js index 2bdb7310b..175b1e97e 100644 --- a/docs/_static/documentation_options.js +++ b/docs/_static/documentation_options.js @@ -1,5 +1,5 @@ const DOCUMENTATION_OPTIONS = { - VERSION: '2.2.3', + VERSION: '3.0.0', LANGUAGE: 'en, zh-CN', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/docs/conf.py b/docs/conf.py index 8e075ea7a..532f9b766 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,11 +18,11 @@ # -- Project information ----------------------------------------------------- project = 'Javet' -copyright = '2021-2022. caoccao.com Sam Cao' +copyright = '2021-2023. caoccao.com Sam Cao' author = 'Sam Cao' # The full version, including alpha/beta/rc tags -release = '2.2.3' +release = '3.0.0' # -- General configuration --------------------------------------------------- diff --git a/docs/development/build.html b/docs/development/build.html index 6c2a8eb89..81784dbfd 100644 --- a/docs/development/build.html +++ b/docs/development/build.html @@ -2,11 +2,11 @@ - + - Build Javet - Javet 2.2.3 documentation + Build Javet - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
@@ -151,7 +151,7 @@
- Javet 2.2.3 documentation + Javet 3.0.0 documentation
- + diff --git a/docs/development/build.rst b/docs/development/build.rst index e3a42eaa9..0f07c6315 100644 --- a/docs/development/build.rst +++ b/docs/development/build.rst @@ -25,10 +25,12 @@ Build Environment Linux Environment ----------------- -* Ubuntu 20.04 +* Ubuntu 20.04+ * CMake 3.25.1+ * JDK 8 -* Gradle 7.2+ +* Gradle 8.1+ +* GCC 10+ +* Python 3.9+ MacOS Environment ----------------- @@ -38,7 +40,8 @@ MacOS Environment * Xcode 11.4.1+ * Cmake 3.16+ * JDK 8 -* Gradle 7.2+ +* Gradle 8.1+ +* Python 3.9+ Windows Environment ------------------- @@ -48,15 +51,17 @@ Windows Environment * CMake 3.24+ (comes with Visual Studio 2022) * Latest Windows 10 SDK with WinDbg * JDK 8 -* Gradle 7.2+ +* Gradle 8.1+ +* Python 3.9+ Android Environment ------------------- -* Ubuntu 20.04 or Ubuntu 20.04 in the WSL2 on the Latest Windows 10 -* CMake 3.10+ +* Ubuntu 20.04+ or Ubuntu 20.04+ in the WSL2 on the Latest Windows 10 +* CMake 3.25.1+ * JDK 8 -* Gradle 7.2+ +* Gradle 8.1+ +* Python 3.9+ * Latest Android Studio (Optional) * Android NDK r25b * Android SDK 30 @@ -70,3 +75,18 @@ Environment Variables * ``${DEPOT_TOOLS_HOME}`` is the home directory of Google depot tools. * ``${ANDROID_NDK_HOME}`` is the home directory of Android NDK. * ``${ANDROID_SDK_HOME}`` is the home directory of Android SDK. + +V8 Feature Flags +================ + +======================= ======= ================================================================================================================================== +Feature Flag Description +======================= ======= ================================================================================================================================== +Custom libcxx Off The official release doesn't support custom libcxx. +Debug Off The official release is a **release** build. +External Startup Data Off The official release doesn't support external startup data. +i18n Off The official release doesn't support i18n. Please contact the maintainer for private builds supporting this feature. +Pointer Compression Off The official release doesn't support pointer compression. +Sandbox Off The official release doesn't support sandbox. Please contact the maintainer for private builds supporting this feature. +Snapshot Off The official release doesn't support snapshot. Please contact the maintainer for private builds supporting this feature. +======================= ======= ================================================================================================================================== diff --git a/docs/development/build_javet_from_scratch.html b/docs/development/build_javet_from_scratch.html index c716348d4..4b51e41f5 100644 --- a/docs/development/build_javet_from_scratch.html +++ b/docs/development/build_javet_from_scratch.html @@ -2,11 +2,11 @@ - + - Build Javet from Scratch - Javet 2.2.3 documentation + Build Javet from Scratch - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
@@ -151,7 +151,7 @@
- Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/development/debug_with_chrome_developer_tools.html b/docs/development/debug_with_chrome_developer_tools.html index d2c129380..e6cda9e3b 100644 --- a/docs/development/debug_with_chrome_developer_tools.html +++ b/docs/development/debug_with_chrome_developer_tools.html @@ -2,11 +2,11 @@ - + - Debug with Chrome Developer Tools - Javet 2.2.3 documentation + Debug with Chrome Developer Tools - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/development/index.html b/docs/development/index.html index d23f1ae4a..0d3fdb9b0 100644 --- a/docs/development/index.html +++ b/docs/development/index.html @@ -2,11 +2,11 @@ - + - Development - Javet 2.2.3 documentation + Development - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/faq/background/history_with_j2v8.html b/docs/faq/background/history_with_j2v8.html index 572b55bec..faa25c82f 100644 --- a/docs/faq/background/history_with_j2v8.html +++ b/docs/faq/background/history_with_j2v8.html @@ -2,11 +2,11 @@ - + - History with J2V8 - Javet 2.2.3 documentation + History with J2V8 - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/faq/development/how_to_think_in_javet.html b/docs/faq/development/how_to_think_in_javet.html index 3c007ba71..bc3eb90e7 100644 --- a/docs/faq/development/how_to_think_in_javet.html +++ b/docs/faq/development/how_to_think_in_javet.html @@ -2,11 +2,11 @@ - + - How to Think in Javet? - Javet 2.2.3 documentation + How to Think in Javet? - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/faq/development/index.html b/docs/faq/development/index.html index d1d92bb76..1c0401770 100644 --- a/docs/faq/development/index.html +++ b/docs/faq/development/index.html @@ -2,11 +2,11 @@ - + - Development - Javet 2.2.3 documentation + Development - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + 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 0689a2827..7c0ae20bf 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 @@ -2,11 +2,11 @@ - + - Why is the Inspector Disabled in Node.js Mode? - Javet 2.2.3 documentation + Why is the Inspector Disabled in Node.js Mode? - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation
    @@ -339,7 +337,7 @@

    Environment diff --git a/docs/faq/index.html b/docs/faq/index.html index 8b0295561..b9ba12081 100644 --- a/docs/faq/index.html +++ b/docs/faq/index.html @@ -2,11 +2,11 @@ - - + + - FAQ - Javet 2.2.3 documentation + FAQ - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • - +
    Previous
    -
    Release Notes 2.2.x
    +
    Release Notes 3.0.x
    @@ -361,7 +359,7 @@

    FAQ#

    Made with Furo @@ -380,7 +378,7 @@

    FAQ#

    -
    + 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 632a90cb8..fed909c2f 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 @@ -2,11 +2,11 @@ - + - A dynamic link library (DLL) initialization routine failed - Javet 2.2.3 documentation + A dynamic link library (DLL) initialization routine failed - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + 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 aff92156f..01fa311c9 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 @@ -2,11 +2,11 @@ - + - Can I Debug Javet in Chrome DevTools? - Javet 2.2.3 documentation + Can I Debug Javet in Chrome DevTools? - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • @@ -149,7 +149,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -220,7 +220,7 @@
  • Release Notes
  • FAQ
  • diff --git a/docs/index.html b/docs/index.html index fc7d01b13..0fdae44db 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,11 +2,11 @@ - + - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
      @@ -240,7 +240,6 @@
    • Environment
    • Troubleshooting
        @@ -310,10 +309,46 @@

        Javet#<

        Major Features#

        +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

        CPU Arch

        Android

        Linux

        MacOS

        Windows

        x86

        x86_64

        arm

        arm64

        +
          -
        • Linux (x86_64) + Mac OS (x86_64, arm64) + ️Windows (x86_64)

        • -
        • Android (arm, arm64, x86 and x86_64)

        • -
        • Node.js v18.17.1 + V8 v11.7.439.16

        • +
        • Node.js v20.8.0 + V8 v11.8.172.15

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

        • Polyfill V8 mode with Javenode

        • V8 API exposure in JVM

        • @@ -334,31 +369,40 @@

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

  • Gradle Kotlin DSL#

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

    Gradle Groovy DSL#

    -
    implementation 'com.caoccao.javet:javet:2.2.3' // Linux and Windows (x86_64)
    -implementation 'com.caoccao.javet:javet-macos:2.2.3' // Mac OS (x86_64 and arm64)
    -implementation 'com.caoccao.javet:javet-android:2.2.3' // Android (arm, arm64, x86 and x86_64)
    +
    implementation 'com.caoccao.javet:javet:3.0.0' // Linux and Windows (x86_64)
    +implementation 'com.caoccao.javet:javet-linux-arm64:3.0.0' // Linux (arm64)
    +implementation 'com.caoccao.javet:javet-macos:3.0.0' // Mac OS (x86_64 and arm64)
    +implementation 'com.caoccao.javet:javet-android:3.0.0' // Android (arm, arm64, x86 and x86_64)
     
    @@ -378,6 +422,10 @@

    Hello Javet +

    Sponsors#

    +

    HiveMQ

    +

    License#

    APACHE LICENSE, VERSION 2.0.

    @@ -386,6 +434,7 @@

    License#<

    Documents#

    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/reference/converters/proxy_converter.html b/docs/reference/converters/proxy_converter.html index ab397b18f..45e844afe 100644 --- a/docs/reference/converters/proxy_converter.html +++ b/docs/reference/converters/proxy_converter.html @@ -2,11 +2,11 @@ - + - Proxy Converter - Javet 2.2.3 documentation + Proxy Converter - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • diff --git a/docs/reference/resource_management/load_and_unload.html b/docs/reference/resource_management/load_and_unload.html index 32f2ac471..250dce59a 100644 --- a/docs/reference/resource_management/load_and_unload.html +++ b/docs/reference/resource_management/load_and_unload.html @@ -2,11 +2,11 @@ - + - Load and Unload - Javet 2.2.3 documentation + Load and Unload - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/reference/resource_management/lock.html b/docs/reference/resource_management/lock.html index df6d9f6e0..47bc869bd 100644 --- a/docs/reference/resource_management/lock.html +++ b/docs/reference/resource_management/lock.html @@ -2,11 +2,11 @@ - + - Know the Lock - Javet 2.2.3 documentation + Know the Lock - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
      @@ -240,7 +240,6 @@
    • Environment
    • Troubleshooting
        @@ -336,6 +335,10 @@

        Thread-safety +

        Coroutines or Virtual Threads#

        +

        Kotlin Coroutines and Java 21 Virtual Threads are incompatible with the V8 threading model. The V8 locking mechanism cannot handle the chaos from coroutines or virtual threads, because V8 sees the calls coming from the same OS thread and doesn't actually keep the calls in sequence. Calling Javet API in coroutines or virtual threads will result in the JVM crash, if an additional synchronization is absent.

        +

  • @@ -367,7 +370,7 @@

    Thread-safety diff --git a/docs/reference/resource_management/lock.rst b/docs/reference/resource_management/lock.rst index a7c0d22d5..649af4e8e 100644 --- a/docs/reference/resource_management/lock.rst +++ b/docs/reference/resource_management/lock.rst @@ -43,3 +43,8 @@ Thread-safety The implicit mode is thread-safe because its locking granularity is at API call level. Multiple threads are free to share the same V8 runtime in the concurrent scenarios. But, please be careful that JavaScript variables may be changed by other threads. It's better not to touch the same JavaScript variable among multiple threads, otherwise, Javet may crash. Yes, crash, because Javet doesn't perform this kind of check. The explicit mode is **NOT** thread-safe because it's designed for maximizing the performance in the single-threaded scenarios. Sharing V8 locker protected V8 runtime among multiple threads will result in Javet crash immediately. + +Coroutines or Virtual Threads +============================= + +Kotlin Coroutines and Java 21 Virtual Threads are incompatible with the V8 threading model. The V8 locking mechanism cannot handle the chaos from coroutines or virtual threads, because V8 sees the calls coming from the same OS thread and doesn't actually keep the calls in sequence. Calling Javet API in coroutines or virtual threads will result in the JVM crash, if an additional synchronization is absent. diff --git a/docs/reference/resource_management/memory_management.html b/docs/reference/resource_management/memory_management.html index a435f5041..76a9b2315 100644 --- a/docs/reference/resource_management/memory_management.html +++ b/docs/reference/resource_management/memory_management.html @@ -2,11 +2,11 @@ - + - Memory Management - Javet 2.2.3 documentation + Memory Management - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • diff --git a/docs/reference/tips/index.html b/docs/reference/tips/index.html index 70e3c4b99..7bc817d8a 100644 --- a/docs/reference/tips/index.html +++ b/docs/reference/tips/index.html @@ -2,11 +2,11 @@ - + - Tips - Javet 2.2.3 documentation + Tips - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/reference/todo_list.html b/docs/reference/todo_list.html index 9df13fc9b..392ad5292 100644 --- a/docs/reference/todo_list.html +++ b/docs/reference/todo_list.html @@ -2,11 +2,11 @@ - + - TODO List - Javet 2.2.3 documentation + TODO List - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/reference/troubleshooting/index.html b/docs/reference/troubleshooting/index.html index ee717911d..37175ad3c 100644 --- a/docs/reference/troubleshooting/index.html +++ b/docs/reference/troubleshooting/index.html @@ -2,11 +2,11 @@ - + - Troubleshooting - Javet 2.2.3 documentation + Troubleshooting - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/reference/v8_values/index.html b/docs/reference/v8_values/index.html index 5479b2717..3a2ab02f5 100644 --- a/docs/reference/v8_values/index.html +++ b/docs/reference/v8_values/index.html @@ -2,11 +2,11 @@ - + - V8 Values - Javet 2.2.3 documentation + V8 Values - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/release_notes/release_notes_0_8.html b/docs/release_notes/release_notes_0_8.html index af8afcaca..bb215caa7 100644 --- a/docs/release_notes/release_notes_0_8.html +++ b/docs/release_notes/release_notes_0_8.html @@ -2,11 +2,11 @@ - + - Release Notes 0.8.x - Javet 2.2.3 documentation + Release Notes 0.8.x - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -159,7 +159,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • diff --git a/docs/tutorial/advanced/interact_with_node_js.html b/docs/tutorial/advanced/interact_with_node_js.html index c66914df7..7d94432c1 100644 --- a/docs/tutorial/advanced/interact_with_node_js.html +++ b/docs/tutorial/advanced/interact_with_node_js.html @@ -2,11 +2,11 @@ - + - Interact with Node.js - Javet 2.2.3 documentation + Interact with Node.js - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/tutorial/advanced/object_converter.html b/docs/tutorial/advanced/object_converter.html index fdd3e2433..18843c37d 100644 --- a/docs/tutorial/advanced/object_converter.html +++ b/docs/tutorial/advanced/object_converter.html @@ -2,11 +2,11 @@ - + - Object Converter - Javet 2.2.3 documentation + Object Converter - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • diff --git a/docs/tutorial/basic/engine_pool.html b/docs/tutorial/basic/engine_pool.html index 30813f5f9..135bbf362 100644 --- a/docs/tutorial/basic/engine_pool.html +++ b/docs/tutorial/basic/engine_pool.html @@ -2,11 +2,11 @@ - + - Javet Engine Pool - Javet 2.2.3 documentation + Javet Engine Pool - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • diff --git a/docs/tutorial/basic/hello_javet.html b/docs/tutorial/basic/hello_javet.html index 278f268a9..51fff1fec 100644 --- a/docs/tutorial/basic/hello_javet.html +++ b/docs/tutorial/basic/hello_javet.html @@ -2,11 +2,11 @@ - + - Hello Javet - Javet 2.2.3 documentation + Hello Javet - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • diff --git a/docs/tutorial/basic/installation.html b/docs/tutorial/basic/installation.html index 83f762616..c3cb3a812 100644 --- a/docs/tutorial/basic/installation.html +++ b/docs/tutorial/basic/installation.html @@ -2,11 +2,11 @@ - + - Installation - Javet 2.2.3 documentation + Installation - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
      @@ -240,7 +240,6 @@
    • Environment
    • Troubleshooting
        @@ -310,31 +309,40 @@

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

  • Gradle Kotlin DSL#

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

    Gradle Groovy DSL#

    -
    implementation 'com.caoccao.javet:javet:2.2.3' // Linux and Windows (x86_64)
    -implementation 'com.caoccao.javet:javet-macos:2.2.3' // Mac OS (x86_64 and arm64)
    -implementation 'com.caoccao.javet:javet-android:2.2.3' // Android (arm, arm64, x86 and x86_64)
    +
    implementation 'com.caoccao.javet:javet:3.0.0' // Linux and Windows (x86_64)
    +implementation 'com.caoccao.javet:javet-linux-arm64:3.0.0' // Linux (arm64)
    +implementation 'com.caoccao.javet:javet-macos:3.0.0' // Mac OS (x86_64 and arm64)
    +implementation 'com.caoccao.javet:javet-android:3.0.0' // Android (arm, arm64, x86 and x86_64)
     
    @@ -419,7 +427,7 @@

    Mac OS#

    Yes

    Mac OS arm64

    -

    Temporary (Can Javet Support Mac?)

    +

    Yes

    @@ -498,7 +506,7 @@

    Android#< + diff --git a/docs/tutorial/basic/installation.rst b/docs/tutorial/basic/installation.rst index 34c98ce8f..c88ff835b 100644 --- a/docs/tutorial/basic/installation.rst +++ b/docs/tutorial/basic/installation.rst @@ -14,14 +14,21 @@ Maven com.caoccao.javet javet - 2.2.3 + 3.0.0 + + + + + com.caoccao.javet + javet-linux-arm64 + 3.0.0 com.caoccao.javet javet-macos - 2.2.3 + 3.0.0 Gradle Kotlin DSL @@ -29,18 +36,20 @@ Gradle Kotlin DSL .. code-block:: kotlin - implementation("com.caoccao.javet:javet:2.2.3") // Linux and Windows (x86_64) - implementation("com.caoccao.javet:javet-macos:2.2.3") // Mac OS (x86_64 and arm64) - implementation("com.caoccao.javet:javet-android:2.2.3") // Android (arm, arm64, x86 and x86_64) + implementation("com.caoccao.javet:javet:3.0.0") // Linux and Windows (x86_64) + implementation("com.caoccao.javet:javet-linux-arm64:3.0.0") // Linux (arm64) + implementation("com.caoccao.javet:javet-macos:3.0.0") // Mac OS (x86_64 and arm64) + implementation("com.caoccao.javet:javet-android:3.0.0") // Android (arm, arm64, x86 and x86_64) Gradle Groovy DSL ----------------- .. code-block:: groovy - implementation 'com.caoccao.javet:javet:2.2.3' // Linux and Windows (x86_64) - implementation 'com.caoccao.javet:javet-macos:2.2.3' // Mac OS (x86_64 and arm64) - implementation 'com.caoccao.javet:javet-android:2.2.3' // Android (arm, arm64, x86 and x86_64) + implementation 'com.caoccao.javet:javet:3.0.0' // Linux and Windows (x86_64) + implementation 'com.caoccao.javet:javet-linux-arm64:3.0.0' // Linux (arm64) + implementation 'com.caoccao.javet:javet-macos:3.0.0' // Mac OS (x86_64 and arm64) + implementation 'com.caoccao.javet:javet-android:3.0.0' // Android (arm, arm64, x86 and x86_64) OS Compatibility ================ @@ -82,7 +91,7 @@ Mac OS OS Compatible =========================== ======================================================================================================================= Mac OS x86_64 Yes -Mac OS arm64 Temporary (:doc:`../../faq/environment/can_javet_support_mac`) +Mac OS arm64 Yes =========================== ======================================================================================================================= .. caution:: diff --git a/docs/tutorial/basic/interception.html b/docs/tutorial/basic/interception.html index e8580517e..c55dcc19e 100644 --- a/docs/tutorial/basic/interception.html +++ b/docs/tutorial/basic/interception.html @@ -2,11 +2,11 @@ - + - Interception - Javet 2.2.3 documentation + Interception - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/tutorial/basic/javet_shell.html b/docs/tutorial/basic/javet_shell.html index 7637a460d..af721f99e 100644 --- a/docs/tutorial/basic/javet_shell.html +++ b/docs/tutorial/basic/javet_shell.html @@ -2,11 +2,11 @@ - + - Javet Shell - Javet 2.2.3 documentation + Javet Shell - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • + diff --git a/docs/tutorial/basic/polyfill.html b/docs/tutorial/basic/polyfill.html index 77b886cc9..1be6cec95 100644 --- a/docs/tutorial/basic/polyfill.html +++ b/docs/tutorial/basic/polyfill.html @@ -2,11 +2,11 @@ - + - Polyfill - Javet 2.2.3 documentation + Polyfill - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • diff --git a/docs/tutorial/basic/spring_integration.html b/docs/tutorial/basic/spring_integration.html index e9b631204..e362cf832 100644 --- a/docs/tutorial/basic/spring_integration.html +++ b/docs/tutorial/basic/spring_integration.html @@ -2,11 +2,11 @@ - + - Spring Integration - Javet 2.2.3 documentation + Spring Integration - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • diff --git a/docs/tutorial/migration_guides/index.html b/docs/tutorial/migration_guides/index.html index e1ee5868a..d201881d6 100644 --- a/docs/tutorial/migration_guides/index.html +++ b/docs/tutorial/migration_guides/index.html @@ -2,11 +2,11 @@ - + - Migration Guides - Javet 2.2.3 documentation + Migration Guides - Javet 3.0.0 documentation @@ -125,7 +125,7 @@
    @@ -151,7 +151,7 @@
    - Javet 2.2.3 documentation + Javet 3.0.0 documentation @@ -222,7 +222,7 @@
  • Release Notes
  • FAQ
  • diff --git a/pom.xml b/pom.xml index 02ba2ef88..8e90955ae 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.caoccao.javet javet - 2.2.3 + 3.0.0 javet Javet is Java + V8 (JAVa + V + EighT). It is an awesome way of embedding V8 in Java. https://github.com/caoccao/Javet @@ -28,7 +28,7 @@ scm:git:git://github.com/caoccao/Javet.git scm:git:git@github.com:caoccao/caoccao.git https://github.com/caoccao/Javet - 2.2.3 + 3.0.0 diff --git a/scripts/node/javet-rebuild/rebuild.cmd b/scripts/node/javet-rebuild/rebuild.cmd index bd3d5f647..f6ae254cf 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.2.2.3.lib" +SET NODE_LIB_FILE="..\..\..\..\..\..\build\libs\libjavet-node-windows-x86_64.v.3.0.0.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 c1b2b3604..1a2af0fbc 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.2.2.3.so ${NODE_MODULE_FILE} +patchelf --add-needed libjavet-node-linux-x86_64.v.3.0.0.so ${NODE_MODULE_FILE} diff --git a/scripts/python/change_javet_version.py b/scripts/python/change_javet_version.py index 9f4c69099..94e94edc2 100644 --- a/scripts/python/change_javet_version.py +++ b/scripts/python/change_javet_version.py @@ -177,7 +177,7 @@ def _update(self, relative_file_path: str, line_separator: str, *patterns: list) logging.info(' Updated.') def main(): - change_javet_version = ChangeJavetVersion('2.2.3') + change_javet_version = ChangeJavetVersion('3.0.0') 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 efc5810c8..25c807bec 100644 --- a/scripts/python/change_node_v8_version.py +++ b/scripts/python/change_node_v8_version.py @@ -152,9 +152,9 @@ def update(self) -> None: re.compile(r'"(?P\d+\.\d+\.\d+\.\d+)",')) def main(): - change_node_version = ChangeNodeVersion('18.17.1') + change_node_version = ChangeNodeVersion('20.8.0') change_node_version.update() - change_v8_version = ChangeV8Version('11.7.439.16') + change_v8_version = ChangeV8Version('11.8.172.15') change_v8_version.update() return 0 diff --git a/scripts/python/patch_node_build.py b/scripts/python/patch_node_build.py index 2b43df128..72987e7c0 100644 --- a/scripts/python/patch_node_build.py +++ b/scripts/python/patch_node_build.py @@ -16,6 +16,7 @@ ''' import argparse +import glob import importlib import logging import pathlib @@ -54,30 +55,6 @@ def __init__(self) -> None: 'CFLAGS_CC_Release :=', 'LDFLAGS_Release :=', ] - self._make_files = [ - 'out/libnode.target.mk', - 'out/tools/v8_gypfiles/torque_base.target.mk', - 'out/tools/v8_gypfiles/v8_base_without_compiler.target.mk', - 'out/deps/cares/cares.target.mk', - 'out/deps/uv/libuv.target.mk', - 'out/deps/openssl/openssl.target.mk', - 'out/deps/nghttp2/nghttp2.target.mk', - 'out/deps/ngtcp2/nghttp3.target.mk', - 'out/deps/ngtcp2/ngtcp2.target.mk', - 'out/tools/icu/icutools.host.mk', - 'out/tools/v8_gypfiles/v8_compiler.target.mk', - 'out/tools/v8_gypfiles/v8_libbase.target.mk', - 'out/deps/llhttp/llhttp.target.mk', - 'out/deps/zlib/zlib.target.mk', - 'out/deps/brotli/brotli.target.mk', - 'out/tools/v8_gypfiles/v8_zlib.target.mk', - 'out/tools/v8_gypfiles/v8_libsampler.target.mk', - 'out/tools/v8_gypfiles/v8_libplatform.target.mk', - 'out/tools/v8_gypfiles/v8_initializers.target.mk', - 'out/deps/histogram/histogram.target.mk', - 'out/deps/uvwasi/uvwasi.target.mk', - 'out/tools/v8_gypfiles/v8_snapshot.target.mk', - ] self._make_property = ' -fPIC \\' self._make_property_inline = ' -fPIC ' @@ -114,8 +91,10 @@ def _patch_common(self): logging.error('Failed to locate %s.', str(file_path)) def _patch_make_files(self): - for make_file in self._make_files: - file_path = self._node_repo_path.joinpath(make_file).resolve().absolute() + for file_path in glob.glob( + (self._node_repo_path.joinpath('out').resolve().absolute() / '**/*.mk').as_posix(), + recursive=True): + file_path = pathlib.Path(file_path) if file_path.exists(): original_buffer = file_path.read_bytes() lines = [] diff --git a/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java b/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java index 338437c89..6ad4a0634 100644 --- a/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java +++ b/src/main/java/com/caoccao/javet/enums/JSRuntimeType.java @@ -37,7 +37,7 @@ public enum JSRuntimeType { */ Node( "node", - "10.2.154.26-node.26", // node -p process.versions.v8 + "11.3.244.8-node.16", // node -p process.versions.v8 NodeRuntimeOptions::new, o -> o instanceof NodeRuntimeOptions), /** @@ -47,7 +47,7 @@ public enum JSRuntimeType { */ V8( "v8", - "11.7.439.16", + "11.8.172.15", V8RuntimeOptions::new, o -> o instanceof V8RuntimeOptions); diff --git a/src/main/java/com/caoccao/javet/interop/IV8Native.java b/src/main/java/com/caoccao/javet/interop/IV8Native.java index 78fdcdf23..cfd61c12a 100644 --- a/src/main/java/com/caoccao/javet/interop/IV8Native.java +++ b/src/main/java/com/caoccao/javet/interop/IV8Native.java @@ -324,7 +324,7 @@ Object promiseThen( void removeJNIGlobalRef(long handle); - void removeReferenceHandle(long referenceHandle, int referenceType); + void removeReferenceHandle(long v8RuntimeHandle, long referenceHandle, int referenceType); boolean reportPendingMessages(long v8RuntimeHandle); diff --git a/src/main/java/com/caoccao/javet/interop/V8Native.java b/src/main/java/com/caoccao/javet/interop/V8Native.java index 82704cbcf..a702b7c9b 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Native.java +++ b/src/main/java/com/caoccao/javet/interop/V8Native.java @@ -496,7 +496,7 @@ public native Object promiseThen( public native void removeJNIGlobalRef(long handle); @Override - public native void removeReferenceHandle(long referenceHandle, int referenceType); + public native void removeReferenceHandle(long v8RuntimeHandle, long referenceHandle, int referenceType); @Override public native boolean reportPendingMessages(long v8RuntimeHandle); diff --git a/src/main/java/com/caoccao/javet/interop/V8Runtime.java b/src/main/java/com/caoccao/javet/interop/V8Runtime.java index 7ca2d1eaf..67a5e6e6c 100644 --- a/src/main/java/com/caoccao/javet/interop/V8Runtime.java +++ b/src/main/java/com/caoccao/javet/interop/V8Runtime.java @@ -53,6 +53,7 @@ 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; @@ -179,17 +180,11 @@ public class V8Runtime implements IJavetClosable, IV8Creatable, IV8Convertible { final List gcPrologueCallbacks; /** * The Primitive flags is for passing the calling succession in JNI calls. - * It's length is 1. True: success. False: failure. + * Its length is 1. True: success. False: failure. * * @since 2.2.0 */ final boolean[] primitiveFlags; - /** - * The Reference lock. - * - * @since 0.9.12 - */ - final Object referenceLock; /** * The Reference map. * @@ -335,8 +330,7 @@ public class V8Runtime implements IJavetClosable, IV8Creatable, IV8Convertible { this.pooled = pooled; primitiveFlags = new boolean[1]; promiseRejectCallback = new JavetPromiseRejectCallback(logger); - referenceLock = new Object(); - referenceMap = new HashMap<>(); + referenceMap = new ConcurrentHashMap<>(); this.v8Host = Objects.requireNonNull(v8Host); v8Inspector = null; this.v8Native = Objects.requireNonNull(v8Native); @@ -386,9 +380,7 @@ public void addGCPrologueCallback(IJavetGCCallback iJavetGCCallback) { * @since 1.0.3 */ void addReference(IV8ValueReference iV8ValueReference) { - synchronized (referenceLock) { - referenceMap.put(iV8ValueReference.getHandle(), iV8ValueReference); - } + referenceMap.put(iV8ValueReference.getHandle(), iV8ValueReference); } /** @@ -2927,15 +2919,12 @@ void removeJNIGlobalRef(long handle) { @SuppressWarnings("RedundantThrows") void removeReference(IV8ValueReference iV8ValueReference) throws JavetException { final long referenceHandle = iV8ValueReference.getHandle(); - synchronized (referenceLock) { - if (referenceMap.containsKey(referenceHandle)) { - final int referenceType = iV8ValueReference.getType().getId(); - if (referenceType == V8ValueReferenceType.Module.getId()) { - removeV8Module((IV8Module) iV8ValueReference); - } - v8Native.removeReferenceHandle(referenceHandle, referenceType); - referenceMap.remove(referenceHandle); + if (referenceMap.remove(referenceHandle) != null) { + final int referenceType = iV8ValueReference.getType().getId(); + if (referenceType == V8ValueReferenceType.Module.getId()) { + removeV8Module((IV8Module) iV8ValueReference); } + v8Native.removeReferenceHandle(handle, referenceHandle, referenceType); } if (gcScheduled) { lowMemoryNotification(); @@ -2950,33 +2939,31 @@ void removeReference(IV8ValueReference iV8ValueReference) throws JavetException * @since 0.7.0 */ void removeReferences() throws JavetException { - 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; - } + 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); } - 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(); + 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)); } + referenceMap.clear(); } } 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 2af55bab5..1dcfa16df 100644 --- a/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoader.java +++ b/src/main/java/com/caoccao/javet/interop/loader/JavetLibLoader.java @@ -48,7 +48,7 @@ public final class JavetLibLoader { * * @since 0.8.0 */ - public static final String LIB_VERSION = "2.2.3"; + public static final String LIB_VERSION = "3.0.0"; 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/test/java/com/caoccao/javet/exceptions/TestJavetCompilationException.java b/src/test/java/com/caoccao/javet/exceptions/TestJavetCompilationException.java index 2f0f302d0..2a852c365 100644 --- a/src/test/java/com/caoccao/javet/exceptions/TestJavetCompilationException.java +++ b/src/test/java/com/caoccao/javet/exceptions/TestJavetCompilationException.java @@ -78,13 +78,8 @@ public void testUnexpectedIdentifier() { } catch (JavetCompilationException e) { assertEquals(JavetError.CompilationFailure, e.getError()); JavetScriptingError javetScriptingError = e.getScriptingError(); - if (v8Runtime.getJSRuntimeType().isV8()) { - assertEquals("SyntaxError: Unexpected identifier 'a'", e.getMessage()); - assertEquals("SyntaxError: Unexpected identifier 'a'", javetScriptingError.getMessage()); - } else { - assertEquals("SyntaxError: Unexpected identifier", e.getMessage()); - assertEquals("SyntaxError: Unexpected identifier", javetScriptingError.getMessage()); - } + assertEquals("SyntaxError: Unexpected identifier 'a'", e.getMessage()); + assertEquals("SyntaxError: Unexpected identifier 'a'", javetScriptingError.getMessage()); assertEquals("undefined", javetScriptingError.getResourceName()); assertEquals("a a a a;", javetScriptingError.getSourceLine()); assertEquals(2, javetScriptingError.getLineNumber()); @@ -92,25 +87,14 @@ public void testUnexpectedIdentifier() { assertEquals(3, javetScriptingError.getEndColumn()); assertEquals(15, javetScriptingError.getStartPosition()); assertEquals(16, javetScriptingError.getEndPosition()); - if (v8Runtime.getJSRuntimeType().isV8()) { - assertEquals( - "SyntaxError: Unexpected identifier 'a'\n" + - "Resource: undefined\n" + - "Source Code: a a a a;\n" + - "Line Number: 2\n" + - "Column: 2, 3\n" + - "Position: 15, 16", - javetScriptingError.toString()); - } else { - assertEquals( - "SyntaxError: Unexpected identifier\n" + - "Resource: undefined\n" + - "Source Code: a a a a;\n" + - "Line Number: 2\n" + - "Column: 2, 3\n" + - "Position: 15, 16", - javetScriptingError.toString()); - } + assertEquals( + "SyntaxError: Unexpected identifier 'a'\n" + + "Resource: undefined\n" + + "Source Code: a a a a;\n" + + "Line Number: 2\n" + + "Column: 2, 3\n" + + "Position: 15, 16", + javetScriptingError.toString()); } catch (JavetException e) { fail("JavetCompilationException should be thrown."); } diff --git a/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java b/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java index 1d37b726e..c0b32c778 100644 --- a/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java +++ b/src/test/java/com/caoccao/javet/interop/TestNodeRuntime.java @@ -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("v18.17.1", nodeModuleProcess.getVersion()); + assertEquals("v20.8.0", nodeModuleProcess.getVersion()); } @Test 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 b2a3737ee..a4ad9bae3 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8Module.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8Module.java @@ -243,41 +243,22 @@ public void testInvalidModuleResolver() throws JavetException { fail("Failed to report SyntaxError."); } catch (JavetExecutionException e) { assertTrue(e.getCause() instanceof JavetCompilationException); - if (v8Runtime.getJSRuntimeType().isV8()) { - assertEquals( - "Error: SyntaxError: Unexpected identifier 'b'\n" + - "Resource: undefined\n" + - "Source Code: \n" + - "Line Number: 0\n" + - "Column: -1, -1\n" + - "Position: -1, -1", - e.getScriptingError().toString()); - assertEquals( - "SyntaxError: Unexpected identifier 'b'\n" + - "Resource: ./test.js\n" + - "Source Code: a b c\n" + - "Line Number: 1\n" + - "Column: 2, 3\n" + - "Position: 2, 3", - ((JavetCompilationException) e.getCause()).getScriptingError().toString()); - } else { - assertEquals( - "Error: SyntaxError: Unexpected identifier\n" + - "Resource: undefined\n" + - "Source Code: \n" + - "Line Number: 0\n" + - "Column: -1, -1\n" + - "Position: -1, -1", - e.getScriptingError().toString()); - assertEquals( - "SyntaxError: Unexpected identifier\n" + - "Resource: ./test.js\n" + - "Source Code: a b c\n" + - "Line Number: 1\n" + - "Column: 2, 3\n" + - "Position: 2, 3", - ((JavetCompilationException) e.getCause()).getScriptingError().toString()); - } + assertEquals( + "Error: SyntaxError: Unexpected identifier 'b'\n" + + "Resource: undefined\n" + + "Source Code: \n" + + "Line Number: 0\n" + + "Column: -1, -1\n" + + "Position: -1, -1", + e.getScriptingError().toString()); + assertEquals( + "SyntaxError: Unexpected identifier 'b'\n" + + "Resource: ./test.js\n" + + "Source Code: a b c\n" + + "Line Number: 1\n" + + "Column: 2, 3\n" + + "Position: 2, 3", + ((JavetCompilationException) e.getCause()).getScriptingError().toString()); } assertTrue(resolver.isCalled()); } @@ -315,11 +296,7 @@ public void testUnexpectedIdentifier() throws JavetException { } catch (JavetCompilationException e) { assertFalse(v8Runtime.containsV8Module("./test.js")); assertEquals(0, v8Runtime.getV8ModuleCount()); - if (v8Runtime.getJSRuntimeType().isV8()) { - assertEquals("SyntaxError: Unexpected identifier 'b'", e.getScriptingError().getMessage()); - } else { - assertEquals("SyntaxError: Unexpected identifier", e.getScriptingError().getMessage()); - } + assertEquals("SyntaxError: Unexpected identifier 'b'", e.getScriptingError().getMessage()); } } 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 bf36a3c5b..5f64a63c3 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8Script.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8Script.java @@ -63,11 +63,7 @@ public void testUnexpectedIdentifier() throws JavetException { try (V8Script v8Script = v8Runtime.getExecutor("a b c").compileV8Script()) { fail("Failed to report error."); } catch (JavetCompilationException e) { - if (v8Runtime.getJSRuntimeType().isV8()) { - assertEquals("SyntaxError: Unexpected identifier 'b'", e.getScriptingError().getMessage()); - } else { - assertEquals("SyntaxError: Unexpected identifier", e.getScriptingError().getMessage()); - } + assertEquals("SyntaxError: Unexpected identifier 'b'", e.getScriptingError().getMessage()); } } } 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 f810e16ba..6faed883f 100644 --- a/src/test/java/com/caoccao/javet/values/reference/TestV8ValueFunction.java +++ b/src/test/java/com/caoccao/javet/values/reference/TestV8ValueFunction.java @@ -1590,10 +1590,6 @@ public void testGetArguments() throws JavetException { @Test public void testGetScopeInfosWith1Closure() throws JavetException { List options = Arrays.asList(true, false); - Set globalVariables = new HashSet<>(Arrays.asList(( - "global,queueMicrotask,clearImmediate,setImmediate," + - "structuredClone,clearInterval,clearTimeout,setInterval," + - "setTimeout,atob,btoa,performance,fetch,require").split(","))); String codeString = "(() => { let a = 1; return () => { const b = 0; return a; } })()"; try (V8ValueFunction v8ValueFunction = v8Runtime.getExecutor(codeString).execute()) { assertEquals(1, v8ValueFunction.callInteger(null)); @@ -1623,8 +1619,12 @@ public void testGetScopeInfosWith1Closure() throws JavetException { IV8ValueFunction.ScopeInfo scopeInfo2 = scopeInfos.get(2); List keys = scopeInfo2.getScopeObject().getOwnPropertyNameStrings(); if (v8Runtime.getJSRuntimeType().isNode()) { - assertEquals(14, keys.size()); - keys.forEach(key -> assertTrue(globalVariables.contains(key))); + Set globalVariables = new HashSet<>(Arrays.asList(( + "global,queueMicrotask,clearImmediate,setImmediate," + + "structuredClone,clearInterval,clearTimeout,setInterval," + + "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 { assertEquals(0, keys.size()); }