简体   繁体   English

为什么GWT无法在Java 8中编译?

[英]Why does GWT fail compile in Java 8?

I'm writing something (a map generator) using the LibGDX library, which has the ability to build a HTML5 deployable using GWT. 我正在使用LibGDX库编写一些东西(一个地图生成器),该库具有使用GWT构建可部署的HTML5的能力。

However, when I run the Gradle build I receive this error: 但是,当我运行Gradle构建时,会收到此错误:

:html:compileGwt
Compiling module technology.rocketjump.undermount.mapgen.GdxDefinition
   Validating units:
     [ERROR] Errors in 'file:/D:/workspace/undermount-mapgen/core/src/main/java/technology/rocketjump/undermount/mapgen/generators/RiverGenerator.java'
     [ERROR] Line 61: RiverPathfindingCalculator cannot be resolved to a type
     [ERROR] Line 89: The left-hand side of an assignment must be a variable

The error seems to be indicating the following lines in RiverGenerator.java 该错误似乎表明RiverGenerator.java中的以下行

private boolean runRiver(GridPoint2 startPoint, GridPoint2 endPoint, GameMap map) {

    RiverPathfindingCalculator pathfinder = new RiverPathfindingCalculator(startPoint, endPoint, map);
    List<GridPoint2> path = pathfinder.findPath();

However RiverPathfindingCalculator is just another Java class in the same project. 但是RiverPathfindingCalculator只是同一项目中的另一个Java类。 It seems to be imported correctly in the file too, here's the imports of RiverGenerator 它似乎也正确导入了文件,这是RiverGenerator的导入

package technology.rocketjump.undermount.mapgen.generators;

import com.badlogic.gdx.math.GridPoint2;
import technology.rocketjump.undermount.mapgen.calculators.RiverPathfindingCalculator;
import technology.rocketjump.undermount.mapgen.model.TileType;
import technology.rocketjump.undermount.mapgen.model.output.*;

import java.util.*;

You can view the relevant code on Github . 您可以在Github上查看相关代码 Any ideas on what I'm doing wrong or how to fix this? 关于我做错了什么或如何解决此问题的任何想法?

GWT < Version 2.8 doesn't support java8 syntax, so no lambda expressions. GWT <版本2.8不支持java8语法,因此没有lambda表达式。

Rewrite that lambda to a "normal" Comparator (most IDEs have a refactoring to do it automatically) and GWT should be happy. 将该lambda重写为“普通”比较器(大多数IDE都具有自动执行的重构功能),GWT应该很高兴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM