From 0b1317078d80b645ec91cef64f8d5e1f1a8f9e5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 21:55:28 +0000 Subject: [PATCH 1/8] Bump MASES.JCOBridge from 2.5.19 to 2.5.20 in /src/net Bumps MASES.JCOBridge from 2.5.19 to 2.5.20. --- updated-dependencies: - dependency-name: MASES.JCOBridge dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/net/JNet/JNet.csproj | 2 +- src/net/JNetReflector/JNetReflector.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/JNet/JNet.csproj b/src/net/JNet/JNet.csproj index ff066b1875..32685f9e85 100644 --- a/src/net/JNet/JNet.csproj +++ b/src/net/JNet/JNet.csproj @@ -52,7 +52,7 @@ - + All None diff --git a/src/net/JNetReflector/JNetReflector.csproj b/src/net/JNetReflector/JNetReflector.csproj index 39b3af7dd4..464bc6409e 100644 --- a/src/net/JNetReflector/JNetReflector.csproj +++ b/src/net/JNetReflector/JNetReflector.csproj @@ -116,7 +116,7 @@ - + All None From 3de29191fb77f7b27369cc4e38a6cac4f5288e25 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:04:25 +0100 Subject: [PATCH 2/8] Update template version --- src/net/JNet/JNet.csproj | 4 +++- .../templates/jcobridgeConsoleApp/jcobridgeConsoleApp.csproj | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/net/JNet/JNet.csproj b/src/net/JNet/JNet.csproj index 32685f9e85..6fdbe8892f 100644 --- a/src/net/JNet/JNet.csproj +++ b/src/net/JNet/JNet.csproj @@ -18,7 +18,9 @@ $(DefineConstants);JNET_SIMPLIFIED_GENERATION - + + false + diff --git a/src/net/templates/templates/jcobridgeConsoleApp/jcobridgeConsoleApp.csproj b/src/net/templates/templates/jcobridgeConsoleApp/jcobridgeConsoleApp.csproj index 387deab2f6..f45bae094f 100644 --- a/src/net/templates/templates/jcobridgeConsoleApp/jcobridgeConsoleApp.csproj +++ b/src/net/templates/templates/jcobridgeConsoleApp/jcobridgeConsoleApp.csproj @@ -11,6 +11,6 @@ - + From 0361ff31afc18a92fc2c500b7af542544bfa0fee Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:06:20 +0100 Subject: [PATCH 3/8] Verify if it is enough JCOBridge change --- src/net/Common/Common.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/net/Common/Common.props b/src/net/Common/Common.props index 905f393b71..ea9ab6d9fc 100644 --- a/src/net/Common/Common.props +++ b/src/net/Common/Common.props @@ -20,10 +20,10 @@ ..\Common\JNet.snk $(NoWarn);0618 - - + true net462;net8.0;net9.0 From c30c0946aaebb83aaf07078d9a7791a00ce64da6 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:19:12 +0100 Subject: [PATCH 4/8] Update license reference --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f052ec10c7..e5f4385838 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -321,7 +321,7 @@ jobs: DOTNET_CreateDumpDiagnostics: 1 DOTNET_CreateDumpVerboseDiagnostics: 1 DOTNET_EnableCrashReport: 1 - JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_5_19 }} + JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_5_20 }} steps: - name: Restore JNet bin from cache @@ -415,7 +415,7 @@ jobs: DOTNET_CreateDumpDiagnostics: 1 DOTNET_CreateDumpVerboseDiagnostics: 1 DOTNET_EnableCrashReport: 1 - JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_5_19 }} + JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_5_20 }} steps: - uses: actions/setup-dotnet@v4 From 7732d13d7572e6fbc7d49b77a0716cd54a12effb Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:44:21 +0100 Subject: [PATCH 5/8] Try executable since dotnet runner is working --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e5f4385838..b222495648 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -362,7 +362,7 @@ jobs: dotnet ./bin/${{ matrix.framework }}/JNetTest.dll dotnet ./bin/${{ matrix.framework }}/JNetByteBufferTest.dll - - if: ${{ matrix.os == 'windows-latest' && matrix.framework == 'net462' }} + - if: ${{ matrix.os == 'windows-latest' }} # && matrix.framework == 'net462' }} continue-on-error: true run: | .\bin\${{ matrix.framework }}\JNetTest.exe From a4ecea85e323c6edf520e1628fdfbc4d5a7f30f7 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:06:41 +0100 Subject: [PATCH 6/8] Documentation update for CET --- README.md | 1 + src/documentation/articles/usage.md | 41 ++++++++++++++++++++++++----- src/documentation/index.md | 1 + 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index aef60cd716..c583eb6f20 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ This project adheres to the Contributor [Covenant code of conduct](CODE_OF_CONDU * review of classes based on latest updates of JNetReflector * enhanced ByteBuffer management * speed-up array/list conversion +* V2.5.11: updates to JCOBridge 2.5.20 and adds management of [CET](https://www.intel.com/content/www/us/en/developer/articles/technical/technical-look-control-flow-enforcement-technology.html) on recent Intel CPU due to [latest change on .NET 9](https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/9.0/cet-support): usage explanation on [this](src/documentation/articles/usage.md#intel-cet-and-jnet) --- diff --git a/src/documentation/articles/usage.md b/src/documentation/articles/usage.md index b835804de6..7c96ad783c 100644 --- a/src/documentation/articles/usage.md +++ b/src/documentation/articles/usage.md @@ -31,9 +31,10 @@ class MyJNetCore : JNetCore } ``` -**IMPORTANT NOTE**: `pathToJVM` shall be escaped -1. `string pathToJVM = "C:\\Program Files\\Eclipse Adoptium\\jdk-11.0.18.10-hotspot\\bin\\server\\jvm.dll";` -2. `string pathToJVM = @"C:\Program Files\Eclipse Adoptium\jdk-11.0.18.10-hotspot\bin\server\jvm.dll";` +> [!IMPORTANT] +> `pathToJVM` shall be escaped +> 1. `string pathToJVM = "C:\\Program Files\\Eclipse Adoptium\\jdk-11.0.18.10-hotspot\\bin\\server\\jvm.dll";` +> 2. `string pathToJVM = @"C:\Program Files\Eclipse Adoptium\jdk-11.0.18.10-hotspot\bin\server\jvm.dll";` ### Special initialization conditions @@ -46,10 +47,36 @@ If the developer/user encounter this condition can do the following steps: 3. Try to set `JAVA_HOME` at system level e.g. `JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-11.0.18.10-hotspot\`; 4. Try to set `JCOBRIDGE_JVMPath` at system level e.g. `JCOBRIDGE_JVMPath=C:\Program Files\Eclipse Adoptium\jdk-11.0.18.10-hotspot\`. -**IMPORTANT NOTES**: -- One of `JCOBRIDGE_JVMPath` or `JAVA_HOME` environment variables or Windows registry (on Windows OSes) shall be available -- `JCOBRIDGE_JVMPath` environment variable takes precedence over `JAVA_HOME` and Windows registry: you can set `JCOBRIDGE_JVMPath` to `C:\Program Files\Eclipse Adoptium\jdk-11.0.18.10-hotspot\bin\server\jvm.dll` and avoid to override `JVMPath` in your code -- After first initialization steps, `JVMPath` takes precedence over `JCOBRIDGE_JVMPath`/`JAVA_HOME` environment variables or Windows registry +> [!IMPORTANT] +> - One of `JCOBRIDGE_JVMPath` or `JAVA_HOME` environment variables or Windows registry (on Windows OSes) shall be available +> - `JCOBRIDGE_JVMPath` environment variable takes precedence over `JAVA_HOME` and Windows registry: you can set `JCOBRIDGE_JVMPath` to `C:\Program Files\Eclipse Adoptium\jdk-11.0.18.10-hotspot\bin\server\jvm.dll` and avoid to override `JVMPath` in your code +> - After first initialization steps, `JVMPath` takes precedence over `JCOBRIDGE_JVMPath`/`JAVA_HOME` environment variables or Windows registry + +### Intel CET and JNet + +JNet uses an embedded JVM through JCOBridge, however JVM initialization is incompatible with [CET](https://www.intel.com/content/www/us/en/developer/articles/technical/technical-look-control-flow-enforcement-technology.html) because the code used to identify CPU try to modify the return address and this is considered from CET a violation: see [comment](https://github.com/masesgroup/JNet/issues/573#issuecomment-2544249107) +From .NET 9 preview 6, [CET is enabled by default on supported hardware](https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/9.0/cet-support) when the final stage produce an executable artifact, i.e. the csproj file contains `Exe`. +If the application, upon startup, fails with the error 0xc0000409 (subcode 0x30) it was compiled with CET enabled and fails during JVM initialization. +To solve the issue there are three possible solutions: +1. use a .NET version, e.g. 8, that does not enable CET by default +2. Add the following snippet to disable CET on executable (templates available for JNet are ready made to solve this issue): + +```xml + + + false + +``` + +3. Use the `dotnet` app host as reported in https://github.com/masesgroup/JCOBridgePublic/issues/7#issuecomment-2550031946 with a syntax like: + +```sh + dotnet MyApplication.dll +``` + instead of the classic: + ```sh + MyApplication.exe +``` ## Basic example diff --git a/src/documentation/index.md b/src/documentation/index.md index 58e6565697..baee093bfe 100644 --- a/src/documentation/index.md +++ b/src/documentation/index.md @@ -90,6 +90,7 @@ This project adheres to the Contributor [Covenant code of conduct](CODE_OF_CONDU * review of classes based on latest updates of JNetReflector * enhanced ByteBuffer management * speed-up array/list conversion +* V2.5.11: updates to JCOBridge 2.5.20 and adds management of [CET](https://www.intel.com/content/www/us/en/developer/articles/technical/technical-look-control-flow-enforcement-technology.html) on recent Intel CPU due to [latest change on .NET 9](https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/9.0/cet-support): usage explanation on [this](articles/usage.md#intel-cet-and-jnet) --- From 68292aee5ce011967c22b2dd2115b5c841f91531 Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:08:55 +0100 Subject: [PATCH 7/8] Revert back to disable CET since tests had failed --- .github/workflows/build.yaml | 2 +- src/net/Common/Common.props | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b222495648..e5f4385838 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -362,7 +362,7 @@ jobs: dotnet ./bin/${{ matrix.framework }}/JNetTest.dll dotnet ./bin/${{ matrix.framework }}/JNetByteBufferTest.dll - - if: ${{ matrix.os == 'windows-latest' }} # && matrix.framework == 'net462' }} + - if: ${{ matrix.os == 'windows-latest' && matrix.framework == 'net462' }} continue-on-error: true run: | .\bin\${{ matrix.framework }}\JNetTest.exe diff --git a/src/net/Common/Common.props b/src/net/Common/Common.props index ea9ab6d9fc..905f393b71 100644 --- a/src/net/Common/Common.props +++ b/src/net/Common/Common.props @@ -20,10 +20,10 @@ ..\Common\JNet.snk $(NoWarn);0618 - false - --> + true net462;net8.0;net9.0 From aee02f461be57fcdfee1a153bbbf2a2c1699f00b Mon Sep 17 00:00:00 2001 From: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:14:33 +0100 Subject: [PATCH 8/8] Document fix --- src/documentation/articles/usage.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/documentation/articles/usage.md b/src/documentation/articles/usage.md index 7c96ad783c..e618bbd8ed 100644 --- a/src/documentation/articles/usage.md +++ b/src/documentation/articles/usage.md @@ -54,12 +54,15 @@ If the developer/user encounter this condition can do the following steps: ### Intel CET and JNet -JNet uses an embedded JVM through JCOBridge, however JVM initialization is incompatible with [CET](https://www.intel.com/content/www/us/en/developer/articles/technical/technical-look-control-flow-enforcement-technology.html) because the code used to identify CPU try to modify the return address and this is considered from CET a violation: see [comment](https://github.com/masesgroup/JNet/issues/573#issuecomment-2544249107) +JNet uses an embedded JVM through JCOBridge, however JVM initialization is incompatible with [CET](https://www.intel.com/content/www/us/en/developer/articles/technical/technical-look-control-flow-enforcement-technology.html) because the code used to identify CPU try to modify the return address and this is considered from CET a violation: see [this comment](https://github.com/masesgroup/JNet/issues/573#issuecomment-2544249107). + From .NET 9 preview 6, [CET is enabled by default on supported hardware](https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/9.0/cet-support) when the final stage produce an executable artifact, i.e. the csproj file contains `Exe`. -If the application, upon startup, fails with the error 0xc0000409 (subcode 0x30) it was compiled with CET enabled and fails during JVM initialization. + +If the application, upon startup, fails with the error 0xc0000409 (subcode 0x30) it was compiled with CET enabled and it fails during JVM initialization. + To solve the issue there are three possible solutions: 1. use a .NET version, e.g. 8, that does not enable CET by default -2. Add the following snippet to disable CET on executable (templates available for JNet are ready made to solve this issue): +2. Add the following snippet to disable CET on executable (templates available for JNet are ready made and solve this issue): ```xml @@ -68,7 +71,7 @@ To solve the issue there are three possible solutions: ``` -3. Use the `dotnet` app host as reported in https://github.com/masesgroup/JCOBridgePublic/issues/7#issuecomment-2550031946 with a syntax like: +3. Use the `dotnet` app host, as reported in https://github.com/masesgroup/JCOBridgePublic/issues/7#issuecomment-2550031946, with a syntax like: ```sh dotnet MyApplication.dll