Skip to content

Commit

Permalink
♨️ Javet v3.1.1 (#318)
Browse files Browse the repository at this point in the history
* Upgraded Node.js to `v20.12.2` ([2024-04-10](https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md#20.12.2))
* Upgraded V8 to `v12.4.254.9` (2024-04-04)
* Updated Node.js to new process initialization and teardown functions
* Added crypto initialization to Node.js
* Removed `isPurgeEventLoopBeforeClose()`, `setPurgeEventLoopBeforeClose()` from `NodeRuntime`
  • Loading branch information
caoccao authored Apr 18, 2024
1 parent 32d8b95 commit ad4cb94
Show file tree
Hide file tree
Showing 534 changed files with 2,256 additions and 2,402 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android_node_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
workflow_dispatch:

env:
JAVET_NODE_VERSION: 20.11.1
JAVET_VERSION: 3.1.0
JAVET_NODE_VERSION: 20.12.2
JAVET_VERSION: 3.1.1
ROOT: /home/runner/work/Javet

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/android_v8_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
workflow_dispatch:

env:
JAVET_V8_VERSION: 12.3.219.10
JAVET_VERSION: 3.1.0
JAVET_V8_VERSION: 12.4.254.9
JAVET_VERSION: 3.1.1
ROOT: /home/runner/work/Javet

jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linux_build_artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ on:
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_REPO_JAVET: ${{ secrets.DOCKERHUB_REPO_JAVET }}
JAVET_NODE_VERSION: 20.11.1
JAVET_V8_VERSION: 12.3.219.10
JAVET_VERSION: 3.1.0
JAVET_NODE_VERSION: 20.12.2
JAVET_V8_VERSION: 12.4.254.9
JAVET_VERSION: 3.1.1

jobs:
javet_linux_x86_64:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linux_build_node_v8_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ on:
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_REPO_JAVET: ${{ secrets.DOCKERHUB_REPO_JAVET }}
JAVET_NODE_VERSION: 20.11.1
JAVET_V8_VERSION: 12.3.219.10
JAVET_VERSION: 3.1.0
JAVET_NODE_VERSION: 20.12.2
JAVET_V8_VERSION: 12.4.254.9
JAVET_VERSION: 3.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.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linux_x86_64_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
workflow_dispatch:

env:
JAVET_NODE_VERSION: 20.11.1
JAVET_V8_VERSION: 12.3.219.10
JAVET_VERSION: 3.1.0
JAVET_NODE_VERSION: 20.12.2
JAVET_V8_VERSION: 12.4.254.9
JAVET_VERSION: 3.1.1
ROOT: /home/runner/work/Javet

jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos_arm64_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
workflow_dispatch:

env:
JAVET_NODE_VERSION: 20.11.1
JAVET_V8_VERSION: 12.3.219.10
JAVET_VERSION: 3.1.0
JAVET_NODE_VERSION: 20.12.2
JAVET_V8_VERSION: 12.4.254.9
JAVET_VERSION: 3.1.1
ROOT: /Users/runner/work/Javet

jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos_x86_64_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
workflow_dispatch:

env:
JAVET_NODE_VERSION: 20.11.1
JAVET_V8_VERSION: 12.3.219.10
JAVET_VERSION: 3.1.0
JAVET_NODE_VERSION: 20.12.2
JAVET_V8_VERSION: 12.4.254.9
JAVET_VERSION: 3.1.1
ROOT: /Users/runner/work/Javet

jobs:
Expand Down
28 changes: 14 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ arm ✔️ ❌ ❌ ❌
arm64 ✔️ ✔️ ✔️ ❌
=========== ======= ======= ======= =======

* Node.js ``v20.11.1`` + V8 ``v12.3.219.10``
* Node.js ``v20.12.2`` + V8 ``v12.4.254.9``
* Dynamic switch between Node.js and V8 mode (`Which mode do you prefer? <https://github.com/caoccao/Javet/discussions/92>`_)
* Polyfill V8 mode with `Javenode <https://github.com/caoccao/Javenode>`_
* V8 API exposure in JVM
Expand Down Expand Up @@ -75,44 +75,44 @@ Maven
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</dependency>
<!-- Linux (arm64) -->
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet-linux-arm64</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</dependency>
<!-- Mac OS (x86_64 and arm64) -->
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet-macos</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</dependency>
Gradle Kotlin DSL
^^^^^^^^^^^^^^^^^

.. code-block:: kotlin
implementation("com.caoccao.javet:javet:3.1.0") // Linux and Windows (x86_64)
implementation("com.caoccao.javet:javet-linux-arm64:3.1.0") // Linux (arm64)
implementation("com.caoccao.javet:javet-macos:3.1.0") // Mac OS (x86_64 and arm64)
implementation("com.caoccao.javet:javet-android-node:3.1.0") // Android Node (arm, arm64, x86 and x86_64)
implementation("com.caoccao.javet:javet-android-v8:3.1.0") // Android V8 (arm, arm64, x86 and x86_64)
implementation("com.caoccao.javet:javet:3.1.1") // Linux and Windows (x86_64)
implementation("com.caoccao.javet:javet-linux-arm64:3.1.1") // Linux (arm64)
implementation("com.caoccao.javet:javet-macos:3.1.1") // Mac OS (x86_64 and arm64)
implementation("com.caoccao.javet:javet-android-node:3.1.1") // Android Node (arm, arm64, x86 and x86_64)
implementation("com.caoccao.javet:javet-android-v8:3.1.1") // Android V8 (arm, arm64, x86 and x86_64)
Gradle Groovy DSL
^^^^^^^^^^^^^^^^^

.. code-block:: groovy
implementation 'com.caoccao.javet:javet:3.1.0' // Linux and Windows (x86_64)
implementation 'com.caoccao.javet:javet-linux-arm64:3.1.0' // Linux (arm64)
implementation 'com.caoccao.javet:javet-macos:3.1.0' // Mac OS (x86_64 and arm64)
implementation 'com.caoccao.javet:javet-android-node:3.1.0' // Android Node (arm, arm64, x86 and x86_64)
implementation 'com.caoccao.javet:javet-android-v8:3.1.0' // Android V8 (arm, arm64, x86 and x86_64)
implementation 'com.caoccao.javet:javet:3.1.1' // Linux and Windows (x86_64)
implementation 'com.caoccao.javet:javet-linux-arm64:3.1.1' // Linux (arm64)
implementation 'com.caoccao.javet:javet-macos:3.1.1' // Mac OS (x86_64 and arm64)
implementation 'com.caoccao.javet:javet-android-node:3.1.1' // Android Node (arm, arm64, x86 and x86_64)
implementation 'com.caoccao.javet:javet-android-v8:3.1.1' // Android V8 (arm, arm64, x86 and x86_64)
Hello Javet
-----------
Expand Down
2 changes: 1 addition & 1 deletion android/javet-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "3.1.0"
const val JAVET = "3.1.1"
const val JUNIT = "5.10.1"
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/javet-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="3.1.0"
android:versionName="3.1.1"
>

</manifest>
4 changes: 2 additions & 2 deletions android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.caoccao.javet</groupId>
<artifactId>javet-android</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<name>javet</name>
<packaging>aar</packaging>
<description>Javet is Java + V8 (JAVa + V + EighT). It is an awesome way of embedding V8 in Java.</description>
Expand All @@ -29,7 +29,7 @@
<connection>scm:git:git://github.com/caoccao/Javet.git</connection>
<developerConnection>scm:git:git@github.com:caoccao/caoccao.git</developerConnection>
<url>https://github.com/caoccao/Javet</url>
<tag>3.1.0</tag>
<tag>3.1.1</tag>
</scm>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object Config {
const val BYTE_BUDDY = "1.14.10"
const val JACKSON_DATABIND = "2.16.0"
const val JAVA_VERSION = "1.8"
const val JAVET = "3.1.0"
const val JAVET = "3.1.1"
const val JETTY_WEBSOCKET = "9.4.53.v20231009"
const val JUNIT = "5.10.1"
}
Expand Down
1 change: 1 addition & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ if(DEFINED V8_DIR)
endif()
if(DEFINED NODE_DIR)
list(APPEND includeDirs
${NODE_DIR}/deps/openssl/openssl/include
${NODE_DIR}/deps/uv/include
${NODE_DIR}/deps/v8
${NODE_DIR}/deps/v8/include
Expand Down
2 changes: 1 addition & 1 deletion cpp/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=3.1.0
JAVET_VERSION=3.1.1
rm -rf build_android
mkdir build_android
cd build_android
Expand Down
2 changes: 1 addition & 1 deletion cpp/build-linux-arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=3.1.0
JAVET_VERSION=3.1.1
rm -rf build_linux_arm64
mkdir build_linux_arm64
cd build_linux_arm64
Expand Down
2 changes: 1 addition & 1 deletion cpp/build-linux-x86_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=3.1.0
JAVET_VERSION=3.1.1
rm -rf build_linux_x86_64
mkdir build_linux_x86_64
cd build_linux_x86_64
Expand Down
2 changes: 1 addition & 1 deletion cpp/build-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=3.1.0
JAVET_VERSION=3.1.1
rm -rf build_macos
mkdir build_macos
cd build_macos
Expand Down
2 changes: 1 addition & 1 deletion cpp/build-windows.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off
REM Usage for V8: build -DV8_DIR=C:\v8
REM Usage for Node: build -DNODE_DIR=C:\node
SET JAVET_VERSION=3.1.0
SET JAVET_VERSION=3.1.1
rd /s/q build_windows
mkdir build_windows
cd build_windows
Expand Down
16 changes: 0 additions & 16 deletions cpp/jni/com_caoccao_javet_interop_NodeNative.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions cpp/jni/javet_jni_core_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,3 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_NodeNative_await
return (jboolean)v8Runtime->Await(umAwaitMode);
}

JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_NodeNative_isPurgeEventLoopBeforeClose
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle) {
#ifdef ENABLE_NODE
auto v8Runtime = Javet::V8Runtime::FromHandle(v8RuntimeHandle);
return v8Runtime->purgeEventLoopBeforeClose;
#else
return false;
#endif
}

JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_NodeNative_setPurgeEventLoopBeforeClose
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jboolean purgeEventLoopBeforeClose) {
#ifdef ENABLE_NODE
auto v8Runtime = Javet::V8Runtime::FromHandle(v8RuntimeHandle);
v8Runtime->purgeEventLoopBeforeClose = purgeEventLoopBeforeClose;
#endif
}
5 changes: 0 additions & 5 deletions cpp/jni/javet_jni_core_v8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,7 @@ JNIEXPORT void JNICALL Java_com_caoccao_javet_interop_V8Native_setWeak

JNIEXPORT jbyteArray JNICALL Java_com_caoccao_javet_interop_V8Native_snapshotCreate
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle) {
#ifdef ENABLE_NODE
auto v8Runtime = Javet::V8Runtime::FromHandle(v8RuntimeHandle);
auto v8Locker = v8Runtime->GetSharedV8Locker();
#else
RUNTIME_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle);
#endif
return v8Runtime->CreateSnapshot(jniEnv);
}

