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?
EntityLayerManager.refreshLayerRenderables(
wwd, this.networkNodeShapeLayer, nodeMap.values(),
MissionDetailUIConst::createNetworkNodeRenderable,
MissionDetailUIConst::updateNetworkNodeRenderable) // <<== FAILED
EntityLayerManager.refreshLayerRenderables(
wwd, this.networkNodeShapeLayer, nodeMap.values(),
MissionDetailUIConst::createNetworkNodeRenderable,
(e, coll) -> MissionDetailUIConst.updateNetworkNodeRenderable(e, coll));
EntityLayerManager.<EwmsVwNetworkNodeEntity, KolladaRoot>refreshLayerRenderables(
wwd, this.networkNodeShapeLayer, nodeMap.values(),
MissionDetailUIConst::createNetworkNodeRenderable,
MissionDetailUIConst::updateNetworkNodeRenderable)
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 (in BiPredicate
) to the referenced method (specified as Collection<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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.