This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Repository navigation
Commit d493ff7
committed
[jnimarshalmethod-gen] JavaInterop1 marshal methods
Fixes: #1159
Context: c93fea0
`jnimarshalmethod-gen` is intended to generate marshal methods for
any type that that:
* Has `[JavaCallable]` (tested in `Java.Interop.Export-Tests.dll`
and c93fea0), or
* Overrides a `virtual` method which has `[JniMethodSignature]`, or
* Implements an interface method which has `[JniMethodSignature]`.
Thus, the intention was that it should generate marshal methods for
`Java.Base-Tests`:
% dotnet bin/Debug-net7.0/jnimarshalmethod-gen.dll -v bin/TestDebug-net7.0/Java.Base-Tests.dll
Unable to read assembly 'bin/TestDebug-net7.0/Java.Base-Tests.dll' with symbols. Retrying to load it without them.
Preparing marshal method assembly 'Java.Base-Tests-JniMarshalMethods'
Processing Java.BaseTests.JavaInvoker type
Processing Java.BaseTests.MyRunnable type
Processing Java.BaseTests.MyIntConsumer type
Marshal method assembly 'Java.Base-Tests-JniMarshalMethods' created
Notably missing? No messages stating:
Adding marshal method for …
Also missing? `ikdasm bin/TestDebug-net7.0/Java.Base-Tests.dll`
showed that there were no `__RegisterNativeMembers()` methods emitted.
The `jnimarshalmethod-gen` invocation was a no-op!
The problems were twofold:
1. It was only looking for methods with
`Android.Runtime.RegisterAttribute`. This was useful for
Xamarin.Android (when we were trying to make it work), but
doesn't work with Java.Base. We need to *also* look for
`Java.Interop.JniMethodSignature`.
Relatedly, the attempt to use
`registerAttribute.Constructor.Parameters` to determine parameter
names didn't work; the parameter name was always `""`.
2. A'la c93fea0, we need to ensure that the Java `native` methods
we register are consistent with `jcw-gen` output.
Fix these two problems, which allows `jnimarshalmethod-gen` to now
emit marshal methods for types within `Java.Base-Tests.dll`.
Additionally, rework the `jnimarshalmethod-gen -f` logic to *remove*
the existing `__<$>_jni_marshal_methods` nested type when present.1 parent c93fea0 commit d493ff7
2 files changed
Lines changed: 38 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
149 | 169 | | |
150 | 170 | | |
151 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
480 | | - | |
| 479 | + | |
481 | 480 | | |
482 | | - | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
483 | 487 | | |
484 | 488 | | |
485 | 489 | | |
| |||
512 | 516 | | |
513 | 517 | | |
514 | 518 | | |
515 | | - | |
| 519 | + | |
516 | 520 | | |
517 | 521 | | |
518 | 522 | | |
| |||
550 | 554 | | |
551 | 555 | | |
552 | 556 | | |
553 | | - | |
554 | 557 | | |
555 | 558 | | |
556 | 559 | | |
557 | 560 | | |
558 | 561 | | |
559 | 562 | | |
560 | 563 | | |
561 | | - | |
| 564 | + | |
562 | 565 | | |
563 | 566 | | |
564 | 567 | | |
| |||
739 | 742 | | |
740 | 743 | | |
741 | 744 | | |
742 | | - | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
743 | 748 | | |
744 | 749 | | |
745 | 750 | | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
| 751 | + | |
762 | 752 | | |
763 | 753 | | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
| 754 | + | |
| 755 | + | |
769 | 756 | | |
770 | | - | |
| 757 | + | |
771 | 758 | | |
772 | 759 | | |
773 | 760 | | |
| |||
808 | 795 | | |
809 | 796 | | |
810 | 797 | | |
811 | | - | |
| 798 | + | |
812 | 799 | | |
813 | 800 | | |
814 | 801 | | |
815 | 802 | | |
816 | 803 | | |
817 | 804 | | |
| 805 | + | |
818 | 806 | | |
819 | 807 | | |
820 | 808 | | |
| |||
0 commit comments