Skip to content

Commit 37f68a3

Browse files
committed
Cleanup.
At this point, *on macOS*, the following commands result in a build of `samples/Hello-Java.Base` which use MonoVM + the Mono GC bridge: # prepare and build the repo against .NET 8, as that has the needed MonoVM packages dotnet build -c Release -t:Prepare -p:DotNetTargetFramework=net8.0 *.sln dotnet build -c Release -p:DotNetTargetFramework=net8.0 *.sln # Publish the Hello-Java.Base sample; must be `--self-contained` + `-p:UseMonoRuntime=true` # to get the MonoVM dotnet publish -c Release --self-contained -p:UseMonoRuntime=true -p:DotNetTargetFramework=net8.0 -p:UseAppHost=true -p:ErrorOnDuplicatePublishOutputFiles=false -r osx-x64 samples/Hello-Java.Base/Hello-Java.Base.csproj # Something is missing in the targets that `Hello-Java.Base.jar` isn't copied; copy it. # TODO: fix this. cp samples/Hello-Java.Base/bin/Release/Hello-Java.Base.jar samples/Hello-Java.Base/bin/Release/osx-x64/publish With that setup, you can then run the sample: % samples/Hello-Java.Base/bin/Release/osx-x64/publish/Hello-Java.Base MonoVM support enabled # jonp: LoadJvmLibrary(/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/lib/libjli.dylib)=1164832048 # jonp: JNI_CreateJavaVM=4572626688; JNI_GetCreatedJavaVMs=4572626768 # jonp: executing JNI_CreateJavaVM=1108cbf00 # jonp: r=0 javavm=11272e690 jnienv=7fe0a32e42a8 WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethodV binding? net.dot.jni.sample.MyJLO@70dea4e Next step: how much of this works targeting win-x64?
1 parent 5374db6 commit 37f68a3

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/java-interop/java-interop.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<DotNetRuntimePacksVersion>8.0.13</DotNetRuntimePacksVersion>
3535
</PropertyGroup>
3636

37-
<ItemGroup Condition=" '$(RuntimeIdentifier)' != '' ">
37+
<ItemGroup Condition=" '$(UseMonoRuntime)' != 'true' And '$(RuntimeIdentifier)' != '' ">
3838
<PackageDownload Include="Microsoft.NETCore.App.Runtime.Mono.$(RuntimeIdentifier)" Version="[$(DotNetRuntimePacksVersion)]" />
3939
</ItemGroup>
4040

src/java-interop/java-interop.targets

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<Project>
22

33
<Import Project="..\..\build-tools\scripts\NativeToolchain.targets" />
4-
<Import Project="obj\java-interop.csproj.nuget.g.props" />
54

65
<PropertyGroup>
76
<RuntimeIdentifier Condition=" '$(RuntimeIdentifier)' == '' ">osx-x64</RuntimeIdentifier>
87
</PropertyGroup>
98

109
<PropertyGroup Condition=" '$(RuntimeIdentifier)' != '' ">
11-
<_MonoNativePath>$(NuGetPackageRoot)/microsoft.netcore.app.runtime.mono.$(RuntimeIdentifier)/$(DotNetRuntimePacksVersion)/runtimes/$(RuntimeIdentifier)/native/</_MonoNativePath>
10+
<_MonoNativePath>$(NuGetPackageRoot)microsoft.netcore.app.runtime.mono.$(RuntimeIdentifier)/$(DotNetRuntimePacksVersion)/runtimes/$(RuntimeIdentifier)/native/</_MonoNativePath>
1211
<_MonoIncludePath>$(_MonoNativePath)include/mono-2.0</_MonoIncludePath>
1312
<_MonoLib>-L $(_MonoNativePath) -lcoreclr</_MonoLib>
1413
<_EnableMono>-DENABLE_MONO_INTEGRATION=ON</_EnableMono>

0 commit comments

Comments
 (0)