Skip to content

Commit

Permalink
Bump MASES.JCOBridge from 2.5.19 to 2.5.20 in /src/net (#577)
Browse files Browse the repository at this point in the history
* 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] <support@github.com>

* Update template version

* Verify if it is enough JCOBridge change

* Update license reference

* Try executable since dotnet runner is working

* Documentation update for CET

* Revert back to disable CET since tests had failed

* Document fix

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: masesdevelopers <94312179+masesdevelopers@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and masesdevelopers authored Dec 19, 2024
1 parent 152e883 commit cbf94c3
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

---

Expand Down
44 changes: 37 additions & 7 deletions src/documentation/articles/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 `<OutputType>Exe</OutputType>`.

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
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0'">
<!--see https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/9.0/cet-support-->
<CETCompat>false</CETCompat>
</PropertyGroup>
```

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

Expand Down
1 change: 1 addition & 0 deletions src/documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

---

Expand Down
6 changes: 4 additions & 2 deletions src/net/JNet/JNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<DefineConstants>$(DefineConstants);JNET_SIMPLIFIED_GENERATION</DefineConstants>
</PropertyGroup>
<ItemGroup Condition="True">
<jnet_jars Include="$(ProjectDir)\..\..\..\jars\jnet-*" />
<jnet_jars Include="$(ProjectDir)\..\..\..\jars\jnet-*">
<InProject>false</InProject>
</jnet_jars>
</ItemGroup>
<Target Name="CopyCustomContent" AfterTargets="AfterBuild" Condition="'$(GITHUB_ACTIONS)' != 'true' Or '$(GITHUB_TEST_PREPARATION)' == 'true'">
<Copy SourceFiles="@(jnet_jars)" DestinationFolder="$(OutDir)\jars" />
Expand Down Expand Up @@ -52,7 +54,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="MASES.CLIParser" Version="3.2.1" />
<PackageReference Include="MASES.JCOBridge" Version="2.5.19">
<PackageReference Include="MASES.JCOBridge" Version="2.5.20">
<IncludeAssets>All</IncludeAssets>
<PrivateAssets>None</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/net/JNetReflector/JNetReflector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="MASES.CLIParser" Version="3.2.1" />
<PackageReference Include="MASES.JCOBridge" Version="2.5.19">
<PackageReference Include="MASES.JCOBridge" Version="2.5.20">
<IncludeAssets>All</IncludeAssets>
<PrivateAssets>None</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MASES.JCOBridge" Version="2.5.19" IncludeAssets="All" PrivateAssets="None" />
<PackageReference Include="MASES.JCOBridge" Version="2.5.20" IncludeAssets="All" PrivateAssets="None" />
</ItemGroup>
</Project>

0 comments on commit cbf94c3

Please sign in to comment.