gpt4 book ai didi

java - Eclipse Oxygen 中的 GWT 编译错误

转载 作者:行者123 更新时间:2023-12-01 20:15:37 25 4
gpt4 key购买 nike

当我尝试在 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] 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

也许我必须将其更新到 GWT 2.8.0?

P.S:在我的 html\war\WEB-INF\lib 目录中,我有以下 jars:

enter image description here

这个设置正确吗?

更新:

现已更新至 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 目录中的(或部分)jar 并使用其他 jar 吗?

最佳答案

如果您使用的是 GWT 2.7,则无法使用 Java8。如果您想使用 Java 8,请升级到 GWT 2.8(或更好的 2.8.1)。

也就是说,如果您确实找到了这些类,则表明您的类路径中已经存在 GWT 2.8 的部分,并且混合各个版本的 GWT 的零碎内容不会有好的结果。最好将所有内容升级到最新版本 2.8.1。

关于java - Eclipse Oxygen 中的 GWT 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45851064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com