Skip to content

false errors on "unknown properties" after Pull Request #177 got merged #216

@OlliL

Description

@OlliL

We are experiencing multiple "Cannot resolve symbol ...." errors with version 1.9.0 of the plugin.

We are currently not able reproduce all of them them with simple projects, but it seems to be connected to not detecting properties defined in abstract classes together with Generics. We'll further investigate into this, but maybe you can check on your side too - you know your code and the edge cases probably far better then we do.

One thing we can reproduce is the handling of final List-properties in target objects having no setter.
Mapstruct will in this case use the getter and call addAll on it to add the mapped elements.
I saw in TargetUtils.javathat you also have code in place to look for getters working with classes implementing java.util.Collection - but something seems not to work right in that place.

Let me provide a simple example:

Class TestDto

package test;
import java.util.List;

public class TestDto {
    private List<String> dtoStringList;
    public List<String> getDtoStringList() {
        return dtoStringList;
    }
}

Class TestEntity

package test;
import java.util.List;
import java.util.ArrayList;

public class TestEntity {
    private final List<String> myStringList = new ArrayList<>();
    public List<String> getMyStringList() {
        return myStringList;
    }
}

Class TestEntityMapper

package test;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper
public interface TestEntityMapper {
    @Mapping(target = "myStringList", source = "dtoStringList")
    TestEntity map(TestDto testDto);
}

This will generate an error:
Cannot resolve symbol 'myStringList'

But the generated mapper is fine, it uses the get-Method and calls addAll() on it. So this is a false error.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions