You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[tests] rework JavaObjectTest, use FinalizerHelper from mono/mono
Context: dotnet/runtime#60638 (comment)
Context: dotnet/android#6363
We were seeing `JavaObjectTest.Dispose_Finalized()` fail in a .NET 6
bump with `$(UseInterpreter)` set to `true`:
Expected: True
But was: False
at Java.InteropTests.JavaObjectTest.Dispose_Finalized()
at System.Reflection.RuntimeMethodInfo.Invoke(Object , BindingFlags , Binder , Object[] , CultureInfo )
The first recommendation was to use a helper method from mono/mono's
unit tests:
https://github.com/mono/mono/blob/8266c5604b8c03882f2b06af27fdea46b142d6b9/mono/mini/TestHelpers.cs#L12
I removed usage of all `System.Threading` in `JavaObjectTest` in favor
of this helper method.
This did not solve this issue; we need to fix up the test to wait for
two GCs to complete:
FinalizerHelpers.PerformNoPinAction (() => {
FinalizerHelpers.PerformNoPinAction (() => {
var v = new JavaDisposedObject (() => d = true, () => f = true);
GC.KeepAlive (v);
});
JniEnvironment.Runtime.ValueManager.CollectPeers ();
});
JniEnvironment.Runtime.ValueManager.CollectPeers ();
With this change in place, the test now passes:
https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=5361266&view=ms.vss-test-web.build-test-results-tab
We can also remove the category added in d1d64c1.
0 commit comments