0

I'm getting these weird errors when I try to compile my Libgdx game to HTML5 in Eclipse.

Tracing compile failure path for type 'java.util.function.DoubleUnaryOperator'
     [ERROR] Errors in 'com/google/gwt/emul/java/util/function/DoubleUnaryOperator.java'
     [ERROR] Line 33: Default methods are allowed only at source level 1.8 or above
     [ERROR] Line 35: Cannot refer to the non-final local variable after defined in an enclosing scope
     [ERROR] Line 40: Cannot refer to the non-final local variable before defined in an enclosing scope
     [ERROR] Line 40: Lambda expressions are allowed only at source level 1.8 or above
     [ERROR] Line 35: Lambda expressions are allowed only at source level 1.8 or above
     [ERROR] Line 38: Default methods are allowed only at source level 1.8 or above
     [ERROR] Line 27: Illegal modifier for the interface method identity; only public & abstract are permitted
     [ERROR] Line 27: Static methods are allowed in interfaces only at source level 1.8 or above
     [ERROR] Line 28: Lambda expressions are allowed only at source level 1.8 or above
Tracing compile failure path for type 'java.util.stream.Collectors'
  [ERROR] Errors in 'com/google/gwt/emul/java/util/stream/Collectors.java'
     [ERROR] Line 291: This static method of interface Collector can only be accessed as Collector.of
     [ERROR] Line 348: Lambda expressions are allowed only at source level 1.8 or above
     [ERROR] Line 96: Lambda expressions are allowed only at source level 1.8 or above
     [ERROR] Line 223: The method of(Supplier<R>, BiConsumer<R,T>, BinaryOperator<R>, Collector.Characteristics...) in the type Collector is not applicable for the arguments (() -> {}, (<no type> u, <no type> t) -> {}, (Object[] u1, Object[] u2) -> {}, (Object[] a) -> {})
     [ERROR] Line 311: Constructor references are allowed only at source level 1.8 or above
     [ERROR] Line 192: Method references are allowed only at source level 1.8 or above
     [ERROR] Line 205: Lambda expressions are allowed only at source level 1.8 or above
     [ERROR] Line 143: Constructor references are allowed only at source level 1.8 or above
     [ERROR] Line 168: Lambda expressions are allowed only at source level 1.8 or above
     [ERROR] Line 339: Lambda expressions are allowed only at source level 1.8 or above...

In my build.gradle, I've checked that the gwtVersion is using 2.7.0 and my sourceCompatibility is at 1.8. I've been at this thing for days and I can't seem to figure it out.

Help!!!

UPDATED

Thank you Colin for the feedback. Here's the error I'm getting now:

[ERROR] An internal compiler exception occurred com.google.gwt.dev.jjs.InternalCompilerException: Error constructing Java AST at com.google.gwt.dev.jjs.impl.GwtAstBuilder.translateException(GwtAstBuilder.java:3099) at com.google.gwt.dev.jjs.impl.GwtAstBuilder$AstVisitor.endVisit(GwtAstBuilder.java:352) at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.traverse(AllocationExpression.java:670) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse(ReturnStatement.java:373) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:347) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1379) at com.google.gwt.dev.jjs.impl.GwtAstBuilder.process(GwtAstBuilder.java:3058) at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater$UnitProcessorImpl.process(CompilationStateBuilder.java:141) at com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.process(JdtCompiler.java:384) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:470) at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:985) at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:339) at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:580) at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:513) at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:499) at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:668) at com.google.gwt.dev.Precompile.precompile(Precompile.java:255) at com.google.gwt.dev.Precompile.precompile(Precompile.java:229) at com.google.gwt.dev.Precompile.precompile(Precompile.java:145) at com.google.gwt.dev.Compiler.run(Compiler.java:206) at com.google.gwt.dev.Compiler.run(Compiler.java:158) at com.google.gwt.dev.Compiler$1.run(Compiler.java:120) at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55) at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50) at com.google.gwt.dev.Compiler.main(Compiler.java:127) Caused by: java.lang.NullPointerException at com.google.gwt.dev.jjs.impl.ReferenceMapper.get(ReferenceMapper.java:99) at com.google.gwt.dev.jjs.impl.GwtAstBuilder$AstVisitor.pushNewExpression(GwtAstBuilder.java:2642) at com.google.gwt.dev.jjs.impl.GwtAstBuilder$AstVisitor.endVisit(GwtAstBuilder.java:350) ... 23 more [ERROR] at TimeZone.java(126): new String(data) org.eclipse.jdt.internal.compiler.ast.AllocationExpression

Maybe I have to update it to GWT 2.8.0?

P.S: In my html\war\WEB-INF\lib directory, i have the following jars:

enter image description here

Is that setup correct?

UPDATED:

