Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant java.lang.SafeVarargs annotation. Varargs element type java.lang.String is reifiable. #909

Open
domdorn opened this issue Feb 3, 2019 · 0 comments

Comments

@domdorn
Copy link

domdorn commented Feb 3, 2019

Hi!
I'm using immutables-value 2.7.5

I'm getting a compiler warning Redundant java.lang.SafeVarargs annotation. Varargs element type java.lang.String is reifiable. because immutables creates the @SafeVarargs annotation even for primitive types/reifiable types (like String)

my interface looks like this

@Value.Style(
  typeAbstract = "Abstract*",
  typeImmutable = "*",
  validationMethod = Value.Style.ValidationMethod.NONE,
  passAnnotations = {
      Nullable.class,
      NotNull.class,
      NotEmpty.class,
      Size.class,
      Max.class,
      Min.class,
      Pattern.class,
      Digits.class,
      JsonProperty.class
  },
  defaults = @Value.Immutable,
  visibility = Value.Style.ImplementationVisibility.PUBLIC)
@VavrEncodingEnabled
@Immutable
public interface AbstractLocalesDto {
....

  @NotNull
  List<String> available();
...
}

which then creates

.....
    @SafeVarargs
    public final Builder addAvailable(String... elements) {
      this.available_list = this.available_list.appendAll(Arrays.asList(elements));
      return this;
    }
...
}

in my understanding, the @SaveVarargs should only be generated when the variable argument types contain type parameters?

Why does this matter? I'm trying to harden my project by setting the -Werror javac compiler option, but this code in immutables is still preventing that.

Putting the @SuppressWarnings({ "all", "varargs" }) on my interface does work as a workaround, but feels wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant