I'm trying to compile following code with Maven:
final Table<Integer, Integer, Integer> destination = HashBasedTable.create();
final Map<Integer, Integer> source = new HashMap<>();
// compiles
final Table<Integer, Integer, Integer> broker =
source.entrySet().stream().collect( Tables.toTable( e -> 0, e -> 0, e -> 0,
( e1, e2 ) -> 0, HashBasedTable::create ) );
destination.putAll( broker );
// doesn't compile
destination.putAll( source.entrySet().stream().collect( Tables.toTable( e -> 0, e -> 0,
e -> 0, ( e1, e2 ) -> 0, HashBasedTable::create ) ) );
the result is error:
incompatible types: inferred type does not conform to upper bound(s)
inferred: com.google.common.collect.Table<java.lang.Object,java.lang.Object,java.lang.Object>
upper bound(s): com.google.common.collect.Table<java.lang.Object,java.lang.Object,java.lang.Object>,com.google.common.collect.Table<? extends java.lang.Integer,? extends java.lang.Integer,? extends java.lang.Integer>,java.lang.Object
Why do I need this broker table to compile? The most interesting thing is that somehow Eclipse compiler knows how to deal with it.
I'm using Maven compiler plugin version 3.8.0 with target and source tags set to 1.8.
I feel like it something is wrong in the workflow here - I'm developing in IDE, everything looks fine, and than all of the sudden it turns out that there is something wrong with my code and it does not even compile on Maven build.
I tried on the newest 3.6 Maven version, and Eclipse compiler comes from Eclipse 2018-12, both Java 8 and 11.