FlexTradeUKLtd / jfixture

JFixture is an open source library based on the popular .NET library, AutoFixture
MIT License
105 stars 22 forks source link

Wildcard types not supported exception: Multiple constructors + guava ImmutableList + Linux #58

Open Borginator opened 4 years ago

Borginator commented 4 years ago

Given the example minimal project at https://github.com/Borginator/exampleJFixtureIssue

This project has a single test which fixtures a single class which throws "Wildcard types not supported" only under Linux (explicitly tested under centos 7 Linux local-dev 3.10.0-957.21.2.el7.x86_64 #1 SMP Wed Jun 5 14:26:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux, and also seen on the docker maven 3.5.0 "docker pull maven:3.5.0").

The same code does not throw this exception under Windows.

Both the CentOS and the Windows systems were using OpenJDK jdk8u212-b04

The class I am trying to fixture is here:

import com.google.common.collect.ImmutableList;

public class SomeClass {

  private final String aString;

  public SomeClass(String path) {
    this.aString = "";
  }

  // Delete *any combination* of the below constructors and the test passes
  public SomeClass(String alias, String... path) {
    this("");
  }

  public SomeClass(String alias, ImmutableList<String> path) {
    this("");
  }

  public SomeClass(ImmutableList<String> path) {
    this("");
  }

}

As specified in the comment, the issue only occurs when all 4 constructors are defined, removing any one (or more) of the specified constructors allows the class to be fixtured. Also, (and this may not be specifically relevant) but using Java List instead of Guava ImmutableList allows the class to be fixtured too.

I can work around this problem, but it's weird to have different behaviours on Linux and Windows.