Enum.values() 在 GWT 中不工作抛出编译错误
Enum.values() not working in GWT throws compilation error
我在我的 GWT 中使用枚举 class class.I 我正在使用 enum.values() 以遍历枚举 class。这会在编译期间引发错误。我使用的 GXT 版本是 2.2.5。 gwt-dev jar 版本是 2.4.0
尝试使用 EnumSet.allOf(DaysOfWeekEnum.class) 仍然出现同样的错误
这篇文章 -> https://github.com/gwtproject/gwt/issues/7065 说这是 gxt 的一个错误。但无法从中找到修复方法
for (DaysOfWeekEnum day : DaysOfWeekEnum.values()) {
System.out.println(day);
}
得到以下异常:
[java] Apr 23, 2019 5:27:38 PM java.util.prefs.WindowsPreferences <init>
[java] WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[java] Compiling module com.dashboard_gxt
[java] Validating newly compiled units
[java] Ignored 9 units with compilation errors in first pass.
[java] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[java] [ERROR] An internal compiler exception occurred
[java] com.google.gwt.dev.jjs.InternalCompilerException: Failed to get JNode
[java] at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:140)
[java] at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:71)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.getType(BuildTypeMap.java:730)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.access[=12=]0(BuildTypeMap.java:99)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap$BuildDeclMapVisitor.visit(BuildTypeMap.java:195)
[java] at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.traverse(LocalDeclaration.java:237)
[java] at org.eclipse.jdt.internal.compiler.ast.ForeachStatement.traverse(ForeachStatement.java:527)
[java] at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:239)
[java] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1239)
[java] at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:687)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.createPeersForNonTypeDecls(BuildTypeMap.java:637)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:514)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:523)
[java] at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:599)
[java] at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:33)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:284)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:232)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:198)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:170)
[java] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
[java] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
[java] at com.google.gwt.dev.Compiler.main(Compiler.java:177)
[java] [ERROR] <no source info>: public final enum com.dashboard.enums.DaysOfWeekEnum
[java] extends Enum<com.dashboard.enums.DaysOfWeekEnum>
[java] /* fields */
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Monday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Tuesday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnums Wednesday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Thursday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Friday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Saturday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Sunday
com.dashboard.enums.DaysOfWeekEnum[] $VALUES
[java] /* methods */
[java] [unresolved] private void <init>()
[java] [unresolved] public static com.dashboard.enums.DaysOfWeekEnum valueOf(java.lang.String)
[java] [unresolved] public static com.dashboard.enums.DaysOfWeekEnum[] values()
[java] org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding
[java] [ERROR] at FormPanel.java(104): com.dashboard.enums.DaysOfWeekEnum day;
[java] org.eclipse.jdt.internal.compiler.ast.LocalDeclaration
通过在gwt.xml 中的源路径="" 下添加Enum class 包来修复它。
<source path='myapplication/enums/'/>
我在我的 GWT 中使用枚举 class class.I 我正在使用 enum.values() 以遍历枚举 class。这会在编译期间引发错误。我使用的 GXT 版本是 2.2.5。 gwt-dev jar 版本是 2.4.0
尝试使用 EnumSet.allOf(DaysOfWeekEnum.class) 仍然出现同样的错误
这篇文章 -> https://github.com/gwtproject/gwt/issues/7065 说这是 gxt 的一个错误。但无法从中找到修复方法
for (DaysOfWeekEnum day : DaysOfWeekEnum.values()) {
System.out.println(day);
}
得到以下异常:
[java] Apr 23, 2019 5:27:38 PM java.util.prefs.WindowsPreferences <init>
[java] WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[java] Compiling module com.dashboard_gxt
[java] Validating newly compiled units
[java] Ignored 9 units with compilation errors in first pass.
[java] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[java] [ERROR] An internal compiler exception occurred
[java] com.google.gwt.dev.jjs.InternalCompilerException: Failed to get JNode
[java] at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:140)
[java] at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:71)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.getType(BuildTypeMap.java:730)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.access[=12=]0(BuildTypeMap.java:99)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap$BuildDeclMapVisitor.visit(BuildTypeMap.java:195)
[java] at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.traverse(LocalDeclaration.java:237)
[java] at org.eclipse.jdt.internal.compiler.ast.ForeachStatement.traverse(ForeachStatement.java:527)
[java] at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:239)
[java] at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1239)
[java] at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:687)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.createPeersForNonTypeDecls(BuildTypeMap.java:637)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:514)
[java] at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:523)
[java] at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:599)
[java] at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:33)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:284)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)
[java] at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:232)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:198)
[java] at com.google.gwt.dev.Compiler.run(Compiler.java:170)
[java] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
[java] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
[java] at com.google.gwt.dev.Compiler.main(Compiler.java:177)
[java] [ERROR] <no source info>: public final enum com.dashboard.enums.DaysOfWeekEnum
[java] extends Enum<com.dashboard.enums.DaysOfWeekEnum>
[java] /* fields */
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Monday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Tuesday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnums Wednesday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Thursday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Friday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Saturday
[java] public static final [unresolved] com.dashboard.enums.DaysOfWeekEnum Sunday
com.dashboard.enums.DaysOfWeekEnum[] $VALUES
[java] /* methods */
[java] [unresolved] private void <init>()
[java] [unresolved] public static com.dashboard.enums.DaysOfWeekEnum valueOf(java.lang.String)
[java] [unresolved] public static com.dashboard.enums.DaysOfWeekEnum[] values()
[java] org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding
[java] [ERROR] at FormPanel.java(104): com.dashboard.enums.DaysOfWeekEnum day;
[java] org.eclipse.jdt.internal.compiler.ast.LocalDeclaration
通过在gwt.xml 中的源路径="" 下添加Enum class 包来修复它。
<source path='myapplication/enums/'/>