Skip to content

Commit

Permalink
Javet v0.9.13 (#94)
Browse files Browse the repository at this point in the history
* Upgraded V8 to `v9.4.146.16` [(2021-09-14)](https://v8.dev/blog/v8-release-94)
* Added support to generator object
* Added `hasInternalType()` and `isGeneratorObject()` to `IV8ValueObject`
* Added `isGeneratorFunction()` and `isAsyncFunction()` to `IV8ValueFunction`
* Added support to `Optional` and `Stream` in converters and callbacks
* Added `IJavetAnonymous` creating ad-hoc annotation based callback receiver
* Added `V8VirtualEscapableValue`
* Added `getMethodNameFromLambda` and `getMethodNameSetFromLambdas` to `JavetReflectionUtils`
* Enabled decorating a function with both `@V8Function` and `@V8Property`
* Enhanced `V8Flags` to accept custom flags
  • Loading branch information
caoccao authored Sep 24, 2021
1 parent 12c7930 commit 26e385c
Show file tree
Hide file tree
Showing 376 changed files with 6,882 additions and 1,562 deletions.
18 changes: 9 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Major Features
==============

* Linux + Mac OS + ️Windows (x86_64)
* Node.js ``v14.17.6`` + V8 ``v9.3.345.16``
* Dynamic switch between Node.js and V8 mode
* Node.js ``v14.17.6`` + V8 ``v9.4.146.16`` (`Which Node.js version do you prefer? <https://github.com/caoccao/Javet/issues/89>`_)
* 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>`_
* Exposure of the majority of V8 API in JVM
* V8 API exposure in JVM
* JavaScript and Java interop
* Native BigInt and Date
* Javet engine pool
Expand All @@ -52,31 +52,31 @@ Maven
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet</artifactId>
<version>0.9.12</version>
<version>0.9.13</version>
</dependency>
<!-- Mac OS (x86_64 Only) -->
<dependency>
<groupId>com.caoccao.javet</groupId>
<artifactId>javet-macos</artifactId>
<version>0.9.12</version>
<version>0.9.13</version>
</dependency>
Gradle Kotlin DSL
^^^^^^^^^^^^^^^^^

.. code-block:: kotlin
implementation("com.caoccao.javet:javet:0.9.12") // Linux or Windows
implementation("com.caoccao.javet:javet-macos:0.9.12") // Mac OS (x86_64 Only)
implementation("com.caoccao.javet:javet:0.9.13") // Linux or Windows
implementation("com.caoccao.javet:javet-macos:0.9.13") // Mac OS (x86_64 Only)
Gradle Groovy DSL
^^^^^^^^^^^^^^^^^

.. code-block:: groovy
implementation 'com.caoccao.javet:javet:0.9.12' // Linux or Windows
implementation 'com.caoccao.javet:javet-macos:0.9.12' // Mac OS (x86_64 Only)
implementation 'com.caoccao.javet:javet:0.9.13' // Linux or Windows
implementation 'com.caoccao.javet:javet-macos:0.9.13' // Mac OS (x86_64 Only)
Hello Javet
-----------
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 = "0.9.12"
version = "0.9.13"

repositories {
mavenCentral()
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=0.9.12
JAVET_VERSION=0.9.13
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=0.9.12
JAVET_VERSION=0.9.13
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=0.9.12
SET JAVET_VERSION=0.9.13
rd /s/q build
mkdir build
cd build
Expand Down
75 changes: 71 additions & 4 deletions cpp/jni/com_caoccao_javet_interop_V8Native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,20 +542,21 @@ JNIEXPORT jlongArray JNICALL Java_com_caoccao_javet_interop_V8Native_getInternal
JNIEXPORT jint JNICALL Java_com_caoccao_javet_interop_V8Native_getJSFunctionType
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType) {
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle);
using namespace Javet::Enums::JSFunctionType;
if (IS_V8_FUNCTION(v8ValueType)) {
auto v8InternalFunction = V8InternalJSFunction::cast(*v8::Utils::OpenHandle(*v8LocalValue));
auto v8InternalShared = v8InternalFunction.shared();
if (v8InternalShared.native()) {
return Javet::Enums::JSFunctionType::Native;
return JSFunctionType::Native;
}
else if (v8InternalShared.IsApiFunction()) {
return Javet::Enums::JSFunctionType::API;
return JSFunctionType::API;
}
else if (v8InternalShared.IsUserJavaScript()) {
return Javet::Enums::JSFunctionType::UserDefined;
return JSFunctionType::UserDefined;
}
}
return Javet::Enums::JSFunctionType::Unknown;
return JSFunctionType::Unknown;
}

JNIEXPORT jint JNICALL Java_com_caoccao_javet_interop_V8Native_getJSScopeType
Expand Down Expand Up @@ -724,6 +725,72 @@ JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_has
return false;
}

JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_hasInternalType
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueInternalType) {
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle);
using namespace Javet::Enums::V8ValueInternalType;
switch (v8ValueInternalType)
{
case V8ValueInternalType::Undefined: return v8LocalValue->IsUndefined(); // 0
case V8ValueInternalType::Null: return v8LocalValue->IsNull(); // 1
case V8ValueInternalType::NullOrUndefined: return v8LocalValue->IsNullOrUndefined(); // 2
case V8ValueInternalType::True: return v8LocalValue->IsTrue(); // 3
case V8ValueInternalType::False: return v8LocalValue->IsFalse(); // 4
case V8ValueInternalType::Name: return v8LocalValue->IsName(); // 5
case V8ValueInternalType::String: return v8LocalValue->IsString(); // 6
case V8ValueInternalType::Symbol: return v8LocalValue->IsSymbol(); // 7
case V8ValueInternalType::Function: return v8LocalValue->IsFunction(); // 8
case V8ValueInternalType::Array: return v8LocalValue->IsArray(); // 9
case V8ValueInternalType::Object: return v8LocalValue->IsObject(); // 10
case V8ValueInternalType::BigInt: return v8LocalValue->IsBigInt(); // 11
case V8ValueInternalType::Boolean: return v8LocalValue->IsBoolean(); // 12
case V8ValueInternalType::Number: return v8LocalValue->IsNumber(); // 13
case V8ValueInternalType::External: return v8LocalValue->IsExternal(); // 14
case V8ValueInternalType::Int32: return v8LocalValue->IsInt32(); // 15
case V8ValueInternalType::Date: return v8LocalValue->IsDate(); // 16
case V8ValueInternalType::ArgumentsObject: return v8LocalValue->IsArgumentsObject(); // 17
case V8ValueInternalType::BigIntObject: return v8LocalValue->IsBigIntObject(); // 18
case V8ValueInternalType::BooleanObject: return v8LocalValue->IsBooleanObject(); // 19
case V8ValueInternalType::NumberObject: return v8LocalValue->IsNumberObject(); // 20
case V8ValueInternalType::StringObject: return v8LocalValue->IsStringObject(); // 21
case V8ValueInternalType::SymbolObject: return v8LocalValue->IsSymbolObject(); // 22
case V8ValueInternalType::NativeError: return v8LocalValue->IsNativeError(); // 23
case V8ValueInternalType::RegExp: return v8LocalValue->IsRegExp(); // 24
case V8ValueInternalType::AsyncFunction: return v8LocalValue->IsAsyncFunction(); // 25
case V8ValueInternalType::GeneratorFunction: return v8LocalValue->IsGeneratorFunction(); // 26
case V8ValueInternalType::GeneratorObject: return v8LocalValue->IsGeneratorObject(); // 27
case V8ValueInternalType::Promise: return v8LocalValue->IsPromise(); // 28
case V8ValueInternalType::Map: return v8LocalValue->IsMap(); // 29
case V8ValueInternalType::Set: return v8LocalValue->IsSet(); // 30
case V8ValueInternalType::MapIterator: return v8LocalValue->IsMapIterator(); // 31
case V8ValueInternalType::SetIterator: return v8LocalValue->IsSetIterator(); // 32
case V8ValueInternalType::WeakMap: return v8LocalValue->IsWeakMap(); // 33
case V8ValueInternalType::WeakSet: return v8LocalValue->IsWeakSet(); // 34
case V8ValueInternalType::ArrayBuffer: return v8LocalValue->IsArrayBuffer(); // 35
case V8ValueInternalType::ArrayBufferView: return v8LocalValue->IsArrayBufferView(); // 36
case V8ValueInternalType::TypedArray: return v8LocalValue->IsTypedArray(); // 37
case V8ValueInternalType::Uint8Array: return v8LocalValue->IsUint8Array(); // 38
case V8ValueInternalType::Uint8ClampedArray: return v8LocalValue->IsUint8ClampedArray(); // 39
case V8ValueInternalType::Int8Array: return v8LocalValue->IsInt8Array(); // 40
case V8ValueInternalType::Uint16Array: return v8LocalValue->IsUint16Array(); // 41
case V8ValueInternalType::Int16Array: return v8LocalValue->IsInt16Array(); // 42
case V8ValueInternalType::Uint32Array: return v8LocalValue->IsUint32Array(); // 43
case V8ValueInternalType::Int32Array: return v8LocalValue->IsInt32Array(); // 44
case V8ValueInternalType::Float32Array: return v8LocalValue->IsFloat32Array(); // 45
case V8ValueInternalType::Float64Array: return v8LocalValue->IsFloat64Array(); // 46
case V8ValueInternalType::BigInt64Array: return v8LocalValue->IsBigInt64Array(); // 47
case V8ValueInternalType::BigUint64Array: return v8LocalValue->IsBigUint64Array(); // 48
case V8ValueInternalType::DataView: return v8LocalValue->IsDataView(); // 49
case V8ValueInternalType::SharedArrayBuffer: return v8LocalValue->IsSharedArrayBuffer(); // 50
case V8ValueInternalType::Proxy: return v8LocalValue->IsProxy(); // 51
case V8ValueInternalType::WasmModuleObject: return v8LocalValue->IsWasmModuleObject(); // 52
case V8ValueInternalType::ModuleNamespaceObject: return v8LocalValue->IsModuleNamespaceObject(); // 53
default:
break;
}
return false;
}

JNIEXPORT jboolean JNICALL Java_com_caoccao_javet_interop_V8Native_hasOwnProperty
(JNIEnv* jniEnv, jobject caller, jlong v8RuntimeHandle, jlong v8ValueHandle, jint v8ValueType, jobject key) {
RUNTIME_AND_VALUE_HANDLES_TO_OBJECTS_WITH_SCOPE(v8RuntimeHandle, v8ValueHandle);
Expand Down
8 changes: 8 additions & 0 deletions cpp/jni/com_caoccao_javet_interop_V8Native.h

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

5 changes: 1 addition & 4 deletions cpp/jni/javet_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ namespace Javet {
if (v8Value->IsSet()) {
return jniEnv->NewObject(jclassV8ValueSet, jmethodIDV8ValueSetConstructor, ToV8PersistentValueReference(v8Context, v8Value));
}
if (v8Value->IsMapIterator() || v8Value->IsSetIterator()) {
if (v8Value->IsMapIterator() || v8Value->IsSetIterator() || v8Value->IsGeneratorObject()) {
return jniEnv->NewObject(jclassV8ValueIterator, jmethodIDV8ValueIteratorConstructor, ToV8PersistentValueReference(v8Context, v8Value));
}
if (v8Value->IsArgumentsObject()) {
Expand All @@ -313,9 +313,6 @@ namespace Javet {
if (v8Value->IsRegExp()) {
return jniEnv->NewObject(jclassV8ValueRegExp, jmethodIDV8ValueRegExpConstructor, ToV8PersistentValueReference(v8Context, v8Value));
}
if (v8Value->IsGeneratorObject()) {
// It defaults to V8ValueObject.
}
if (v8Value->IsAsyncFunction()) {
// It defaults to V8ValueFunction.
}
Expand Down
59 changes: 59 additions & 0 deletions cpp/jni/javet_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,65 @@ namespace Javet {
};
};

namespace V8ValueInternalType {
enum V8ValueInternalType {
Undefined = 0,
Null = 1,
NullOrUndefined = 2,
True = 3,
False = 4,
Name = 5,
String = 6,
Symbol = 7,
Function = 8,
Array = 9,
Object = 10,
BigInt = 11,
Boolean = 12,
Number = 13,
External = 14,
Int32 = 15,
Date = 16,
ArgumentsObject = 17,
BigIntObject = 18,
BooleanObject = 19,
NumberObject = 20,
StringObject = 21,
SymbolObject = 22,
NativeError = 23,
RegExp = 24,
AsyncFunction = 25,
GeneratorFunction = 26,
GeneratorObject = 27,
Promise = 28,
Map = 29,
Set = 30,
MapIterator = 31,
SetIterator = 32,
WeakMap = 33,
WeakSet = 34,
ArrayBuffer = 35,
ArrayBufferView = 36,
TypedArray = 37,
Uint8Array = 38,
Uint8ClampedArray = 39,
Int8Array = 40,
Uint16Array = 41,
Int16Array = 42,
Uint32Array = 43,
Int32Array = 44,
Float32Array = 45,
Float64Array = 46,
BigInt64Array = 47,
BigUint64Array = 48,
DataView = 49,
SharedArrayBuffer = 50,
Proxy = 51,
WasmModuleObject = 52,
ModuleNamespaceObject = 53,
};
};

namespace V8ValueReferenceType {
enum V8ValueReferenceType {
Invalid = 0,
Expand Down
1 change: 1 addition & 0 deletions cpp/jni/javet_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "javet_callbacks.h"
#include "javet_constants.h"
#include "javet_converter.h"
#include "javet_enums.h"
#include "javet_exceptions.h"
#include "javet_inspector.h"
#include "javet_logging.h"
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 0,9,12,0
PRODUCTVERSION 0,9,12,0
FILEVERSION 0,9,13,0
PRODUCTVERSION 0,9,13,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", "0.9.12.0"
VALUE "InternalName", "libjavet-node-windows-x86_64.v.0.9.12.dll"
VALUE "FileVersion", "0.9.13.0"
VALUE "InternalName", "libjavet-node-windows-x86_64.v.0.9.13.dll"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.0.9.12.dll"
VALUE "OriginalFilename", "libjavet-node-windows-x86_64.v.0.9.13.dll"
VALUE "ProductName", "Javet Windows"
VALUE "ProductVersion", "0.9.12.0"
VALUE "ProductVersion", "0.9.13.0"
END
END
BLOCK "VarFileInfo"
Expand Down
12 changes: 6 additions & 6 deletions cpp/jni/javet_resource_v8.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 0,9,12,0
PRODUCTVERSION 0,9,12,0
FILEVERSION 0,9,13,0
PRODUCTVERSION 0,9,13,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", "0.9.12.0"
VALUE "InternalName", "libjavet-v8-windows-x86_64.v.0.9.12.dll"
VALUE "FileVersion", "0.9.13.0"
VALUE "InternalName", "libjavet-v8-windows-x86_64.v.0.9.13.dll"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.0.9.12.dll"
VALUE "OriginalFilename", "libjavet-v8-windows-x86_64.v.0.9.13.dll"
VALUE "ProductName", "Javet Windows"
VALUE "ProductVersion", "0.9.12.0"
VALUE "ProductVersion", "0.9.13.0"
END
END
BLOCK "VarFileInfo"
Expand Down
9 changes: 4 additions & 5 deletions docker/linux-x86_64/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Usage: docker build -t sjtucaocao/javet:0.9.11 -f docker/linux-x86_64/base.Dockerfile .
# Usage: docker build -t sjtucaocao/javet:0.9.13 -f docker/linux-x86_64/base.Dockerfile .

FROM ubuntu:20.04
WORKDIR /

# Update Ubuntu
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install --upgrade -qq -y --no-install-recommends git curl wget build-essential software-properties-common patchelf maven sudo zip unzip execstack
RUN apt-get install --upgrade -qq -y --no-install-recommends git curl wget build-essential software-properties-common patchelf maven sudo zip unzip execstack cmake
RUN apt-get install --upgrade -qq -y --no-install-recommends python3 python python3-pip python3-distutils python3-testresources
RUN apt-get upgrade -y
RUN pip3 install coloredlogs
Expand All @@ -31,12 +31,12 @@ RUN mkdir google
WORKDIR /google
RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
WORKDIR /google/depot_tools
RUN git checkout remotes/origin/master
RUN git checkout remotes/origin/main
ENV PATH=/google/depot_tools:$PATH
WORKDIR /google
RUN fetch v8
WORKDIR /google/v8
RUN git checkout 9.3.345.16
RUN git checkout 9.4.146.16
RUN sed -i 's/snapcraft/nosnapcraft/g' ./build/install-build-deps.sh
RUN ./build/install-build-deps.sh
RUN sed -i 's/nosnapcraft/snapcraft/g' ./build/install-build-deps.sh
Expand Down Expand Up @@ -76,7 +76,6 @@ ENV GRADLE_HOME="${SDKMAN_HOME}/candidates/gradle/current"
RUN curl -s https://get.sdkman.io | bash
RUN source ${SDKMAN_HOME}/bin/sdkman-init.sh && sdk install gradle 7.2
ENV PATH=$GRADLE_HOME/bin:$PATH
RUN apt-get install --upgrade -qq -y --no-install-recommends cmake

# Shrink
RUN rm -rf ${SDKMAN_HOME}/archives/*
Expand Down
Loading

0 comments on commit 26e385c

Please sign in to comment.