forked from dotnet/java-interop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Java.Runtime.Environment] Support .NET Core
Fixes: dotnet#426 Enable C#8 [Nullable Reference Types][0] for `Java.Runtime.Environment.dll`. Add support for a "non-bridged backend", so that a `JniRuntime.JniValueManager` exists for .NET Core. This new "managed" backed is used if the Mono runtime is *not* used. To work, `ManagedValueManager` holds *strong* references to `IJavaPeerable` instances. As such, tests which required the use of GC integration are now "optional". To make this work, update `JniRuntime.JniValueManager` to have the following new abstract members: partial class JniRuntime { partial class JniValueManager { public abstract bool PeersRequireRelease {get;} public abstract void ReleasePeers (); } } `PeersRequireRelease` shall be `true` when there is no GC bridge. When this is true, `JniValueManager.CollectPeers()` is a no-op. If an `IJavaPeerable` must have disposal logic performed, then `.Dispose()` must be called on that instance. There is no finalization integration. The new `JniValueManager.ReleasePeers()` method: 1. Releases all GREFs for all held peers. This allows Java to collect the Java peers. 2. Stops referencing all `IJavaPeerable` values. This allows the .NET GC to collect the `IJavaPeerable` values. There is no notification to the `IJavaPeerable` instances that this has happened. Update `Java.Interop-Tests.csproj` to define `NO_MARSHAL_MEMBER_BUILDER_SUPPORT` when building for .NET Core. These changes allow all remaining `Java.Interop-Tests` unit tests to execute under .NET Core: dotnet test -v diag '--logger:trx;verbosity=detailed' bin/TestDebug-netcoreapp3.1/Java.Interop-Tests.dll Other changes: * The attempt to retain useful Java-side exceptions in 89a5a22 proved to be incomplete. Add a comment to invoke [`JNIEnv::ExceptionDescribe()`][1]. We don't always want this to be present, but when we do want it… * While `NO_MARSHAL_MEMBER_BUILDER_SUPPORT` is set -- which means that `Java.Interop.Export`-related tests aren't run -- there are some fixes for `Java.Interop.Export` & related unit tests for .NET Core, to avoid the use of generic delegate types and to avoid a `Type.GetType()` which is no longer needed. [0]: https://docs.microsoft.com/dotnet/csharp/nullable-references [1]: https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#ExceptionDescribe
- Loading branch information
Showing
20 changed files
with
616 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.