Skip to content

SubclassMapping stackoverflow exception #2825

@Zegveld

Description

@Zegveld

When using subclass mappings the method itself is accepted as a possible conversion method.
This is not wanted, work around is to manually define the subclass mapping methods.

Reproduction scenario:

class Animal {
    String name;
}
class Dog extends Animal {
    String race;
}
class Cat extends Animal {
    String race;
}
class TargetAnimal {
    String name;
    String race;
}

@SubclassMapping( target = TargetAnimal.class, source = Dog.class )
@SubclassMapping( target = TargetAnimal.class, source = Cat.class )
TargetAnimal map(Animal source);

What happends is that the TargetAnimal map(Animal) method is called for each subclass, instead of new methods being generated.
The following 2 methods are wanted here:

TargetAnimal map(Dog dog);
TargetAnimal map(Cat cat);

Work-around is to create these 2 mapping methods manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions