amazon web services – AWS Java SDK V1 –> V2 migration encountered a compilation error

I’m trying to migrate to AWS SDK Ec2 V2 and got compilation error:

error: types SdkBuilder and Builder are incompatible;
  both define build(), but with unrelated return types
  where CAP#1,CAP#2 are fresh type-variables:
    CAP#1 extends CopyableBuilder from capture of ?
    CAP#2 extends ToCopyableBuilder from capture of ?

Seems it is somehow related to builders definition where multiple parent interfaces define method build()

DescribeInstancesRequest.Builder
  -- Ec2Request.Builder:  Ec2Request build();
    -- AwsRequest.Builder: AwsRequest build();
  -- CopyableBuilder
    -- SdkBuilder: DescribeInstancesRequest build();

P.S Both V1 and V2 versions are still using during migration.

Read more here: Source link