Skip to content

Commit a5b229d

Browse files
authored
[java-interop] Resuscitate MonoVM GC Bridge (#1316)
Context: dotnet/runtime#112109 Context: f5ce0ad Context: 3824b97 Context: c6c487b Commit f5ce0ad copied portions of the .NET for Android Mono GC Bridge code into `src/java-interop`, but to *build* that code "on Desktop" -- for possible CI and unit test use -- it needed to build against Mono *somehow*. The *actual* "how" was unspecified: * The macOS build implicitly required that `/Library/Frameworks/Mono.framework` exist, and would pull in header files and libraries from there. This directory would only exist if you installed Mono system-wide on your Mac. * Linux and Windows were not support *at all*. Eventually `src/java-interop` got Windows build support in 3824b97. This allowed `Java.Interop-Tests.dll` to run under .NET Core, but this did *not* contain any GC bridge code; it was *just* the JNI wrapper functions such as `java_interop_jnienv_get_version()` and JVM loading functions such as `java_interop_jvm_create()`. Eventually (c6c487b), a native `java-interop` library was not needed *at all*: C#9 function pointers and `NativeLibrary` removed the need for it to be built at all. The Mono GC bridge code within java-interop effectively bitrotted, as nothing *built* it anymore. .NET for Android has its own (original!) copy, and CI is primarily concerned about .NET (Core) and not Mono. (This means the GC bridge *isn't* tested, but everything else is.) Three things have happened in the meantime: 1. The Mono team was absorbed into the .NET team, with the new "MonoVM" as a supported backend for .NET, selectable by setting `$(UseMonoRuntime)`=true on desktop platforms. MonoVM is used by .NET for Android and a supported backend with .NET for iOS, Mac… 2. MonoVM is now provided as NuGet packages! 3. There are now efforts to investigate adding something like the GC Bridge to CoreCLR and NativeAOT; see dotnet/runtime#112109. Some developers involved with this would like to debug how the current GC bridge works. *On desktop Windows*. Embrace the new world order: remove support for using "system" Mono installations, the `_CreateMonoInfoProps` target, generation of `MonoInfo.props`, etc., and instead use MonoVM packages to provide the MonoVM runtime and header files needed for compilation & linking. This allows for a consistent build environment across Linux, macOS, and Windows, though Windows adds one wrinkle: MonoVM doesn't contain a `coreclr.lib` file for linking. Add `coreclr.def` and a `coreclr.lib` file to use for linking against MonoVM on Windows. `coreclr.lib` was created by: lib /def:coreclr.def /out:coreclr.lib /machine:X64 where `coreclr.def` contains the `mono_` symbols that were referenced by the macOS `libjava-interop.dylib` build, as per `nm bin/Release-net8.0/libjava-interop.dylib | grep 'U _mono'`. Update `src/java-interop` so that it builds with the latest MonoVM headers (`<mono/metadata/appdomain.h>` must now be included), and allow it to build under Windows (use `Interlocked*` instead of clang's `__sync_*_and_fetch()`.) There is one ("tiny") problem with this approach: .NET 9 doesn't contain MonoVM packages. For example, the [`Microsoft.NETCore.App.Runtime.Mono.osx-x64` NuGet package][0] was last updated for .NET 9 Preview 7; the last *stable* version is for .NET *8*. Fortunately we only recently migrated to .NET 9 (f30e420). Update `JniRuntime.cs` so that we can build the repo when overriding with `-p:DotNetTargetFramework=net8.0`. Update `Java.Interop.Sdk` so that the `.jar` it creates is appropriately copied to `$(OutputPath)` of the referencing project. This required using `%(Content.CopyToOutputDirectory)`=PreserveNewest alongside using `%(Content.TargetPath)` -- which sets the relative name within `$(OutputPath)` -- and in turn required making `_JavaCreateJcws` run after `CoreCompile` instead of `Build`, so that it would properly participate in `%(CopyToOutputDirectory)` logic. The code to detect that MonoVM is being used within `Java.Runtime.Environment.dll` has changed; the `Mono.Runtime` type no longer exists. Check for `Mono.RuntimeStructs` instead. Update `TestJVM.GetJvmLibraryPath()` so that it can find `bin\BuildRelease\JdkInfo.props` when running an app from the `samples` directory and not from `bin\TestRelease*\…`. All of this allows for `samples/Hello-Java.Base` to be built against and run with MonoVM, on Windows! # need Release config build because `dotnet publish` is implicitly Release dotnet build -c Release -t:Prepare -p:DotNetTargetFramework=net8.0 Java.Interop.sln dotnet build -c Release -p:DotNetTargetFramework=net8.0 Java.Interop.sln # -p:UseMonoRuntime enables use of MonoVM dotnet publish --self-contained -p:UseMonoRuntime=true -p:DotNetTargetFramework=net8.0 -p:UseAppHost=true -p:ErrorOnDuplicatePublishOutputFiles=false samples/Hello-Java.Base/Hello-Java.Base.csproj -r win-x64 Note: replace `-r win-x64` with the appropriate RID for your host. With that setup, you can then run the sample: > samples\Hello-Java.Base\bin\Release\win-x64\publish\Hello-Java.Base.exe MonoVM support enabled # jonp: LoadJvmLibrary(C:\Users\jopryo\android-toolchain\jdk-17\bin\server\jvm.dll)=140710450692096 # jonp: JNI_CreateJavaVM=140710454831248; JNI_GetCreatedJavaVMs=140710454831280 # jonp: executing JNI_CreateJavaVM=7ff9b4ad2890 # jonp: r=0 javavm=7ff9b51fd7f0 jnienv=24d781dddc0 WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethodV binding? net.dot.jni.sample.MyJLO@a09ee92 [0]: https://www.nuget.org/packages/Microsoft.NETCore.App.Runtime.Mono.osx-x64/
1 parent 6096f8b commit a5b229d

File tree

16 files changed

+182
-172
lines changed

16 files changed

+182
-172
lines changed

build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks.targets

-88
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,5 @@
11
<Project>
22

3-
<Target Name="_CreateMonoInfoProps"
4-
Condition=" ($([MSBuild]::IsOSPlatform ('linux')) Or $([MSBuild]::IsOSPlatform ('osx'))) And '$(_MonoPath)' != '' "
5-
AfterTargets="AfterBuild"
6-
DependsOnTargets="_GetLinuxMonoPaths;_GetMacOSMonoPaths"
7-
Inputs="$(MSBuildThisFileFullPath);$(MSBuildThisFileDirectory)Java.Interop.BootstrapTasks.csproj"
8-
Outputs="$(_OutputPath)MonoInfo.props">
9-
<ItemGroup>
10-
<_MonoInfoLine Include="&lt;Project&gt;" />
11-
<_MonoInfoLine Include=" &lt;Choose&gt;" />
12-
<_MonoInfoLine Include=" &lt;When Condition=&quot; %27%24(MonoFrameworkPath)%27 == %27%27 &quot;&gt;" />
13-
<_MonoInfoLine Include=" &lt;PropertyGroup&gt;" />
14-
<_MonoInfoLine Include=" &lt;MonoFrameworkPath&gt;$(_MonoFrameworkPath)&lt;/MonoFrameworkPath&gt;" />
15-
<_MonoInfoLine Include=" &lt;MonoLibs &gt;$(_MonoLibs)&lt;/MonoLibs&gt;" />
16-
<_MonoInfoLine Include=" &lt;/PropertyGroup&gt;" />
17-
<_MonoInfoLine Include=" &lt;ItemGroup&gt;" />
18-
<_MonoInfoLine Include=" &lt;MonoIncludePath Include=&quot;$(_MonoIncludePath)&quot; /&gt;" />
19-
<_MonoInfoLine Include=" &lt;/ItemGroup&gt;" />
20-
<_MonoInfoLine Include=" &lt;/When&gt;" />
21-
<_MonoInfoLine Include=" &lt;/Choose&gt;" />
22-
<_MonoInfoLine Include="&lt;/Project&gt;" />
23-
</ItemGroup>
24-
<WriteLinesToFile
25-
File="$(_OutputPath)MonoInfo.props"
26-
Lines="@(_MonoInfoLine)"
27-
Overwrite="True"
28-
/>
29-
<Touch Files="$(_OutputPath)MonoInfo.props" />
30-
</Target>
31-
32-
<Target Name="_CreateMonoMk"
33-
AfterTargets="AfterBuild"
34-
DependsOnTargets="_GetLinuxMonoPaths;_GetMacOSMonoPaths"
35-
Inputs="$(MSBuildThisFileFullPath);$(MSBuildThisFileDirectory)Java.Interop.BootstrapTasks.csproj"
36-
Outputs="$(_OutputPath)mono.mk">
37-
<ItemGroup>
38-
<_MonoMkLine Include="JI_MONO_LIB_PATH=$(_MonoLibPath)" />
39-
</ItemGroup>
40-
<WriteLinesToFile
41-
File="$(_OutputPath)mono.mk"
42-
Lines="@(_MonoMkLine)"
43-
Overwrite="True"
44-
/>
45-
<Touch Files="$(_OutputPath)mono.mk" />
46-
</Target>
47-
48-
<Target Name="_GetLinuxMonoPath"
49-
Condition=" $([MSBuild]::IsOSPlatform ('linux')) ">
50-
<Exec
51-
Command="which mono"
52-
ConsoleToMsBuild="true"
53-
IgnoreExitCode="true">
54-
<Output TaskParameter="ConsoleOutput" PropertyName="_MonoPath" />
55-
</Exec>
56-
</Target>
57-
58-
<Target Name="_GetLinuxMonoPaths"
59-
DependsOnTargets="_GetLinuxMonoPath"
60-
Condition=" $([MSBuild]::IsOSPlatform ('linux')) And '$(_MonoPath)' != '' ">
61-
<Exec
62-
Command="pkg-config --variable=libdir mono-2"
63-
ConsoleToMsBuild="True">
64-
<Output TaskParameter="ConsoleOutput" PropertyName="_MonoPkgConfigLibdir" />
65-
</Exec>
66-
<Exec
67-
Command="pkg-config --variable=includedir mono-2"
68-
ConsoleToMsBuild="True">
69-
<Output TaskParameter="ConsoleOutput" PropertyName="_MonoPkgConfigIncludedir" />
70-
</Exec>
71-
<PropertyGroup>
72-
<_MonoLibPath>$([System.IO.Path]::GetDirectoryName($(_MonoPath)))/../lib/</_MonoLibPath>
73-
<_MonoFrameworkPath>$(_MonoPkgConfigLibdir)/libmonosgen-2.0.so</_MonoFrameworkPath>
74-
<_MonoIncludePath>$(_MonoPkgConfigIncludedir)</_MonoIncludePath>
75-
<_MonoLibs>-L "$(_MonoPkgConfigLibdir)" -lmonosgen-2.0</_MonoLibs>
76-
</PropertyGroup>
77-
</Target>
78-
79-
<Target Name="_GetMacOSMonoPaths"
80-
Condition=" $([MSBuild]::IsOSPlatform ('osx')) ">
81-
<PropertyGroup>
82-
<_MonoBase>/Library/Frameworks/Mono.framework/</_MonoBase>
83-
<_MonoLibPath>$(_MonoBase)Libraries/</_MonoLibPath>
84-
<_MonoFrameworkPath>$(_MonoLibPath)libmonosgen-2.0.1.dylib</_MonoFrameworkPath>
85-
<_MonoIncludePath>$(_MonoBase)Headers/mono-2.0</_MonoIncludePath>
86-
<_MonoLibs>-L "$(_MonoLibPath)" -lmonosgen-2.0</_MonoLibs>
87-
</PropertyGroup>
88-
</Target>
89-
90-
913
<Target Name="_CreatePackagePathsProps"
924
AfterTargets="AfterBuild"
935
Inputs="$(MSBuildThisFileFullPath);$(MSBuildThisFileDirectory)Java.Interop.BootstrapTasks.csproj"

build-tools/Java.Interop.Sdk/Sdk/Sdk.targets

+19-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</ItemDefinitionGroup>
1111

1212
<PropertyGroup>
13-
<JavaOutputJar Condition=" '$(JavaOutputJar)' == '' ">$(OutputPath)$(AssemblyName).jar</JavaOutputJar>
13+
<JavaOutputJarName Condition=" '$(JavaOutputJarName)' == '' ">$(AssemblyName).jar</JavaOutputJarName>
1414
</PropertyGroup>
1515

1616
<PropertyGroup>
@@ -32,7 +32,7 @@
3232
</Target>
3333

3434
<Target Name="JavaCreateOutputJar"
35-
AfterTargets="Build"
35+
AfterTargets="CoreCompile"
3636
DependsOnTargets="$(JavaCreateOutputJarDependsOn)">
3737
</Target>
3838

@@ -43,8 +43,16 @@
4343
<_JavaManagedBindingDir>$(_JavaIntermediateDir)mcw\</_JavaManagedBindingDir>
4444
<_JavaJcwClassesDir>$(_JavaIntermediateDir)classes\</_JavaJcwClassesDir>
4545
<_JavaJcwSourcesDir>$(_JavaIntermediateDir)java\</_JavaJcwSourcesDir>
46+
<_JavaOutputJarPath>$(_JavaIntermediateDir)$(JavaOutputJarName)</_JavaOutputJarPath>
4647
</PropertyGroup>
4748

49+
<ItemGroup>
50+
<Content Include="$(_JavaOutputJarPath)"
51+
CopyToOutputDirectory="PreserveNewest"
52+
TargetPath="$(JavaOutputJarName)"
53+
/>
54+
</ItemGroup>
55+
4856
<Target Name="_CollectJavaCompileForManagedBindingInputs">
4957
<ItemGroup>
5058
<_JavaCompileForBindingInputs
@@ -169,8 +177,8 @@
169177
<Target Name="_CleanupManagedBinding" />
170178

171179
<Target Name="_JavaCreateJcws"
172-
Condition=" '$(TargetPath)' != '' And Exists($(TargetPath))"
173-
Inputs="$(TargetPath)"
180+
Condition=" '@(IntermediateAssembly)' != '' And Exists(@(IntermediateAssembly))"
181+
Inputs="@(IntermediateAssembly)"
174182
Outputs="$(_JavaJcwSourcesDir).stamp">
175183
<RemoveDir Directories="$(_JavaJcwSourcesDir)" />
176184
<MakeDir Directories="$(_JavaJcwSourcesDir)" />
@@ -184,7 +192,7 @@
184192
<_Output>-o "$(_JavaJcwSourcesDir)."</_Output>
185193
<_Libpath>@(_RefAsmDirs->'-L "%(Identity)"', ' ')</_Libpath>
186194
</PropertyGroup>
187-
<Exec Command="$(DotnetToolPath) $(_JcwGen) -v &quot;$(TargetPath)&quot; $(_Target) $(_Output) $(_Libpath)" />
195+
<Exec Command="$(DotnetToolPath) $(_JcwGen) -v @(IntermediateAssembly->'&quot;%(Identity)&quot;', ' ') $(_Target) $(_Output) $(_Libpath)" />
188196
<Touch Files="$(_JavaJcwSourcesDir).stamp" AlwaysCreate="True" />
189197
</Target>
190198

@@ -197,7 +205,7 @@
197205
<Target Name="_JavaCreateOutputJar"
198206
DependsOnTargets="_JavaCollectGeneratdJcwSource;_JavaCollectJavacRefs"
199207
Inputs="@(_JavaGeneratedJcwSource)"
200-
Outputs="$(JavaOutputJar)">
208+
Outputs="$(_JavaOutputJarPath)">
201209
<RemoveDir Directories="$(_JavaJcwClassesDir)" />
202210
<MakeDir Directories="$(_JavaJcwClassesDir)" />
203211
<PropertyGroup>
@@ -215,7 +223,11 @@
215223
/>
216224
<Exec Command="&quot;$(JavaCPath)&quot; $(_JavacSourceOptions) -d &quot;$(_JavaJcwClassesDir).&quot; -classpath &quot;$(_Classpath)&quot; &quot;@$(_JavaIntermediateDir)_java_sources.txt&quot;" />
217225
<Delete Files="$(_JavaIntermediateDir)_java_sources.txt" />
218-
<Exec Command="&quot;$(JarPath)&quot; cf &quot;$(JavaOutputJar)&quot; -C &quot;$(_JavaJcwClassesDir).&quot; ." />
226+
<Exec Command="&quot;$(JarPath)&quot; cf &quot;$(_JavaOutputJarPath)&quot; -C &quot;$(_JavaJcwClassesDir).&quot; ." />
227+
228+
<ItemGroup>
229+
<FileWrites Include="$(_JavaOutputJarPath)" />
230+
</ItemGroup>
219231
</Target>
220232

221233
</Project>

samples/Hello-Java.Base/Program.cs

+21-3
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,34 @@ class App
1717

1818
public static void Main (string[] args)
1919
{
20-
string? jvmPath = global::Java.InteropTests.TestJVM.GetJvmLibraryPath ();
20+
var logger = (Action<TraceLevel, string>?) null;
21+
string? jvmPath = null;
2122
bool createMultipleVMs = false;
2223
bool reportTiming = false;
2324
bool showHelp = false;
25+
int verbosity = 0;
2426
var options = new OptionSet () {
2527
"Using the JVM from C#!",
2628
"",
2729
"Options:",
2830
{ "jvm=",
29-
$"{{PATH}} to JVM to use. Default is:\n {jvmPath}",
31+
$"{{PATH}} to JVM to use. Default is:\n{Java.InteropTests.TestJVM.GetJvmLibraryPath (logger)}",
3032
v => jvmPath = v },
3133
{ "m",
3234
"Create multiple Java VMs. This will likely crash.",
3335
v => createMultipleVMs = v != null },
3436
{ "t",
3537
$"Timing; invoke Object.hashCode() {N} times, print average.",
3638
v => reportTiming = v != null },
39+
{ "v|verbosity:",
40+
$"Set console log verbosity to {{LEVEL}}. Default is 0.",
41+
(int? v) => {
42+
verbosity = v.HasValue ? v.Value : verbosity + 1;
43+
if (verbosity > 0) {
44+
logger = CreateConsoleLogger ();
45+
}
46+
}
47+
},
3748
{ "h|help",
3849
"Show this message and exit.",
3950
v => showHelp = v != null },
@@ -45,7 +56,7 @@ public static void Main (string[] args)
4556
}
4657
var builder = new JreRuntimeOptions () {
4758
JniAddNativeMethodRegistrationAttributePresent = true,
48-
JvmLibraryPath = jvmPath,
59+
JvmLibraryPath = jvmPath ?? global::Java.InteropTests.TestJVM.GetJvmLibraryPath (logger),
4960
ClassPath = {
5061
Path.Combine (Path.GetDirectoryName (typeof (App).Assembly.Location)!, "Hello-Java.Base.jar"),
5162
},
@@ -70,6 +81,13 @@ public static void Main (string[] args)
7081
CreateJLO ();
7182
}
7283

84+
static Action<TraceLevel, string> CreateConsoleLogger ()
85+
{
86+
return (level, message) => {
87+
Console.WriteLine ($"# {level}: {message}");
88+
};
89+
}
90+
7391
static void CreateJLO ()
7492
{
7593
var jlo = new MyJLO ();

src/Java.Interop/Java.Interop/JniRuntime.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,9 @@ public virtual void OnEnterMarshalMethod ()
445445
public virtual void OnUserUnhandledException (ref JniTransition transition, Exception e)
446446
{
447447
transition.SetPendingException (e);
448-
448+
#if NET9_0_OR_GREATER
449449
Debugger.BreakForUserUnhandledException (e);
450+
#endif // NET9_0_OR_GREATER
450451
}
451452

452453
public virtual void RaisePendingException (Exception pendingException)

src/Java.Runtime.Environment/Java.Interop/JreRuntime.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ static unsafe JreRuntimeOptions CreateJreVM (JreRuntimeOptions builder)
9191
builder.TypeManager ??= new JreTypeManager (builder.typeMappings);
9292
#endif // NET
9393

94-
bool onMono = Type.GetType ("Mono.Runtime", throwOnError: false) != null;
94+
bool onMono = Type.GetType ("Mono.RuntimeStructs", throwOnError: false) != null;
9595
if (onMono) {
96+
Console.WriteLine ($"MonoVM support enabled");
9697
builder.ValueManager = builder.ValueManager ?? new MonoRuntimeValueManager ();
9798
builder.ObjectReferenceManager = builder.ObjectReferenceManager ?? new MonoRuntimeObjectReferenceManager ();
9899
}

src/java-interop/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
coreclr.exp
12
jni.c
23
jni.g.cs

src/java-interop/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(CMAKE_OSX_ARCHITECTURES x86_64 arm64)
1+
cmake_minimum_required(VERSION 3.10.2)
22

33
project(
44
java-interop
@@ -14,8 +14,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1414
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
1515

1616
option(ENABLE_MONO_INTEGRATION "Require Mono runtime" OFF)
17+
option(ENABLE_OSX_ARCHITECTURES "macOS architectures" "")
1718

18-
cmake_minimum_required(VERSION 3.10.2)
19+
set(CMAKE_OSX_ARCHITECTURES ${ENABLE_OSX_ARCHITECTURES})
1920

2021
set(JAVA_INTEROP_CORE_SOURCES
2122
java-interop-dlfcn.cc
@@ -44,7 +45,6 @@ if(ENABLE_MONO_INTEGRATION)
4445
include_directories(${dir})
4546
endforeach()
4647
list(APPEND LINK_FLAGS ${MONO_LINK_FLAGS})
47-
list(APPEND LINK_FLAGS "-Wl,-undefined -Wl,suppress -Wl,-flat_namespace")
4848
set(JAVA_INTEROP_SOURCES ${JAVA_INTEROP_CORE_SOURCES} ${JAVA_INTEROP_MONO_SOURCES})
4949
else()
5050
set(JAVA_INTEROP_SOURCES ${JAVA_INTEROP_CORE_SOURCES})

src/java-interop/coreclr.def

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
LIBRARY CORECLR
2+
3+
EXPORTS
4+
mono_class_from_mono_type
5+
mono_class_get_field_from_name
6+
mono_class_get_name
7+
mono_class_get_namespace
8+
mono_class_is_subclass_of
9+
mono_class_vtable
10+
mono_domain_get
11+
mono_field_get_value
12+
mono_field_set_value
13+
mono_field_static_set_value
14+
mono_gc_register_bridge_callbacks
15+
mono_gc_wait_for_bridge_processing
16+
mono_object_get_class
17+
mono_thread_attach
18+
mono_thread_current
19+
mono_thread_get_managed_id
20+
mono_thread_get_name_utf8

src/java-interop/coreclr.lib

5.53 KB
Binary file not shown.

src/java-interop/java-interop-gc-bridge-mono.cc

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <assert.h>
44
#include <stdlib.h>
55
#include <string.h>
6-
#include <pthread.h>
76
#include <inttypes.h>
87

98
#include "java-interop.h"
@@ -12,6 +11,7 @@
1211
#include "java-interop-util.h"
1312

1413
#ifdef _WINDOWS
14+
#include <windows.h>
1515
#include <fileapi.h>
1616
#endif
1717

@@ -530,13 +530,21 @@ get_object_ref_type (JNIEnv *env, jobject handle)
530530
static int
531531
gref_inc (JavaInteropGCBridge *bridge)
532532
{
533+
#if _WINDOWS
534+
return InterlockedIncrement ((LONG volatile*) &bridge->gc_gref_count);
535+
#else // !_WINDOWS
533536
return __sync_add_and_fetch (&bridge->gc_gref_count, 1);
537+
#endif // _!WINDOWS
534538
}
535539

536540
static int
537541
gref_dec (JavaInteropGCBridge *bridge)
538542
{
543+
#if _WINDOWS
544+
return InterlockedDecrement ((LONG volatile*) &bridge->gc_gref_count);
545+
#else // !_WINDOWS
539546
return __sync_sub_and_fetch (&bridge->gc_gref_count, 1);
547+
#endif // _!WINDOWS
540548
}
541549

542550
#if defined (ANDROID)

src/java-interop/java-interop-mono.h

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "java-interop.h"
55

66
#include <mono/metadata/assembly.h>
7+
#include <mono/metadata/appdomain.h>
78
#include <mono/metadata/class.h>
89
#include <mono/metadata/object.h>
910
#include <mono/metadata/sgen-bridge.h>

src/java-interop/java-interop.csproj

+12-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@
2828

2929
<ItemGroup>
3030
<ProjectReference Include="..\..\build-tools\jnienv-gen\jnienv-gen.csproj" ReferenceOutputAssembly="false" />
31-
</ItemGroup>
31+
</ItemGroup>
32+
33+
<PropertyGroup>
34+
<DotNetRuntimePacksVersion>8.0.13</DotNetRuntimePacksVersion>
35+
</PropertyGroup>
36+
37+
<ItemGroup Condition=" '$(UseMonoRuntime)' != 'true' ">
38+
<PackageDownload
39+
Include="Microsoft.NETCore.App.Runtime.Mono.$(NETCoreSdkRuntimeIdentifier)"
40+
Version="[$(DotNetRuntimePacksVersion)]"
41+
/>
42+
</ItemGroup>
3243

3344
<Import Project="java-interop.targets" />
3445

0 commit comments

Comments
 (0)