import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNullByDefault; import org.jetbrains.annotations.Nullable; import java.util.List; class MyTest { @NotNullByDefault static class Iterables { public static native Iterable concat(Iterable a, Iterable b); public static native T[] toArray( Iterable iterable, Class<@NotNull T> type); public static native T get( Iterable iterable, int position); } void foo1(List<@Nullable Integer> l1, List<@Nullable String> l2) { for (Object s : Iterables.concat(l1, l2)) { System.out.println(s.toString()); } } void foo2(List<@Nullable Integer> l1, List l2) { for (Object s : Iterables.concat(l1, l2)) { System.out.println(s.toString()); } } void toArray(List<@Nullable String> l1) { for (String s : Iterables.toArray(l1, String.class)) { System.out.println(s.length()); } } void get(List<@Nullable String> l1) { System.out.println(Iterables.get(l1, 0).length()); } void get2(List l1) { System.out.println(Iterables.get(l1, 0).length()); } void foo(List l1, List l2) { for (String s : Iterables.concat(l1, l2)) { System.out.println(s.length()); } } }