Now updated to GWT 2.8.1. Now I get the following error:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.gwt.util.regexfilter.RegexFilter: method <init>()V not found
at com.google.gwt.util.regexfilter.WhitelistRegexFilter.<init>(WhitelistRegexFilter.java:21)
at com.google.gwt.dev.jjs.JJSOptionsImpl.<init>(JJSOptionsImpl.java:54)
at com.google.gwt.dev.PrecompileTaskOptionsImpl.<init>(PrecompileTaskOptionsImpl.java:39)
at com.google.gwt.dev.CompilerOptionsImpl.<init>(CompilerOptionsImpl.java:30)
at com.google.gwt.dev.Compiler.main(Compiler.java:108)

Should I clean up the (or some of the) jars that's in my html\war\WEB-INF\lib directory and use other jars?

C.O.D.E
  • 885
  • 8
  • 19
  • 1
    It would be most helpful to lead me to some solutions instead of choosing to vote to close this question. I did my research on SO and in Google, yet none of them gave me a solution. – C.O.D.E Aug 24 '17 at 00:47
  • Did you ever manage to solve this? – Andrei F Oct 24 '18 at 10:09

1 Answers1

3

If you are using GWT 2.7, you cannot use Java8. If you want to use Java 8, upgrade to GWT 2.8 (or better, 2.8.1).

That said, if you are finding those classes at all, it suggests you have part of GWT 2.8 already on your classpath, and mixing bits and pieces from each version of GWT won't end well. Best to upgrade everything to latest, 2.8.1.

Colin Alworth
  • 17,801
  • 2
  • 26
  • 39
  • Oddly enough, I can`t seem to find those classes on my computer. Is it possible that in my build path that I`m refering the jre system library 1.8.0. Does it have to do with that system library? – C.O.D.E Aug 25 '17 at 23:18
  • It shows that this is part of GWT: `com/google/gwt/emul/java/util/stream/Collectors.java`, not part of your JDK. Also, the way GWT works, it emulates JRE classes by only providing .java files, not .class files, so you wouldn't be able to find that class on your computer. Look for a gwt-user-2.8.0.jar or the .java files themselves, as that is almost certainly what is wrong. – Colin Alworth Aug 26 '17 at 13:40
  • I can`t find gwt-user-2.8.0.jar anywhere. I have the following jars in my referenced libraries: gwt-user.jar, gwt-codeserver.jar, gwt-dev.jar, validation-api-1.0.0.GA-sources.jar, validation-api-1.0.0.GA.jar and gdx-backend-gwt-1.6.5.jar (all located in the folder eclipse/plugins/com.gwtplugins.gwt.eclipse.sdkbundle.gwt27_2.7.0.201707251900/gwt-2.7.0/). Do I have to remove the gwt-user.jar or the other jars? – C.O.D.E Aug 26 '17 at 17:36
  • Check what version the file called `gwt-user.jar` is, it is possible that this is 2.8. – Colin Alworth Aug 26 '17 at 20:02
  • I`ve looked in the com/google/gwt/dev/About.propertie in the jar gwt-dev.jar and it`s using the version 2.7.0. Should I check all other jar files for a 2.8? – C.O.D.E Aug 27 '17 at 22:50
  • Or clear out the jars are get new ones that you are sure about the version number. If you have those files present, then at least one of your jars is 2.8.x, and mixing versions like this _will_ cause problems. – Colin Alworth Aug 28 '17 at 14:03
  • Sorry for the delay, Colin. Here's what I just did: I had to go to Windows > Preferences > GWT > GWT Settings and from there select GWT 2.7.0 as it was on GWT 2.8.0 before. After that, I clicked on OK and it added the GWT 2.7.0 jars. But now I have another problem. When I compile, I get others errors: [ERROR] An internal compiler exception occurred com.google.gwt.dev.jjs.InternalCompilerException: Error constructing Java AST at com.google.gwt.dev.jjs.impl.GwtAstBuilder.translateException(GwtAstBuilder.java:3099)... – C.O.D.E Aug 30 '17 at 00:35
  • I tried the following solution https://stackoverflow.com/questions/41039097/gwt-error-constructing-java-ast, but to no avail :(. – C.O.D.E Aug 30 '17 at 00:54
  • If it is a new error, you should either put the entire error into the question, or open a new question. – Colin Alworth Aug 30 '17 at 12:50
  • Do note however that the linked question is also a version mismatch issue, so you may be dealing with your dependencies, or may still have missed something. – Colin Alworth Aug 30 '17 at 12:55
  • What jars do I need to correctly compile the html5 libgdx project? – C.O.D.E Aug 30 '17 at 23:15
  • From your comment above, you moved to 2.7, but your update to the question shows clearly that you have 2.6 as well! Version mismatches will end badly. As far as libgdx, check the documentation of the version of libgdx you are using to see which GWT version you should pair it with. – Colin Alworth Aug 31 '17 at 14:25
  • I've updated to GWT 2.8.1 since I'm using libgdx version 1.9.6. And I get new errors. I'll post it up above. – C.O.D.E Aug 31 '17 at 22:42
  • Thank you for your help, Colin. I managed to arrange correctly my .classpath file as it contained some attributes node pointing to javadoc files. I remove them and now I don't see these errors anymore. Thank you again for you patience. You da man!! :) – C.O.D.E Sep 01 '17 at 00:56