Skip to content

Commit

Permalink
🍂 Javet v2.2.2 (#259)
Browse files Browse the repository at this point in the history
* Upgraded V8 to `v11.6.189.18` (2023-08-08)
* Upgraded Node.js to `v18.17.1` ([2023-08-09](https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#18.17.1))
* Fixed a path resolution bug in the executor for Node.js mode
* Fixed `v8::internal::NativeContext` for V8 mode
  • Loading branch information
caoccao authored Aug 15, 2023
1 parent a7e30b7 commit 72783b6
Show file tree
Hide file tree
Showing 458 changed files with 1,044 additions and 997 deletions.
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: 18.16.1
JAVET_V8_VERSION: 11.5.150.12
JAVET_VERSION: 2.2.1
JAVET_NODE_VERSION: 18.17.1
JAVET_V8_VERSION: 11.6.189.18
JAVET_VERSION: 2.2.2

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: 18.16.1
JAVET_V8_VERSION: 11.5.150.12
JAVET_VERSION: 2.2.1
JAVET_NODE_VERSION: 18.17.1
JAVET_V8_VERSION: 11.6.189.18
JAVET_VERSION: 2.2.2

# 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/macos_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: 18.16.1
JAVET_V8_VERSION: 11.5.150.12
JAVET_VERSION: 2.2.1
JAVET_NODE_VERSION: 18.17.1
JAVET_V8_VERSION: 11.6.189.18
JAVET_VERSION: 2.2.2
ROOT: /Users/runner/work/Javet

jobs:
Expand Down
27 changes: 14 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Javet

|Maven Central| |Discord| |Donate|

|Linux Build| |Android Build|
|Linux Build| |MacOS Build| |Android Build|

.. |Maven Central| image:: https://img.shields.io/maven-central/v/com.caoccao.javet/javet?style=for-the-badge
:target: https://search.maven.org/search?q=g:com.caoccao.javet
Expand All @@ -17,23 +17,24 @@ Javet
.. |Linux Build| image:: https://github.com/caoccao/Javet/actions/workflows/linux_build_artifact.yml/badge.svg
:target: https://github.com/caoccao/Javet/actions/workflows/linux_build_artifact.yml

.. |MacOS Build| image:: https://github.com/caoccao/Javet/actions/workflows/macos_build.yml/badge.svg
:target: https://github.com/caoccao/Javet/actions/workflows/macos_build.yml

.. |Android Build| image:: https://github.com/caoccao/Javet/actions/workflows/android_build.yml/badge.svg
:target: https://github.com/caoccao/Javet/actions/workflows/android_build.yml

`Javet <https://github.com/caoccao/Javet/>`_ is Java + V8 (JAVa + V + EighT). It is an awesome way of embedding Node.js and V8 in Java.

If you like my work, please **Star** this project. And, you may follow me `@sjtucaocao <https://twitter.com/sjtucaocao>`_, or visit http://caoccao.blogspot.com/. And the official support channel is at `discord <https://discord.gg/R4vvKU96gw>`_.

💖 If you use Mac OS (x86_64), please be aware that the Mac OS (x86_64) build will discontinue anytime because I'm no longer able to build new versions of V8 with my `MacBook Air mid-2012 <https://caoccao.blogspot.com/2021/09/macbook-air-mid-2012-from-lion-to-mojave.html>`_. Please `donate <https://opencollective.com/javet>`_ to support me purchasing a new Mac OS (x86_64) device. Or, if you have a retired Mac OS (x86_64) device and are fine with mailing it to me, that will also be great. Thank you for supporting Javet.

💖 If you use Mac OS (arm64), I bought an M2 device and now am able to build it.
💖 If you like my work, please `donate <https://opencollective.com/javet>`_ to support me. If you have a retired Mac OS (x86_64) device and are fine with mailing it to me, that will be great because I don't have such device to support the community. Thank you for supporting Javet.

Major Features
==============

* Linux (x86_64) + Mac OS (x86_64, arm64) + ️Windows (x86_64)
* Android (arm, arm64, x86 and x86_64)
* Node.js ``v18.16.1`` + V8 ``v11.5.150.12``
* Node.js ``v18.17.1`` + V8 ``v11.6.189.18``
* 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 All @@ -58,33 +59,33 @@ Maven
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet</artifactId>
<version>2.2.1</version>
<version>2.2.2</version>
</dependency>
<!-- Mac OS (x86_64 and arm64) -->
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet-macos</artifactId>
<version>2.2.1</version>
<version>2.2.2</version>
</dependency>
Gradle Kotlin DSL
^^^^^^^^^^^^^^^^^

.. code-block:: kotlin
implementation("com.caoccao.javet:javet:2.2.1") // Linux and Windows (x86_64)
implementation("com.caoccao.javet:javet-macos:2.2.1") // Mac OS (x86_64 and arm64)
implementation("com.caoccao.javet:javet-android:2.2.1") // Android (arm, arm64, x86 and x86_64)
implementation("com.caoccao.javet:javet:2.2.2") // Linux and Windows (x86_64)
implementation("com.caoccao.javet:javet-macos:2.2.2") // Mac OS (x86_64 and arm64)
implementation("com.caoccao.javet:javet-android:2.2.2") // Android (arm, arm64, x86 and x86_64)
Gradle Groovy DSL
^^^^^^^^^^^^^^^^^

.. code-block:: groovy
implementation 'com.caoccao.javet:javet:2.2.1' // Linux and Windows (x86_64)
implementation 'com.caoccao.javet:javet-macos:2.2.1' // Mac OS (x86_64 and arm64)
implementation 'com.caoccao.javet:javet-android:2.2.1' // Android (arm, arm64, x86 and x86_64)
implementation 'com.caoccao.javet:javet:2.2.2' // Linux and Windows (x86_64)
implementation 'com.caoccao.javet:javet-macos:2.2.2' // Mac OS (x86_64 and arm64)
implementation 'com.caoccao.javet:javet-android:2.2.2' // Android (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 @@ -21,7 +21,7 @@ plugins {
id("com.android.library")
}

version = "2.2.1"
version = "2.2.2"

android {
compileSdk = 30
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
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.caoccao.javet"
android:versionCode="1"
android:versionName="2.2.1"
android:versionName="2.2.2"
>

</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>2.2.1</version>
<version>2.2.2</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>2.2.1</tag>
<tag>2.2.2</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 @@ -25,7 +25,7 @@ repositories {
}

group = "com.caoccao.javet"
version = "2.2.1"
version = "2.2.2"

dependencies {
testImplementation("org.eclipse.jetty.websocket:websocket-server:9.4.49.v20220914")
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=2.2.1
JAVET_VERSION=2.2.2
rm -rf build
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion cpp/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.1
JAVET_VERSION=2.2.2
rm -rf build
mkdir build
cd build
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=2.2.1
JAVET_VERSION=2.2.2
rm -rf build
mkdir build
cd build
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=2.2.1
SET JAVET_VERSION=2.2.2
rd /s/q build
mkdir build
cd build
Expand Down
19 changes: 17 additions & 2 deletions cpp/jni/javet_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ namespace Javet {
}
else {
FETCH_JNI_ENV(GlobalJavaVM);
jobject mReferrerV8Module = referrer.IsEmpty()
? nullptr
jobject mReferrerV8Module = referrer.IsEmpty()
? nullptr
: Javet::Converter::ToExternalV8Module(jniEnv, v8Runtime, v8Context, referrer);
jobject mIV8Module = jniEnv->CallObjectMethod(
v8Runtime->externalV8Runtime,
Expand Down Expand Up @@ -233,6 +233,21 @@ namespace Javet {
return resolvedV8MaybeLocalModule;
}

#ifndef ENABLE_NODE
void OOMErrorCallback(const char* location, const v8::OOMDetails& oomDetails) noexcept {
LOG_DEBUG("OOM " << location << ", " << oomDetails.is_heap_oom);
if (oomDetails.is_heap_oom) {
auto v8Isolate = v8::Isolate::TryGetCurrent();
if (v8Isolate == nullptr) {
LOG_ERROR("OOMErrorCallback: V8 isolate is not found.");
}
else {
LOG_ERROR("OOMErrorCallback: V8 isolate is found.");
}
}
}
#endif

void JavetPromiseRejectCallback(v8::PromiseRejectMessage message) noexcept {
auto promiseRejectEvent = message.GetEvent();
auto v8LocalPromise = message.GetPromise();
Expand Down
3 changes: 3 additions & 0 deletions cpp/jni/javet_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ namespace Javet {
V8LocalName propertyName,
V8LocalValue propertyValue,
const v8::PropertyCallbackInfo<void>& info) noexcept;
#ifndef ENABLE_NODE
void OOMErrorCallback(const char* location, const v8::OOMDetails& oomDetails) noexcept;
#endif
void JavetPromiseRejectCallback(v8::PromiseRejectMessage message) noexcept;

V8MaybeLocalModule JavetModuleResolveCallback(
Expand Down
6 changes: 3 additions & 3 deletions cpp/jni/javet_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,16 @@ namespace Javet {
auto v8InternalIsolate = reinterpret_cast<V8InternalIsolate*>(v8Context->GetIsolate());
if (v8InternalObject.IsJSObject() || v8InternalObject.IsPrimitive()
|| v8InternalObject.IsJSArray() || v8InternalObject.IsJSTypedArray()) {
auto v8LocalObject = v8::Utils::ToLocal(v8::internal::Handle(v8InternalObject, v8InternalIsolate));
auto v8LocalObject = v8::Utils::ToLocal(v8::internal::handle(v8InternalObject, v8InternalIsolate));
return ToExternalV8Value(jniEnv, v8Runtime, v8Context, v8LocalObject);
}
else if (v8InternalObject.IsContext()) {
auto v8InternalContext = V8InternalContext::cast(v8InternalObject);
auto v8LocalContext = v8::Utils::ToLocal(v8::internal::Handle(v8InternalContext, v8InternalIsolate));
auto v8LocalContext = v8::Utils::ToLocal(v8::internal::handle(v8InternalContext, v8InternalIsolate));
return ToExternalV8Context(jniEnv, v8Runtime, v8Context, v8LocalContext);
}
else if (v8InternalObject.IsModule()) {
auto v8LocalModule = v8::Utils::ToLocal(v8::internal::Handle(V8InternalModule::cast(v8InternalObject), v8InternalIsolate));
auto v8LocalModule = v8::Utils::ToLocal(v8::internal::handle(V8InternalModule::cast(v8InternalObject), v8InternalIsolate));
return ToExternalV8Module(jniEnv, v8Runtime, v8Context, v8LocalModule);
}
else if (v8InternalObject.IsScript()) {
Expand Down
22 changes: 10 additions & 12 deletions cpp/jni/javet_jni_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionCopyS
auto v8InternalIsolate = reinterpret_cast<V8InternalIsolate*>(v8Context->GetIsolate());
// Clone the shared function info
targetV8InternalShared = *v8InternalIsolate->factory()->CloneSharedFunctionInfo(
v8::internal::Handle(sourceV8InternalShared, v8InternalIsolate));
v8::internal::handle(sourceV8InternalShared, v8InternalIsolate));
// Clone the scope info
auto sourceScopeInfo = sourceV8InternalShared.scope_info();
auto emptyBlocklistHandle = V8InternalStringSet::New(v8InternalIsolate);
auto targetScopeInfo = *V8InternalScopeInfo::RecreateWithBlockList(
v8InternalIsolate, v8::internal::Handle(sourceScopeInfo, v8InternalIsolate), emptyBlocklistHandle);
v8InternalIsolate, v8::internal::handle(sourceScopeInfo, v8InternalIsolate), emptyBlocklistHandle);
targetV8InternalShared.set_raw_scope_info(targetScopeInfo);
targetV8InternalFunction.set_shared(targetV8InternalShared, V8InternalWriteBarrierMode::UPDATE_WRITE_BARRIER);
success = true;
Expand Down Expand Up @@ -204,7 +204,7 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionDisca
if (IS_USER_DEFINED_FUNCTION(v8InternalShared)) {
if (v8InternalShared.CanDiscardCompiled()) {
auto v8InternalIsolate = reinterpret_cast<V8InternalIsolate*>(v8Context->GetIsolate());
V8InternalSharedFunctionInfo::DiscardCompiled(v8InternalIsolate, v8::internal::Handle(v8InternalShared, v8InternalIsolate));
V8InternalSharedFunctionInfo::DiscardCompiled(v8InternalIsolate, v8::internal::handle(v8InternalShared, v8InternalIsolate));
return true;
}
}
Expand All @@ -226,7 +226,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_caoccao_javet_interop_V8Native_functionG
if (length > 0) {
jobjectArray arguments = jniEnv->NewObjectArray(length, Javet::Converter::jclassString, nullptr);
for (int i = 0; i < length; ++i) {
auto v8InternalObjectHandle = v8::internal::Handle(wrappedArguments.get(i), v8InternalIsolate);
auto v8InternalObjectHandle = v8::internal::handle(wrappedArguments.get(i), v8InternalIsolate);
auto v8LocalString = v8::Utils::ToLocal(v8InternalObjectHandle).As<v8::String>();
jstring argument = Javet::Converter::ToJavaString(jniEnv, v8Context, v8LocalString);
jniEnv->SetObjectArrayElement(arguments, i, argument);
Expand Down Expand Up @@ -270,9 +270,7 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetCon
auto v8InternalIsolate = reinterpret_cast<V8InternalIsolate*>(v8Context->GetIsolate());
auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue);
if (v8InternalFunction.has_context()) {
auto v8InternalContextHandle = v8::internal::Handle(v8InternalFunction.context(), v8InternalIsolate);
auto v8LocalContext = v8::Utils::ToLocal(v8InternalContextHandle);
return Javet::Converter::ToExternalV8Context(jniEnv, v8Runtime, v8Context, v8LocalContext);
return Javet::Converter::ToExternalV8Value(jniEnv, v8Runtime, v8Context, v8InternalFunction.context());
}
}
return nullptr;
Expand Down Expand Up @@ -342,7 +340,7 @@ JNIEXPORT jobject JNICALL Java_com_caoccao_javet_interop_V8Native_functionGetSco
auto v8InternalFunction = Javet::Converter::ToV8InternalJSFunction(v8LocalValue);
auto v8InternalShared = v8InternalFunction.shared();
auto v8InternalScopeInfo = v8InternalShared.scope_info();
V8InternalScopeIterator scopeIterator(v8InternalIsolate, v8::internal::Handle(v8InternalFunction, v8InternalIsolate));
V8InternalScopeIterator scopeIterator(v8InternalIsolate, v8::internal::handle(v8InternalFunction, v8InternalIsolate));
uint32_t index = 0;
for (; !scopeIterator.Done(); scopeIterator.Next()) {
auto type = scopeIterator.Type();
Expand Down Expand Up @@ -475,11 +473,11 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetSc
bool positionEquals = startPosition == v8InternalShared.StartPosition() && endPosition == v8InternalShared.EndPosition();
if (!sourceCodeEquals || !positionEquals) {
if (v8InternalShared.CanDiscardCompiled()) {
V8InternalSharedFunctionInfo::DiscardCompiled(v8InternalIsolate, v8::internal::Handle(v8InternalShared, v8InternalIsolate));
V8InternalSharedFunctionInfo::DiscardCompiled(v8InternalIsolate, v8::internal::handle(v8InternalShared, v8InternalIsolate));
v8InternalShared.set_allows_lazy_compilation(true);
}
if (!sourceCodeEquals) {
auto v8InternalScriptHandle = v8::internal::Handle(v8InternalScript, v8InternalIsolate);
auto v8InternalScriptHandle = v8::internal::handle(v8InternalScript, v8InternalIsolate);
if (mCloneScript) {
#ifdef ENABLE_NODE
auto clonedV8InternalScript = v8InternalIsolate->factory()->CloneScript(v8InternalScriptHandle);
Expand Down Expand Up @@ -589,11 +587,11 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_functionSetSo
if (!sourceCodeEquals || !positionEquals) {
// Discard compiled data and set lazy compile.
if (v8InternalShared.CanDiscardCompiled()) {
V8InternalSharedFunctionInfo::DiscardCompiled(v8InternalIsolate, v8::internal::Handle(v8InternalShared, v8InternalIsolate));
V8InternalSharedFunctionInfo::DiscardCompiled(v8InternalIsolate, v8::internal::handle(v8InternalShared, v8InternalIsolate));
v8InternalShared.set_allows_lazy_compilation(true);
}
if (!sourceCodeEquals) {
auto v8InternalScriptHandle = v8::internal::Handle(v8InternalScript, v8InternalIsolate);
auto v8InternalScriptHandle = v8::internal::handle(v8InternalScript, v8InternalIsolate);
if (mCloneScript) {
#ifdef ENABLE_NODE
auto clonedV8InternalScript = v8InternalIsolate->factory()->CloneScript(v8InternalScriptHandle);
Expand Down
12 changes: 6 additions & 6 deletions cpp/jni/javet_resource_node.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,2,1,0
PRODUCTVERSION 2,2,1,0
FILEVERSION 2,2,2,0
PRODUCTVERSION 2,2,2,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "caoccao.com"
VALUE "FileDescription", "caoccao.com"
VALUE "FileVersion", "2.2.1.0"
VALUE "InternalName", "libjavet-node-windows-x86_64.v.2.2.1.dll"
VALUE "FileVersion", "2.2.2.0"
VALUE "InternalName", "libjavet-node-windows-x86_64.v.2.2.2.dll"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.2.2.1.dll"
VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.2.2.2.dll"
VALUE "ProductName", "Javet Windows"
VALUE "ProductVersion", "2.2.1.0"
VALUE "ProductVersion", "2.2.2.0"
END
END
BLOCK "VarFileInfo"
Expand Down
Loading

0 comments on commit 72783b6

Please sign in to comment.