Expand Down
9 changes: 8 additions & 1 deletion cpp/jni/javet_jni_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,17 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_moduleCreate
}
}
}
#ifndef ENABLE_NODE
v8::MemorySpan<const V8LocalString> exportNamesMemorySpan(exportNames.begin(), exportNames.end());
#endif
auto v8LocalModule = v8::Module::CreateSyntheticModule(
v8Context->GetIsolate(),
Javet::Converter::ToV8String(jniEnv, v8Context, mModuleName),
#ifdef ENABLE_NODE
exportNames,
#else
exportNamesMemorySpan,
#endif
Javet::Callback::JavetSyntheticModuleEvaluationStepsCallback);
std::string stringKey("module:{}" + std::to_string(v8LocalModule->GetIdentityHash()));
auto v8LocalStringKey = Javet::Converter::ToV8String(v8Context, stringKey.c_str());
Expand Down Expand Up @@ -226,7 +233,7 @@ JNIEXPORT jstring JNICALL Java_com_caoccao_javet_interop_V8Native_moduleGetResou
#endif
auto v8InternalStringName = v8InternalSyntheticModule.name();
v8LocalObjectName = v8::Utils::ToLocal(v8::internal::handle(v8InternalStringName, v8InternalIsolate));
}
}
if (!v8LocalObjectName.IsEmpty()) {
return Javet::Converter::ToJavaString(jniEnv, v8Context, v8LocalObjectName);
}
Expand Down
31 changes: 18 additions & 13 deletions cpp/jni/javet_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ namespace Javet {
if (!jniEnv->CallStaticBooleanMethod(jclassV8Host, jmethodIDV8HostIsLibraryReloadable)) {
v8::V8::Dispose();
v8::V8::DisposePlatform();
#ifdef ENABLE_NODE
node::TearDownOncePerProcess();
#endif
GlobalV8Platform.reset();
#ifndef ENABLE_NODE
GlobalV8ArrayBufferAllocator.reset();
Expand Down Expand Up @@ -143,18 +146,20 @@ namespace Javet {
#ifdef ENABLE_NODE
uv_setup_args(0, nullptr);
std::vector<std::string> args{ DEFAULT_SCRIPT_NAME };
std::vector<std::string> execArgs;
std::vector<std::string> errors;
auto flags = static_cast<node::ProcessInitializationFlags::Flags>(
node::ProcessInitializationFlags::kNoFlags
| node::ProcessInitializationFlags::kNoStdioInitialization
| node::ProcessInitializationFlags::kNoDefaultSignalHandling
| 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().");
std::unique_ptr<node::InitializationResult> result = node::InitializeOncePerProcess(
args, {
node::ProcessInitializationFlags::kNoFlags,
node::ProcessInitializationFlags::kNoStdioInitialization,
node::ProcessInitializationFlags::kNoDefaultSignalHandling,
node::ProcessInitializationFlags::kNoInitializeV8,
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform,
#ifndef ENABLE_I18N
node::ProcessInitializationFlags::kNoICU,
#endif
node::ProcessInitializationFlags::kNoInitializeCppgc,
});
if (result->exit_code() != 0) {
LOG_ERROR("Failed to call node::InitializeOncePerProcess().");
}
Javet::V8Native::GlobalV8Platform = node::MultiIsolatePlatform::Create(4);
#else
Expand All @@ -171,7 +176,7 @@ namespace Javet {
if (!GlobalV8ArrayBufferAllocator) {
GlobalV8ArrayBufferAllocator = std::shared_ptr<V8ArrayBufferAllocator>();
GlobalV8ArrayBufferAllocator.reset(V8ArrayBufferAllocator::NewDefaultAllocator());
}
}
#endif
LOG_INFO("V8::Initialize() ends.");
}
Expand Down
Loading

0 comments on commit ad4cb94

Please sign in to comment.