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 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..e618bbd8ed 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,39 @@ 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 [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 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 and 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) --- diff --git a/src/net/JNet/JNet.csproj b/src/net/JNet/JNet.csproj index ff066b1875..6fdbe8892f 100644 --- a/src/net/JNet/JNet.csproj +++ b/src/net/JNet/JNet.csproj @@ -18,7 +18,9 @@ $(DefineConstants);JNET_SIMPLIFIED_GENERATION - + + false + @@ -52,7 +54,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 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 @@ - +