Skip to content

Commit

Permalink
🔢 Javet v1.1.5 (#164)
Browse files Browse the repository at this point in the history
* Upgraded Node.js to `v16.15.1` ([2022-06-01](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V16.md#16.15.1))
* Upgraded V8 to `v10.3.174.14` ([2022-06-14](https://v8.dev/blog/v8-release-103))
* Fixed JNI pending exception for Andoird by caching it in the runtime
* Added `V8ValueBigInteger` to primitive types and `JavetPrimitiveConverter`
  • Loading branch information
caoccao authored Jun 22, 2022
1 parent 0836a40 commit 5d2f89e
Show file tree
Hide file tree
Showing 418 changed files with 2,775 additions and 1,397 deletions.
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Major Features

* Linux (x86_64) + Mac OS (x86_64, arm64) + ️Windows (x86_64)
* Android (arm, arm64, x86 and x86_64)
* Node.js ``v16.15.0`` + V8 ``v10.2.154.4``
* Node.js ``v16.15.1`` + V8 ``v10.3.174.14``
* 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,7 +58,7 @@ Maven
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet</artifactId>
<version>1.1.4</version>
<version>1.1.5</version>
</dependency>
<!-- Mac OS (x86_64 and arm64) -->
Expand All @@ -73,18 +73,18 @@ Gradle Kotlin DSL

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

.. code-block:: groovy
implementation 'com.caoccao.javet:javet:1.1.4' // Linux and Windows (x86_64)
implementation 'com.caoccao.javet:javet:1.1.5' // Linux and Windows (x86_64)
implementation 'com.caoccao.javet:javet-macos:1.1.0' // Mac OS (x86_64 and arm64)
implementation 'com.caoccao.javet:javet-android:1.1.4' // Android (arm, arm64, x86 and x86_64)
implementation 'com.caoccao.javet:javet-android:1.1.5' // 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 = "1.1.4"
version = "1.1.5"

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="1.1.4"
android:versionName="1.1.5"
>

</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>1.1.4</version>
<version>1.1.5</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>1.1.4</tag>
<tag>1.1.5</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 = "1.1.4"
version = "1.1.5"

dependencies {
testImplementation("org.eclipse.jetty.websocket:websocket-server:9.4.44.v20210927")
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=1.1.4
JAVET_VERSION=1.1.5
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=1.1.4
JAVET_VERSION=1.1.5
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=1.1.4
JAVET_VERSION=1.1.5
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=1.1.4
SET JAVET_VERSION=1.1.5
rd /s/q build
mkdir build
cd build
Expand Down
183 changes: 93 additions & 90 deletions cpp/jni/com_caoccao_javet_interop_V8Native.cpp

Large diffs are not rendered by default.

31 changes: 18 additions & 13 deletions cpp/jni/javet_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "javet_callbacks.h"
#include "javet_converter.h"
#include "javet_exceptions.h"
#include "javet_logging.h"
#include "javet_native.h"
#include "javet_v8_runtime.h"
Expand Down Expand Up @@ -209,20 +210,25 @@ namespace Javet {
LOG_ERROR("JavetPromiseRejectCallback: V8 runtime is empty.");
}
else {
auto externalV8Runtime = v8Runtime->externalV8Runtime;
jobject value;
if (promiseRejectEvent == v8::PromiseRejectEvent::kPromiseHandlerAddedAfterReject) {
value = Javet::Converter::ToExternalV8ValueUndefined(jniEnv, externalV8Runtime);
value = Javet::Converter::ToExternalV8ValueUndefined(jniEnv, v8Runtime);
}
else {
value = Javet::Converter::ToExternalV8Value(jniEnv, externalV8Runtime, v8Context, message.GetValue());
value = Javet::Converter::ToExternalV8Value(jniEnv, v8Runtime, v8Context, message.GetValue());
}
jniEnv->CallVoidMethod(
externalV8Runtime,
v8Runtime->externalV8Runtime,
jmethodIDV8RuntimeReceivePromiseRejectCallback,
promiseRejectEvent,
Javet::Converter::ToExternalV8Value(jniEnv, externalV8Runtime, v8Context, v8LocalPromise),
Javet::Converter::ToExternalV8Value(jniEnv, v8Runtime, v8Context, v8LocalPromise),
value);
if (value != nullptr) {
jniEnv->DeleteLocalRef(value);
}
if (jniEnv->ExceptionCheck()) {
Javet::Exceptions::ThrowV8Exception(jniEnv, v8Context, "Uncaught JavaError in promise reject callback");
}
}
}
}
Expand Down Expand Up @@ -256,8 +262,8 @@ namespace Javet {
V8ContextScope v8ContextScope(v8Context);
jboolean isReturnResult = IsReturnResult();
jboolean isThisObjectRequired = IsThisObjectRequired();
jobject externalArgs = Javet::Converter::ToExternalV8ValueArray(jniEnv, externalV8Runtime, v8Context, args);
jobject thisObject = isThisObjectRequired ? Javet::Converter::ToExternalV8Value(jniEnv, externalV8Runtime, v8Context, args.This()) : nullptr;
jobject externalArgs = Javet::Converter::ToExternalV8ValueArray(jniEnv, v8Runtime, v8Context, args);
jobject thisObject = isThisObjectRequired ? Javet::Converter::ToExternalV8Value(jniEnv, v8Runtime, v8Context, args.This()) : nullptr;
jobject mResult = jniEnv->CallStaticObjectMethod(
jclassV8FunctionCallback,
jmethodIDV8FunctionCallbackReceiveCallback,
Expand Down Expand Up @@ -316,7 +322,7 @@ namespace Javet {
jobject externalV8Runtime = v8Runtime->externalV8Runtime;
V8ContextScope v8ContextScope(v8Context);
jboolean isThisObjectRequired = IsThisObjectRequired();
jobject thisObject = isThisObjectRequired ? Javet::Converter::ToExternalV8Value(jniEnv, externalV8Runtime, v8Context, args.This()) : nullptr;
jobject thisObject = isThisObjectRequired ? Javet::Converter::ToExternalV8Value(jniEnv, v8Runtime, v8Context, args.This()) : nullptr;
jobject mResult = jniEnv->CallStaticObjectMethod(
jclassV8FunctionCallback,
jmethodIDV8FunctionCallbackReceiveCallback,
Expand Down Expand Up @@ -363,21 +369,20 @@ namespace Javet {
LOG_ERROR("CallPropertySetter: V8 runtime is empty.");
}
else {
jobject externalV8Runtime = v8Runtime->externalV8Runtime;
V8ContextScope v8ContextScope(v8Context);
auto v8Array = v8::Array::New(v8Context->GetIsolate(), 1);
auto maybeResult = v8Array->Set(v8Context, 0, propertyValue);
if (maybeResult.IsNothing()) {
Javet::Exceptions::HandlePendingException(jniEnv, externalV8Runtime, v8Context);
Javet::Exceptions::HandlePendingException(jniEnv, v8Runtime, v8Context);
}
else {
jboolean isThisObjectRequired = IsThisObjectRequired();
jobject thisObject = isThisObjectRequired ? Javet::Converter::ToExternalV8Value(jniEnv, externalV8Runtime, v8Context, args.This()) : nullptr;
jobject mPropertyValue = Javet::Converter::ToExternalV8Value(jniEnv, externalV8Runtime, v8Context, v8Array);
jobject thisObject = isThisObjectRequired ? Javet::Converter::ToExternalV8Value(jniEnv, v8Runtime, v8Context, args.This()) : nullptr;
jobject mPropertyValue = Javet::Converter::ToExternalV8Value(jniEnv, v8Runtime, v8Context, v8Array);
jobject mResult = jniEnv->CallStaticObjectMethod(
jclassV8FunctionCallback,
jmethodIDV8FunctionCallbackReceiveCallback,
externalV8Runtime,
v8Runtime->externalV8Runtime,
callbackContext,
thisObject,
mPropertyValue);
Expand Down
Loading

0 comments on commit 5d2f89e

Please sign in to comment.