Generics type inference resolved by javac and IDEA, but not in Eclipse [message #784441] |
Fri, 27 January 2012 14:35 |
Simone Tripodi Messages: 3 Registered: January 2012 |
Junior Member |
|
|
HI all guys,
at Apache Commons we are developing a Sandbox component to work with Graph structures, approaching the problem with fluent APIs and Generics.
We have an issue with Generics in Eclipse that we need to fix in order to redistribute the library in a decent state to be used inside the most used IDEs: the CommonsGraph class contains the following method signature:
public static <V extends Vertex, WE extends WeightedEdge<W>, W, G extends Graph<V, WE>> SpanningTreeSourceSelector<V, W, WE, G> minimumSpanningTree( G graph )
When passing an argument that looks like:
UndirectedMutableWeightedGraph<BaseLabeledVertex, BaseLabeledWeightedEdge<Double>, Double> input = ...;
minimumSpanningTree( input )...
Eclipse detectes the following problem:
Bound mismatch: The generic method minimumSpanningTree(G) of type CommonsGraph<V,E,G> is not applicable for the arguments (UndirectedMutableWeightedGraph<BaseLabeledVertex,BaseLabeledWeightedEdge<Double>,Double>). The inferred type BaseLabeledWeightedEdge<Double> is not a valid substitute for the bounded parameter <WE extends WeightedEdge<W>>
Please note that the following code works when compiled from command line (via Apache Maven) and in IntelliJ IDEA, unfortunately I didn't figure out how to have it fixed in Eclipse as well.
Can someone give me an explanation about what happens and how to fix it, please? I'll be available to provide as much details as possible!
Many thanks in advance, all the best!!!
-Simo
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03491 seconds