Commit 2d453fc
[TrimmableTypeMap] Fix UCO constructor activations (#11094)
* [TrimmableTypeMap] Fix UCO constructor activation parity with legacy
Refactor UCO constructor wrappers to match legacy ManagedPeer.Construct
activation behavior:
- Add WithinNewObjectScope guard: skip activation when the object is
being created from managed code (JNIEnv.StartCreateInstance/NewObject),
preventing double peer creation and GC crashes.
- For non-leaf types (activation ctor on a base type), call
ActivatePeerFromJavaConstructor at runtime instead of inline IL.
This finds the matching managed ctor for the JNI signature (e.g.,
parameterless for "()V") and invokes it via ActivatePeer, preserving
user constructor side effects like field initialization.
- For leaf types, inline the activation ctor call directly in the UCO
with the WithinNewObjectScope guard.
- Emit no-op UCO for open generic type definitions (type params unknown).
- Add ControlFlowBuilder support to PEAssemblyBuilder.EmitBody for
branch instructions (useBranches parameter).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* [TrimmableTypeMap] Remove UCO reflection fallback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Inline activation ctor in UCO wrappers
- UCO constructors directly call activation ctor (no ActivateInstance indirection)
- WithinNewObjectScope guard prevents double peer creation
- No-op UCO for open generic type definitions
- ControlFlowBuilder support in PEAssemblyBuilder
- Remove TrimmableNativeRegistration wrapper and ActivateInstance
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* [TrimmableTypeMap] Remove invalid proxy attribute metadata
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* [TrimmableTypeMap] Strengthen RegisterNatives regression test
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent f09c2f2 commit 2d453fc
5 files changed
Lines changed: 179 additions & 78 deletions
File tree
- src
- Microsoft.Android.Sdk.TrimmableTypeMap/Generator
- Model
- Mono.Android/Microsoft.Android.Runtime
- tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| |||
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
272 | 277 | | |
273 | 278 | | |
274 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
275 | 285 | | |
276 | 286 | | |
277 | 287 | | |
| |||
287 | 297 | | |
288 | 298 | | |
289 | 299 | | |
290 | | - | |
| 300 | + | |
| 301 | + | |
291 | 302 | | |
292 | 303 | | |
293 | 304 | | |
| |||
Lines changed: 127 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
80 | | - | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | | - | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
187 | | - | |
188 | | - | |
189 | 188 | | |
190 | 189 | | |
191 | 190 | | |
| |||
245 | 244 | | |
246 | 245 | | |
247 | 246 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
255 | 252 | | |
256 | 253 | | |
257 | 254 | | |
| |||
352 | 349 | | |
353 | 350 | | |
354 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
355 | 362 | | |
356 | 363 | | |
357 | 364 | | |
| |||
397 | 404 | | |
398 | 405 | | |
399 | 406 | | |
400 | | - | |
| 407 | + | |
401 | 408 | | |
402 | 409 | | |
403 | 410 | | |
| |||
686 | 693 | | |
687 | 694 | | |
688 | 695 | | |
689 | | - | |
| 696 | + | |
690 | 697 | | |
691 | | - | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
692 | 701 | | |
693 | 702 | | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | 703 | | |
698 | | - | |
| 704 | + | |
699 | 705 | | |
700 | 706 | | |
701 | 707 | | |
702 | 708 | | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
720 | 716 | | |
721 | 717 | | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
722 | 813 | | |
723 | 814 | | |
724 | 815 | | |
| |||
Lines changed: 1 addition & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | 150 | | |
184 | 151 | | |
185 | 152 | | |
| |||
208 | 175 | | |
209 | 176 | | |
210 | 177 | | |
| 178 | + | |
211 | 179 | | |
Lines changed: 35 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
191 | 210 | | |
192 | 211 | | |
193 | 212 | | |
| |||
422 | 441 | | |
423 | 442 | | |
424 | 443 | | |
425 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
426 | 455 | | |
427 | | - | |
428 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
429 | 460 | | |
430 | 461 | | |
431 | 462 | | |
432 | | - | |
| 463 | + | |
433 | 464 | | |
434 | 465 | | |
435 | 466 | | |
| |||
0 commit comments