8000 🎄 Javet v1.0.5 by caoccao · Pull Request #114 · caoccao/Javet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

🎄 Javet v1.0.5 #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
65da055
🔧 build(Version): Upgrade to v1.0.5
caoccao Nov 19, 2021
20f3a46
🧪 test(Converter): Add test case for invalid function in proxy converter
caoccao Nov 19, 2021
2111a9f
🐞 fix(JNI): Change post exception handling for Android
caoccao Nov 19, 2021
aad31af
🦄 refactor(Docker): Take out patch for Android
caoccao Nov 20, 2021
cb075fc
📃 docs(Javadoc): Enhance doc for V8Runtime
caoccao Nov 21, 2021
c3bb399
🦄 refactor(Pool): Upgrade pool to expose more statistics
caoccao Nov 22, 2021
187157a
✨ feat(Pool): Add aggregation statistics API
caoccao Nov 22, 2021
b5af470
🦄 refactor(Test): Fix some problems reported by IDEA
caoccao Nov 22, 2021
2b39915
🦄 refactor(JNI): Prepend receive to GC callbacks
caoccao Nov 23, 2021
e1e4b9d
📃 docs(Node.js): Update doc for rebuild script 8000
caoccao Nov 23, 2021
196ea1d
✨ feat(Node.js): Add doc and test for @swc/core
caoccao Nov 23, 2021
711a02f
🦄 refactor(Observer): Add dedicated observers
caoccao Nov 24, 2021
08237aa
🐞 fix(Pool): Change to non-blocking queue
caoccao Nov 25, 2021
3afa156
📃 docs(Statistics): Add 3 screenshots
caoccao Nov 25, 2021
5a5b739
✨ feat(Pool): Carry allocation space
caoccao Nov 25, 2021
89c5c95
🦄 refactor(Pool): Add warning for sleep in getEngine()
caoccao Nov 25, 2021
e1d4d88
🦄 refactor(Pool): Add more error handling
caoccao Nov 25, 2021
22db7db
✨ feat(Pool): Reduce logging frequency in getEngine()
caoccao Nov 25, 2021
0c31234
📃 docs(Pool): Update javadoc
caoccao Nov 25, 2021
3748436
🦄 refactor(Pool): Update sleep algorithm
caoccao Nov 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 8 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,33 @@ Maven
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
</dependency>

<!-- Mac OS (x86_64 Only) -->
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet-macos</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
</dependency>

Gradle Kotlin DSL
^^^^^^^^^^^^^^^^^

.. code-block:: kotlin

implementation("com.caoccao.javet:javet:1.0.4") // Linux or Windows
implementation("com.caoccao.javet:javet-macos:1.0.4") // Mac OS (x86_64 Only)
implementation("com.caoccao.javet:javet-android:1.0.3") // Android (arm, arm64, x86 and x86_64)
implementation("com.caoccao.javet:javet:1.0.5") // Linux or Windows
implementation("com.caoccao.javet:javet-macos:1.0.5") // Mac OS (x86_64 Only)
implementation("com.caoccao.javet:javet-android:1.0.5") // Android (arm, arm64, x86 and x86_64)

Gradle Groovy DSL
^^^^^^^^^^^^^^^^^

.. code-block:: groovy

implementation 'com.caoccao.javet:javet:1.0.4' // Linux or Windows
implementation 'com.caoccao.javet:javet-macos:1.0.4' // Mac OS (x86_64 Only)
implementation 'com.caoccao.javet:javet-android:1.0.3' // Android (arm, arm64, x86 and x86_64)
implementation 'com.caoccao.javet:javet:1.0.5' // Linux or Windows
implementation 'com.caoccao.javet:javet-macos:1.0.5' // Mac OS (x86_64 Only)
implementation 'com.caoccao.javet:javet-android:1.0.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.0.4"
version = "1.0.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.0.4"
android:versionName="1.0.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.0.4</version>
<version>1.0.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.0.4</tag>
<tag>1.0.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.0.4"
version = "1.0.5"

