Commit a666a6f
authored
[Java.Runtime.Environment] Partial support for .NET Core (#804)
Enable C#8 [Nullable Reference Types][0] for
`Java.Runtime.Environment.dll`.
Add partial 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", conditional on the
`!NO_GC_BRIDGE_SUPPORT` define.
The `ManagedValueManager.CollectPeers()` method calls
`IJavaPeerable.Dispose()` on all currently referenced peers, then
stops referencing the managed peers.
This causes all GREFs to be dropped, allowing Java peers to be
collected, and then allows the .NET GC to collect the `IJavaPeerable`
values.
Any and all exceptions thrown by `IJavaPeerable.Dispose()` are
caught and re-thrown by an `AggregateException`.
Update `Java.Interop-Tests.csproj` to define `NO_GC_BRIDGE_SUPPORT`
and `NO_MARSHAL_MEMBER_BUILDER_SUPPORT` when building for .NET Core.
This excludes all currently "troublesome"/non-passing tests.
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
Passed! - Failed: 0, Passed: 617, Skipped: 1, Total: 618, Duration: 1 s
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#ExceptionDescribe1 parent bba1f07 commit a666a6f
File tree
17 files changed
+598
-87
lines changed- build-tools/automation
- templates
- src
- Java.Interop.Export/Java.Interop
- Java.Interop/Java.Interop
- Java.Runtime.Environment
- Java.Interop
- tests
- Java.Interop-Tests
- Java.Interop
- Java.Interop.Export-Tests/Java.Interop
- TestJVM
17 files changed
+598
-87
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
374 | 379 | | |
375 | 380 | | |
376 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
| |||
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
170 | 188 | | |
171 | 189 | | |
172 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| |||
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 45 | | |
53 | 46 | | |
54 | 47 | | |
| |||
87 | 80 | | |
88 | 81 | | |
89 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
95 | | - | |
| 98 | + | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| |||
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | 172 | | |
217 | 173 | | |
0 commit comments