Skip to content

[BUG] Mapping from kotlin data class to java class #239

Closed

Description

@Janiaje

Describe the bug
I created a mapper, which maps a kotlin data class to a java class.
All of my tries resulted in the "Identifier $name does not occur as as setter or as a parameter in constructor" code link

To Reproduce

Source class

import java.util.UUID

data class TestSource(val id: UUID, val name: String)

Target class

import java.util.UUID;

class TestTarget {
    private UUID id;
    private String name;

    public TestTarget() {
    }

    public TestTarget(UUID id, String name) {
        this.id = id;
        this.name = name;
    }

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

Mapper

import tech.mappie.api.ObjectMappie

object TestMapper: ObjectMappie<TestSource, TestTarget>() {
    
    override fun map(from: TestSource): TestTarget = mapping {
        to("id") fromProperty from::id
        to("name") fromProperty from::name
    }
    
}

Expected behavior
Mapping done without errors

Kotlin version
2.2.0

Mappie version
2.2.0-1.4.0

Mappie and Kotlin compatibility
Is the Mappie version compatible with the Kotlin version? - Yes

Invocation method
The method of invocation, i.e. Gradle, Maven or CLI.
Gradle (kts) - version 8.7

Additional context

Activity

  1. stefankoppier commented on Aug 19, 2025

    @stefankoppier
    Collaborator

    Thanks for the report. I'm looking into it. The reproduction scenario doesn't seem to fail in a test. But I have some other pointers to look further.

  2. stefankoppier commented on Aug 19, 2025

    @stefankoppier
    Collaborator

    I found the issue, and will create a release with a fix (targeting Kotlin 2.2.10) today. If the issue persists, feel free to re-open this issue or create a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions