CARVIEW |
Select Language
HTTP/2 301
date: Wed, 23 Jul 2025 07:19:58 GMT
content-type: text/html; charset=utf-8
content-length: 0
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
location: https://github.com/dotnet/java-interop/commit/220b87fbbb8d986c2c8951757aa3ea45d8e7e7eb
cache-control: no-cache
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
set-cookie: _gh_sess=FebB8UjiEcFNIR7KlLki2WIaiFa5k%2BchaGKeVgYRdXRU5EF2fDSU9GJsAcuUFucW%2B6Z38xgQ5h4HF2QMHYsFtUpI9V%2FNaQrB5wLS2Oxm2JFqnPC3S0ZFn6ecf0QeM4UYFi6KrKScDNyJc4eOA4iMGZSSMvORqM1Ing5WsVvi7dlc2hTpXKsjuh4vPCX37iy6iiuhyGpJ3wdwI9MDQVbB6RDbFpyCaVbAsGczQm85cW%2BtDMFJChSEPTUNQ4sGpHPeU6fb2tzrf1sLGfYhe5suPw%3D%3D--dmuFJljrjiG2tsDK--vg3UbC7qH3HcvOnqCf%2FKwQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1552966213.1753255198; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 07:19:58 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Thu, 23 Jul 2026 07:19:58 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: E770:941DF:608C7F:79F6DD:68808D1E
HTTP/2 200
date: Wed, 23 Jul 2025 07:19:59 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/dotnet/java-interop.git
etag: W/"925478b018a3aa091b2aa7f6f4d61a2a"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
x-github-request-id: E770:941DF:608CDC:79F743:68808D1E
[tests] rework JavaObjectTest, use FinalizerHelper from mono/mono (#899) · dotnet/java-interop@220b87f · GitHub
Copy file name to clipboard
Copy file name to clipboardExpand all lines: tests/Java.Interop-Tests/Java.Interop/JavaObjectTest.cs
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit 220b87f
authored
[tests] rework JavaObjectTest, use FinalizerHelper from mono/mono (#899)
Context: dotnet/android#6363
Context: dotnet/runtime#60638 (comment)
Context: d1d64c1
Context: dotnet/android@c2c9ed4
We were seeing `JavaObjectTest.Dispose_Finalized()` fail in a .NET 6
bump in xamarin-android 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, which internally uses a `Thread`.
This did not solve this issue; we need to fix up the test to wait for
two GCs to complete, on two separate threads:
FinalizerHelpers.PerformNoPinAction (() => {
FinalizerHelpers.PerformNoPinAction (() => {
var v = new JavaDisposedObject (() => d = true, () => f = true);
GC.KeepAlive (v);
});
// Thread 2
JniEnvironment.Runtime.ValueManager.CollectPeers ();
});
// Thread 1
JniEnvironment.Runtime.ValueManager.CollectPeers ();
`ValueManager.CollectPeers()` uses `GC.Collect()`, and `GC.Collect()`
needs to be called from two separate threads because, as per @BrzVlad:
> if an object is alive then the GC will scan it and, by doing so, it
> will probably store it in the stack somewhere. In very unfortunate
> scenarios, at the second collection, the pinning step will find this
> reference existing on the stack and will pin the object (that might
> have now been dead otherwise). Because the `JavaDisposedObject` is
> alive during the first collection, we do this collection on a
> separate thread, so the second GC doesn't get to find this left over
> references on the stack.
With this change in place, the test now passes.
We can also remove the category added in d1d64c1.1 parent f658ab2 commit 220b87fCopy full SHA for 220b87f
File tree
Expand file treeCollapse file tree
2 files changed
+56
-19
lines changedFilter options
- tests/Java.Interop-Tests/Java.Interop
Expand file treeCollapse file tree
2 files changed
+56
-19
lines changedtests/Java.Interop-Tests/Java.Interop/FinalizerHelpers.cs
Copy file name to clipboard+47Lines changed: 47 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + |
tests/Java.Interop-Tests/Java.Interop/JavaObjectTest.cs
Copy file name to clipboardExpand all lines: tests/Java.Interop-Tests/Java.Interop/JavaObjectTest.cs+9-19Lines changed: 9 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 |
| - | |
3 | 2 |
| |
4 | 3 |
| |
5 | 4 |
| |
| |||
18 | 17 |
| |
19 | 18 |
| |
20 | 19 |
| |
21 |
| - | |
| 20 | + | |
22 | 21 |
| |
23 | 22 |
| |
24 | 23 |
| |
25 | 24 |
| |
26 |
| - | |
27 |
| - | |
28 | 25 |
| |
29 | 26 |
| |
30 | 27 |
| |
| |||
80 | 77 |
| |
81 | 78 |
| |
82 | 79 |
| |
83 |
| - | |
| 80 | + | |
84 | 81 |
| |
85 | 82 |
| |
86 | 83 |
| |
87 | 84 |
| |
88 |
| - | |
89 |
| - | |
90 | 85 |
| |
91 | 86 |
| |
92 | 87 |
| |
| |||
110 | 105 |
| |
111 | 106 |
| |
112 | 107 |
| |
113 |
| - | |
114 |
| - | |
115 | 108 |
| |
116 | 109 |
| |
117 | 110 |
| |
118 | 111 |
| |
119 |
| - | |
120 |
| - | |
121 |
| - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
122 | 118 |
| |
123 |
| - | |
124 |
| - | |
125 |
| - | |
126 |
| - | |
127 | 119 |
| |
128 | 120 |
| |
129 | 121 |
| |
| |||
185 | 177 |
| |
186 | 178 |
| |
187 | 179 |
| |
188 |
| - | |
| 180 | + | |
189 | 181 |
| |
190 | 182 |
| |
191 |
| - | |
192 |
| - | |
193 | 183 |
| |
194 | 184 |
| |
195 | 185 |
| |
|
You can’t perform that action at this time.
0 commit comments