dependencies {
testImplementation("org.eclipse.jetty.websocket:websocket-server:9.4.38.v20210224")
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.0.4
JAVET_VERSION=1.0.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.0.4
JAVET_VERSION=1.0.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.0.4
JAVET_VERSION=1.0.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.0.4
SET JAVET_VERSION=1.0.5
rd /s/q build
mkdir build
cd build
Expand Down
123 changes: 85 additions & 38 deletions cpp/jni/com_caoccao_javet_interop_V8Native.cpp

Large diffs are not rendered by default.

64 changes: 36 additions & 28 deletions cpp/jni/javet_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ namespace Javet {

jclassV8Runtime = (jclass)jniEnv->NewGlobalRef(jniEnv->FindClass("com/caoccao/javet/interop/V8Runtime"));
jmethodIDV8RuntimeGetV8Module = jniEnv->GetMethodID(jclassV8Runtime, "getV8Module", "(Ljava/lang/String;Lcom/caoccao/javet/values/reference/IV8Module;)Lcom/caoccao/javet/values/reference/IV8Module;");
jmethodIDV8RuntimeGCEpilogueCallback = jniEnv->GetMethodID(jclassV8Runtime, "gcEpilogueCallback", "(II)V");
jmethodIDV8RuntimeGCPrologueCallback = jniEnv->GetMethodID(jclassV8Runtime, "gcPrologueCallback", "(II)V");
jmethodIDV8RuntimeReceiveGCEpilogueCallback = jniEnv->GetMethodID(jclassV8Runtime, "receiveGCEpilogueCallback", "(II)V");
jmethodIDV8RuntimeReceiveGCPrologueCallback = jniEnv->GetMethodID(jclassV8Runtime, "receiveGCPrologueCallback", "(II)V");
jmethodIDV8RuntimeReceivePromiseRejectCallback = jniEnv->GetMethodID(jclassV8Runtime, "receivePromiseRejectCallback", "(ILcom/caoccao/javet/values/reference/V8ValuePromise;Lcom/caoccao/javet/values/V8Value;)V");
jmethodIDV8RuntimeRemoveCallbackContext = jniEnv->GetMethodID(jclassV8Runtime, "removeCallbackContext", "(J)V");
}
Expand Down Expand Up @@ -105,7 +105,7 @@ namespace Javet {
FETCH_JNI_ENV(GlobalJavaVM);
auto externalV8Runtime = v8Runtime->externalV8Runtime;
jobject mIV8Module = jniEnv->CallObjectMethod(
externalV8Runtime, jmethodIDV8RuntimeGCEpilogueCallback, (jint)v8GCType, (jint)v8GCCallbackFlags);
externalV8Runtime, jmethodIDV8RuntimeReceiveGCEpilogueCallback, (jint)v8GCType, (jint)v8GCCallbackFlags);
}
}
}
Expand All @@ -124,7 +124,7 @@ namespace Javet {
FETCH_JNI_ENV(GlobalJavaVM);
auto externalV8Runtime = v8Runtime->externalV8Runtime;
jobject mIV8Module = jniEnv->CallObjectMethod(
externalV8Runtime, jmethodIDV8RuntimeGCPrologueCallback, (jint)v8GCType, (jint)v8GCCallbackFlags);
externalV8Runtime, jmethodIDV8RuntimeReceiveGCPrologueCallback, (jint)v8GCType, (jint)v8GCCallbackFlags);
}
}
}
Expand Down Expand Up @@ -255,26 +255,32 @@ namespace Javet {
callbackContext,
thisObject,
externalArgs);
if (jniEnv->ExceptionCheck()) {
Javet::Exceptions::ThrowV8Exception(jniEnv, v8Context, "Uncaught JavaError in function callback");
}
else if (isReturnResult) {
if (mResult == nullptr) {
args.GetReturnValue().SetUndefined();
}
else {
args.GetReturnValue().Set(Javet::Converter::ToV8Value(jniEnv, v8Context, mResult));
}
}
if (thisObject != nullptr) {
jniEnv->DeleteLocalRef(thisObject);
}
if (externalArgs != nullptr) {
jniEnv->DeleteLocalRef(externalArgs);
}
if (mResult != nullptr) {
jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult);
jniEnv->DeleteLocalRef(mResult);
if (jniEnv->ExceptionCheck()) {
if (mResult != nullptr) {
jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult);
jniEnv->DeleteLocalRef(mResult);
}
Javet::Exceptions::ThrowV8Exception(jniEnv, v8Context, "Uncaught JavaError in function callback");
}
else {
if (isReturnResult) {
if (mResult == nullptr) {
args.GetReturnValue().SetUndefined();
}
else {
args.Ge 10000 tReturnValue().Set(Javet::Converter::ToV8Value(jniEnv, v8Context, mResult));
}
}
if (mResult != nullptr) {
jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult);
jniEnv->DeleteLocalRef(mResult);
}
}
}
}
Expand Down Expand Up @@ -308,7 +314,14 @@ namespace Javet {
callbackContext,
thisObject,
nullptr);
if (thisObject != nullptr) {
jniEnv->DeleteLocalRef(thisObject);
}
if (jniEnv->ExceptionCheck()) {
if (mResult != nullptr) {
jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult);
jniEnv->DeleteLocalRef(mResult);
}
Javet::Exceptions::ThrowV8Exception(jniEnv, v8Context, "Uncaught JavaError in property getter callback");
}
else {
Expand All @@ -317,15 +330,10 @@ namespace Javet {
}
else {
args.GetReturnValue().Set(Javet::Converter::ToV8Value(jniEnv, v8Context, mResult));
jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult);
jniEnv->DeleteLocalRef(mResult);
}
}
if (thisObject != nullptr) {
jniEnv->DeleteLocalRef(thisObject);
}
if (mResult != nullptr) {
jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult);
jniEnv->DeleteLocalRef(mResult);
}
}
}
}
Expand Down Expand Up @@ -363,16 +371,16 @@ namespace Javet {
callbackContext,
thisObject,
mPropertyValue);
if (jniEnv->ExceptionCheck()) {
Javet::Exceptions::ThrowV8Exception(jniEnv, v8Context, "Uncaught JavaError in property setter callback");
}
if (thisObject != nullptr) {
jniEnv->DeleteLocalRef(thisObject);
}
if (mResult != nullptr) {
jniEnv->CallStaticVoidMethod(jclassJavetResourceUtils, jmethodIDJavetResourceUtilsSafeClose, mResult);
jniEnv->DeleteLocalRef(mResult);
}
if (jniEnv->ExceptionCheck()) {
Javet::Exceptions::ThrowV8Exception(jniEnv, v8Context, "Uncaught JavaError in property setter callback");
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions cpp/jni/javet_callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace Javet {

static jclass jclassV8Runtime;
static jmethodID jmethodIDV8RuntimeGetV8Module;
static jmethodID jmethodIDV8RuntimeGCEpilogueCallback;
static jmethodID jmethodIDV8RuntimeGCPrologueCallback;
static jmethodID jmethodIDV8RuntimeReceiveGCEpilogueCallback;
static jmethodID jmethodIDV8RuntimeReceiveGCPrologueCallback;
static jmethodID jmethodIDV8RuntimeReceivePromiseRejectCallback;
static jmethodID jmethodIDV8RuntimeRemoveCallbackContext;

Expand Down
19 changes: 12 additions & 7 deletions cpp/jni/javet_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ namespace Javet {
return false;
}

void ThrowJavetCompilationException(JNIEnv* jniEnv, const V8LocalContext& v8Context, const V8TryCatch& v8TryCatch) {
jobject ThrowJavetCompilationException(JNIEnv* jniEnv, const V8LocalContext& v8Context, const V8TryCatch& v8TryCatch) {
if (v8TryCatch.HasTerminated()) {
LOG_ERROR("Compilation has been terminated.");
ThrowJavetTerminatedException(jniEnv, v8TryCatch.CanContinue());
return ThrowJavetTerminatedException(jniEnv, v8TryCatch.CanContinue());
}
else {
LOG_ERROR("Compilation exception.");
Expand All @@ -89,17 +89,19 @@ namespace Javet {
jniEnv->DeleteLocalRef(javetCompilationException);
jniEnv->DeleteLocalRef(javetScriptingError);
}
return nullptr;
}

void ThrowJavetConverterException(JNIEnv* jniEnv, const char* message) {
jobject ThrowJavetConverterException(JNIEnv* jniEnv, const char* message) {
LOG_ERROR(*message);
jniEnv->ThrowNew(jclassJavetConverterException, message);
return nullptr;
}

void ThrowJavetExecutionException(JNIEnv* jniEnv, const V8LocalContext& v8Context, const V8TryCatch& v8TryCatch) {
jobject ThrowJavetExecutionException(JNIEnv* jniEnv, const V8LocalContext& v8Context, const V8TryCatch& v8TryCatch) {
if (v8TryCatch.HasTerminated()) {
LOG_ERROR("Execution has been terminated.");
ThrowJavetTerminatedException(jniEnv, v8TryCatch.CanContinue());
return ThrowJavetTerminatedException(jniEnv, v8TryCatch.CanContinue());
}
else {
LOG_ERROR("Execution exception.");
Expand All @@ -111,9 +113,10 @@ namespace Javet {
jniEnv->Throw(javetExecutionException);
jniEnv->DeleteLocalRef(javetExecutionException);
}
return nullptr;
}

void ThrowJavetOutOfMemoryException(JNIEnv* jniEnv, v8::Isolate* v8Isolate, const char* message) {
jobject ThrowJavetOutOfMemoryException(JNIEnv* jniEnv, v8::Isolate* v8Isolate, const char* message) {
LOG_ERROR(*message);
jstring jStringExceptionMessage = Javet::Converter::ToJavaString(jniEnv, message);
jobject jObjectHeapStatistics = Javet::Monitor::GetHeapStatistics(jniEnv, v8Isolate);
Expand All @@ -125,14 +128,16 @@ namespace Javet {
jniEnv->DeleteLocalRef(jStringExceptionMessage);
jniEnv->DeleteLocalRef(jObjectHeapStatistics);
jniEnv->Throw(javetOutOfMemoryException);
return nullptr;
}

void ThrowJavetTerminatedException(JNIEnv* jniEnv, bool canContinue) {
jobject ThrowJavetTerminatedException(JNIEnv* jniEnv, bool canContinue) {
jthrowable javetTerminatedException = (jthrowable)jniEnv->NewObject(
jclassJavetTerminatedException,
jmethodIDJavetTerminatedExceptionConstructor,
canContinue);
jniEnv->Throw(javetTerminatedException);
return nullptr;
}

void ThrowV8Exception(JNIEnv* jniEnv, const V8LocalContext& v8Context, const char* defaultMessage) {
Expand Down
10 changes: 5 additions & 5 deletions cpp/jni/javet_exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ namespace Javet {
void Initialize(JNIEnv* jniEnv);

bool HandlePendingException(JNIEnv* jniEnv, const V8LocalContext& v8Context, const char* message = nullptr);
void ThrowJavetCompilationException(JNIEnv* jniEnv, const V8LocalContext& v8Context, const V8TryCatch& v8TryCatch);
void ThrowJavetConverterException(JNIEnv* jniEnv, const char* message);
void ThrowJavetExecutionException(JNIEnv* jniEnv, const V8LocalContext& v8Context, const V8TryCatch& v8TryCatch);
void ThrowJavetOutOfMemoryException(JNIEnv* jniEnv, v8::Isolate* v8Isolate, const char* message);
void ThrowJavetTerminatedException(JNIEnv* jniEnv, bool canContinue);
jobject ThrowJavetCompilationException(JNIEnv* jniEnv, const V8LocalContext& v8Context, const V8TryCatch& v8TryCatch);
jobject ThrowJavetConverterException(JNIEnv* jniEnv, const char* message);
jobject ThrowJavetExecutionException(JNIEnv* jniEnv, const V8LocalContext& v8Context, const V8TryCatch& v8TryCatch);
jobject ThrowJavetOutOfMemoryException(JNIEnv* jniEnv, v8::Isolate* v8Isolate, const char* message);
jobject ThrowJavetTerminatedException(JNIEnv* jniEnv, bool canContinue);
void ThrowV8Exception(JNIEnv* jniEnv, const V8LocalContext& v8Context, const char* defaultMessage);
}
}
Loading
0