Skip to content

Fixes Constructors parameters are wrongly assigned when compiled, and ghost references wrongly passed#710

Merged
wasabii merged 3 commits intoikvmnet:developfrom
maxpiva:main
Mar 1, 2026
Merged

Fixes Constructors parameters are wrongly assigned when compiled, and ghost references wrongly passed#710
wasabii merged 3 commits intoikvmnet:developfrom
maxpiva:main

Conversation

@maxpiva
Copy link
Copy Markdown
Contributor

@maxpiva maxpiva commented Jan 22, 2026

Fixes #709

And fixes this issue:

IL Code generated Lambda:

    .method public final virtual newslot instance void
      accept(
        [in] object obj0,
        [in] object obj1
      ) cil managed
    {
      .custom instance void [IKVM.Runtime]IKVM.Attributes.HideFromJavaAttribute::.ctor()
        = (01 00 00 00 )
      .maxstack 3
      .locals init (
        [0] object obj,
        [1] valuetype [IKVM.Java]java.lang.CharSequence charSequence
      )

      IL_0000: ldarg.1      // obj0
      IL_0001: castclass    org.jsoup.internal.StringUtil/StringJoiner
      IL_0006: ldarg.2      // obj1
      IL_0007: stloc.0      // obj
      IL_0008: ldloca.s     charSequence
      IL_000a: ldloc.0      // obj
      IL_000b: stfld        object [IKVM.Java]java.lang.CharSequence::'__<ref>'
      IL_0010: ldloca.s     charSequence
      IL_0012: ldobj        [IKVM.Java]java.lang.CharSequence
      IL_0017: callvirt     instance class org.jsoup.internal.StringUtil/StringJoiner org.jsoup.internal.StringUtil/StringJoiner::'add'(object)
      IL_001c: pop
      IL_001d: ldnull
      IL_001e: pop
      IL_001f: ret

    } // end of method '__<>Anon1'::accept

Notice the bad boxing, it should load the ghost instead.

IL_0012: ldobj [IKVM.Java]java.lang.CharSequence

Now it generates the following code:

    .method public final virtual newslot instance void
      accept(
        [in] object obj0,
        [in] object obj1
      ) cil managed
    {
      .custom instance void [IKVM.Runtime]IKVM.Attributes.HideFromJavaAttribute::.ctor()
        = (01 00 00 00 )
      .maxstack 3
      .locals init (
        [0] object obj,
        [1] valuetype [IKVM.Java]java.lang.CharSequence charSequence,
        [2] valuetype [IKVM.Java]java.lang.CharSequence V_2
      )

      IL_0000: ldarg.1      // obj0
      IL_0001: castclass    org.jsoup.internal.StringUtil/StringJoiner
      IL_0006: ldarg.2      // obj1
      IL_0007: stloc.0      // obj
      IL_0008: ldloca.s     charSequence
      IL_000a: ldloc.0      // obj
      IL_000b: stfld        object [IKVM.Java]java.lang.CharSequence::'__<ref>'
      IL_0010: ldloca.s     charSequence
      IL_0012: ldobj        [IKVM.Java]java.lang.CharSequence
      IL_0017: stloc.2      // V_2
      IL_0018: ldloca.s     V_2
      IL_001a: ldfld        object [IKVM.Java]java.lang.CharSequence::'__<ref>'
      IL_001f: callvirt     instance class org.jsoup.internal.StringUtil/StringJoiner org.jsoup.internal.StringUtil/StringJoiner::'add'(object)
      IL_0024: pop
      IL_0025: ldnull
      IL_0026: pop
      IL_0027: ret

    } // end of method '__<>Anon1'::accept

I wasn’t able to build the test project to run the full regression suite, not the full ikvm suite, but I did verify the fixes by temporarily hacking around ikvmc and IKVM.Tools.Importer.dll. The changes are working as expected.

@wasabii , it would be good to run proper regression tests on this, but so far everything looks solid.

Offending class included for the above issue.
StringUtil.zip

Added a condition to prevent merging local variable table slots with the same name in Kotlin’s nested/anonymous classes.

Signed-off-by: Maximo Piva <maximo.piva@gmail.com>
Handle ghost signature types in LambdaMetafactory.

Signed-off-by: Maximo Piva <maximo.piva@gmail.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jan 22, 2026

CLA assistant check
All committers have signed the CLA.

@wasabii wasabii changed the base branch from main to develop February 28, 2026 14:09
@wasabii wasabii merged commit 3ccefbe into ikvmnet:develop Mar 1, 2026
478 of 486 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constructors parameters are wrongly assigned when compiled. (8.15.0)

3 participants