Can anyone tell me why the following code fails to compile but the lambda version does:
Are there rules about the generic type inference? Anything I should avoid?
Failed:
EntityLayerManager.refreshLayerRenderables(
wwd, this.networkNodeShapeLayer, nodeMap.values(),
MissionDetailUIConst::createNetworkNodeRenderable,
MissionDetailUIConst::updateNetworkNodeRenderable) // <<== FAILED
Success (with normal lambda):
EntityLayerManager.refreshLayerRenderables(
wwd, this.networkNodeShapeLayer, nodeMap.values(),
MissionDetailUIConst::createNetworkNodeRenderable,
(e, coll) -> MissionDetailUIConst.updateNetworkNodeRenderable(e, coll));
Success (with generic parameters specified):
EntityLayerManager.<EwmsVwNetworkNodeEntity, KolladaRoot>refreshLayerRenderables(
wwd, this.networkNodeShapeLayer, nodeMap.values(),
MissionDetailUIConst::createNetworkNodeRenderable,
MissionDetailUIConst::updateNetworkNodeRenderable)
Referenced Methods:
public static <E, R extends Renderable> int refreshLayerRenderables(WorldWindow wwd,
RenderableLayer renderableLayer, Collection<E> entityList,
Function<E, ? extends Collection<? extends R>> createRenderables,
BiPredicate<E, Collection<R>> updateRenderables);
public static Collection<KolladaRoot> createNetworkNodeRenderable(EwmsVwNetworkNodeEntity networkNode);
public static boolean updateNetworkNodeRenderable(EwmsVwNetworkNodeEntity networkNode, Collection<KolladaRoot> colladaRootCollection);
This is an Eclipse bug. I narrowed it down to the use of a nested generic parameter (
Collection<R>
) as the type of an argument (inBiPredicate
) to the referenced method (specified asCollection<KolladaRoot>
). It should compile fine in javac.exe.I'd say stick with explicit type specification until it's fixed in 4.5 M2, it should have less effect (if any) than switching to lambdas.