Skip to content

Compilation error when mapping fields with the same type due to not wrapping in a try-catch block #2839

@hakan0xFF

Description

@hakan0xFF

The mapper for the following class cannot be generated:

...
public final class FinancingProductDto {
  ...
  private final List<CommitmentFeeDto> conditionedCommitmentFees;
  private final List<CommitmentFeeDto> unconditionedCommitmentFees;
...

The second mapped field is not wrapped in a try-catch block:

...
        try {
            conditionedCommitmentFees = commitmentFeeDtoListToCommitmentFeeList( dto.getConditionedCommitmentFees() );
        }
        catch ( IllegalAccessException e ) {
            throw new RuntimeException( e );
        }
        catch ( InvocationTargetException e ) {
            throw new RuntimeException( e );
        }
        catch ( InstantiationException e ) {
            throw new RuntimeException( e );
        }
        catch ( NoSuchMethodException e ) {
            throw new RuntimeException( e );
        }
        unconditionedCommitmentFees = commitmentFeeDtoListToCommitmentFeeList( dto.getUnconditionedCommitmentFees() );
...

The following error is occurring: unreported exception java.lang.IllegalAccessException; must be caught or declared to be thrown

Here is an example project to reproduce the issue: https://github.com/hakan0xFF/mapstruct-mapping-issue

The error occurs also with the latest stable version 1.4.2.Final.

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