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
{{ message }}
This repository was archived by the owner on Nov 9, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 9, 2026. It is now read-only.
Renaming methods in an abstract class does not rename all the components #496
Besides all the issues in #464 and #466 which I work around for now, I write this <attr /> element to rename the member:
<attrpath="/api/package[@name='kotlin.time']/class[@name='ClockMark']/method[@name='minus-LRDsOJo' and count(parameter)=1 and parameter[1][@type='double']]"name="managedName">Minus</attr>
This element does rename the public component, but the name of the delegate is not changed accordingly - resulting in invalid C# code.
staticDelegatecb_minus-LRDsOJo_D;
#pragma warning disable 0169staticDelegateGetMinus_DHandler(){if(cb_minus-LRDsOJo_D==null)cb_minus-LRDsOJo_D=JNINativeWrapper.CreateDelegate((Func<IntPtr,IntPtr,double,IntPtr>)n_Minus_D);returncb_minus-LRDsOJo_D;}staticIntPtrn_Minus_D(IntPtrjnienv,IntPtrnative__this,doublep0){global::Kotlin.Time.ClockMark__this=global::Java.Lang.Object.GetObject<global::Kotlin.Time.ClockMark>(jnienv,native__this,JniHandleOwnership.DoNotTransfer);returnJNIEnv.ToLocalJniHandle(__this.Minus(p0));}
#pragma warning restore 0169// Metadata.xml XPath method reference: path="/api/package[@name='kotlin.time']/class[@name='ClockMark']/method[@name='minus-LRDsOJo' and count(parameter)=1 and parameter[1][@type='double']]"[Register("minus-LRDsOJo","(D)Lkotlin/time/ClockMark;","GetMinus_DHandler")]publicvirtualunsafeglobal::Kotlin.Time.ClockMarkMinus(doublep0){conststring__id="minus-LRDsOJo.(D)Lkotlin/time/ClockMark;";try{JniArgumentValue*__args=stackallocJniArgumentValue[1];__args[0]=newJniArgumentValue(p0);var__rm=_members.InstanceMethods.InvokeVirtualObjectMethod(__id,this,__args);returnglobal::Java.Lang.Object.GetObject<global::Kotlin.Time.ClockMark>(__rm.Handle,JniHandleOwnership.TransferLocalRef);}finally{}}
The first parameter -- minus-LRDsOJo -- is used by JavaCallableWrapperGenerator so that it knows what Java method name to override, and this Is Not A Valid Java Identifier, but our generator...emits Java code!
WTF is supposed to happen here?
Is this ostensibly Kotlin "virtual" method not overridable by Java? Do we need to emit Kotlin to override such methods?
If true, the meaning of "Kotlin support" just keeps expanding in scope...
Compile the above using a Kotlin 1.3 compiler, and javap shows that the method is named plus, and no hyphens are present anywhere:
$ javap -l -verbose -private -c -s ClockMark.class
...
public abstract class ClockMark
...
{
public ClockMark plus(double);
...
public ClockMark();
...
}
Turning operator fun plus into a fun plus -- making it not an operator -- and overloading plus() doesn't alter the name. Adding a default value does alter the method name, but only to append $default:
A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.
Fix included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2. To try the Preview version that includes the fix, check for the latest updates on the Previewupdater channel.
A new Release version has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix.
(Fix also included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2.1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Previewupdater channel.)
A new Release version has now been published on macOS that includes the fix for this item.
Fix included in Xamarin.Android 10.1.1.0.
Fix included on macOS in Visual Studio 2019 for Mac version 8.4. To get the new version that includes the fix, check for the latest updates on the Stableupdater channel.
Activity
jonpryor commentedon Oct 8, 2019
Horrifying thought: we emit:
The first parameter --
minus-LRDsOJo-- is used byJavaCallableWrapperGeneratorso that it knows what Java method name to override, and this Is Not A Valid Java Identifier, but our generator...emits Java code!WTF is supposed to happen here?
Is this ostensibly Kotlin "virtual" method not overridable by Java? Do we need to emit Kotlin to override such methods?
If true, the meaning of "Kotlin support" just keeps expanding in scope...
[generator] Escape hyphens for callback names so they're valid C#. (#497
jonpryor commentedon Oct 9, 2019
For future reference, we believe that the
plus-LRDsOJomethod is generated from the kotlin fragment:jonpryor commentedon Oct 9, 2019
...and this belief is apparently unwarranted. Given this Kotlin code:
Compile the above using a Kotlin 1.3 compiler, and
javapshows that the method is namedplus, and no hyphens are present anywhere:$ javap -l -verbose -private -c -s ClockMark.class ... public abstract class ClockMark ... { public ClockMark plus(double); ... public ClockMark(); ... }Turning
operator fun plusinto afun plus-- making it not an operator -- and overloadingplus()doesn't alter the name. Adding a default value does alter the method name, but only to append $default:Results in
javapoutput:I don't currently understand how or why hyphens would be present in method names. :-(
[generator] Escape hyphens for callback names so they're valid C#. (#497
Bump to xamarin/Java.Interop/d16-4@c4e569f4
Bump to xamarin/Java.Interop/master@73096d9f
Bump to xamarin/Java.Interop/master@73096d9f
Bump to xamarin/Java.Interop/master@73096d9f (#3831)
jpobst commentedon Oct 31, 2019
Fixed in #497.
brendanzagaeski commentedon Nov 4, 2019
Release status update
A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.
Fix included in Xamarin.Android 10.1.0.29.
Fix included on Windows in Visual Studio 2019 version 16.4 Preview 3. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.
Fix included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.
brendanzagaeski commentedon Dec 4, 2019
Release status update
A new Release version has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix.
Fix included in Xamarin.Android 10.1.0.30.
Fix included on Windows in Visual Studio 2019 version 16.4. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.
(Fix also included on macOS in Visual Studio 2019 for Mac version 8.4 Preview 2.1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.)
brendanzagaeski commentedon Jan 8, 2020
Release status update
A new Release version has now been published on macOS that includes the fix for this item.
Fix included in Xamarin.Android 10.1.1.0.
Fix included on macOS in Visual Studio 2019 for Mac version 8.4. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.
(Fix also included on Windows in Visual Studio 2019 version 16.4 and higher. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.)
fixed issue dotnet/java-interop#496
fixed issue dotnet/java-interop#496
fixed issue dotnet/java-interop#496