@Test
  public void typeParameterBuilderFieldsAreNullable() throws ReflectiveOperationException {
    assertThrows(NullPointerException.class, () -> NotNullableVariableBound.builder().setT(null));

    // Even though neither t() nor string() has a @Nullable return type, the corresponding builder
    // fields should be @Nullable. This test depends on the knowledge that for a property `t`, we
    // will have a field also called `t`.
    // For `nullableT`, the @Nullable in question should be the same as the one on the return type
    // of nullableT(). For `t`, it is a @Nullable that AutoValue found somewhere, either there or
    // possibly on the parameter of the inherited Object.equals method.
    Field builderT = NotNullableVariableBound.builder().getClass().getDeclaredField("t");
    assertThat(builderT.getAnnotatedType().getAnnotations())
        .asList()
        .containsAnyIn(nullables(AutoValue_AutoValueJava8Test_NotNullableVariableBound.class));
    Field builderNullableT =
        NotNullableVariableBound.builder().getClass().getDeclaredField("nullableT");
    assertThat(builderNullableT.getAnnotatedType().getAnnotations()).asList().contains(nullable());

    // Meanwhile the AutoValue class itself should have @Nullable on the private field, the getter
    // method, and the constructor parameter for nullableT. This @Nullable should be the same as
    // the one on the return type of nullableT().
    Class<?> autoValueClass = AutoValue_AutoValueJava8Test_NotNullableVariableBound.class;
    Field nullableTField = autoValueClass.getDeclaredField("nullableT");
    assertThat(nullableTField.getAnnotatedType().getAnnotations()).asList().contains(nullable());
    Method nullableTMethod = autoValueClass.getMethod("nullableT");
    assertThat(nullableTMethod.getAnnotatedReturnType().getAnnotations())
        .asList()
        .contains(nullable());
    Constructor<?> autoValueConstructor =
        autoValueClass.getDeclaredConstructor(Object.class, Object.class, String.class);
    assertThat(autoValueConstructor.getAnnotatedParameterTypes()[1].getAnnotations())
        .asList()
        .contains(nullable());
  }
Tests that an annotation on a type parameter of an {@code @AutoValue} builder is copied to the
implementation class.
value/src/it/functional/src/test/java/com/google/auto/value/AutoValueJava8Test.java