Search code examples
javagwtlibgdxjava-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.

However, when I run the Gradle build I receive this error:

: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

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. It seems to be imported correctly in the file too, here's the imports of 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. Any ideas on what I'm doing wrong or how to fix this?


Solution

  • GWT < Version 2.8 doesn't support java8 syntax, so no lambda expressions.

    Rewrite that lambda to a "normal" Comparator (most IDEs have a refactoring to do it automatically) and GWT should be happy.