当我尝试在Eclipse中将我的Libgdx游戏编译为HTML5时,我遇到了这些奇怪的错误。
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...
在我的build.gradle中,我检查过gwtVersion是使用2.7.0而我的sourceCompatibility是1.8。我已经做了好几天了,我似乎无法弄明白。
帮助!!!
已更新
感谢科林的反馈。这是我现在得到的错误:
[ERROR]发生内部编译器异常 com.google.gwt.dev.jjs.InternalCompilerException:构造Java AST时出错 在com.google.gwt.dev.jjs.impl.GwtAstBuilder.translateException(GwtAstBuilder.java:3099) 在com.google.gwt.dev.jjs.impl.GwtAstBuilder $ AstVisitor.endVisit(GwtAstBuilder.java:352) 在org.eclipse.jdt.internal.compiler.ast.AllocationExpression.traverse(AllocationExpression.java:670) at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.traverse(ReturnStatement.java:373) 在org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:347) 在org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1379) 在com.google.gwt.dev.jjs.impl.GwtAstBuilder.process(GwtAstBuilder.java:3058) 在com.google.gwt.dev.javac.CompilationStateBuilder $ CompileMoreLater $ UnitProcessorImpl.process(CompilationStateBuilder.java:141) 在com.google.gwt.dev.javac.JdtCompiler $ CompilerImpl.process(JdtCompiler.java:384) 在org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:470) 在com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:985) 在com.google.gwt.dev.javac.CompilationStateBuilder $ CompileMoreLater.compile(CompilationStateBuilder.java:339) 在com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:580) 在com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:513) 在com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:499) 在com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:668) 在com.google.gwt.dev.Precompile.precompile(Precompile.java:255) 在com.google.gwt.dev.Precompile.precompile(Precompile.java:229) 在com.google.gwt.dev.Precompile.precompile(Precompile.java:145) 在com.google.gwt.dev.Compiler.run(Compiler.java:206) 在com.google.gwt.dev.Compiler.run(Compiler.java:158) 在com.google.gwt.dev.Compiler $ 1.run(Compiler.java:120) 在com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55) 在com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50) 在com.google.gwt.dev.Compiler.main(Compiler.java:127) 引起:java.lang.NullPointerException 在com.google.gwt.dev.jjs.impl.ReferenceMapper.get(ReferenceMapper.java:99) 在com.google.gwt.dev.jjs.impl.GwtAstBuilder $ AstVisitor.pushNewExpression(GwtAstBuilder.java:2642) 在com.google.gwt.dev.jjs.impl.GwtAstBuilder $ AstVisitor.endVisit(GwtAstBuilder.java:350) ......还有23个 TimeZone.java的[错误](126):new String(data) org.eclipse.jdt.internal.compiler.ast.AllocationExpression
也许我必须将它更新为GWT 2.8.0?
P.S:在我的html \ war \ WEB-INF \ lib目录中,我有以下jar:
这个设置是否正确?
更新:
现在更新为GWT 2.8.1。现在我收到以下错误:
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)
我应该清理我的html \ war \ WEB-INF \ lib目录中的(或某些)罐子并使用其他罐子吗?
答案 0 :(得分:3)
如果您使用的是GWT 2.7,则无法使用Java8。如果要使用Java 8,请升级到GWT 2.8(或更好,2.8.1)。
也就是说,如果您正在查找这些类,那么它表明您已经在类路径上有部分的GWT 2.8,并且每个版本的GWT混合了一些碎片并没有赢得结束好。最好将所有内容升级到最新版本,2.8.1。