2

尝试编译通常由 jre 1.7 (51.0) 编译类引起的 gwt 项目时出现错误。我已经验证我的类是用 1.6 版本编译的。我几乎可以肯定这是包含在类路径中的其他一些类,但是在调试 maven 构建时我无法让 gwt 编译器中断。我正在使用 eclipse 尝试中断调试 maven 构建并为 UnsupportClassVersionError 和 UnableToCompleteException 添加断点,但是当发生这种情况时 jvm 并没有停止。我猜测 GWT 编译器可能在单独的进程下运行,我将无法轻松捕获这些异常。任何指针将不胜感激。

这是我尝试使用 maven 从命令行编译时出现的错误。

[INFO] --- gwt-maven-plugin:2.5.1:compile (default) @ smartbar ---
[INFO] Loading inherited module 'com.smartbar.SmartBar'
[INFO]    Loading inherited module 'com.smartbar.SmartBarCommon'
[INFO]       Loading inherited module 'com.google.gwt.inject.Inject'
[INFO]          [ERROR] Unexpected error while processing XML
[INFO] java.lang.UnsupportedClassVersionError: com/google/gwt/inject/rebind/GinjectorGenerator : Unsupported major.minor version 51.0
[INFO]  at java.lang.ClassLoader.defineClass1(Native Method)
[INFO]  at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
[INFO]  at java.lang.ClassLoader.defineClass(ClassLoader.java:615)


chinshaw$ java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)


chinshaw$ find . -name '*.class' | xargs file | head -10
    ./WEB-INF/classes/com/testing/client/activity/AbstractActivity.class:                                compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/activity/EstablishmentInventoryActivity.class:                  compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/activity/EstablishmentNavigationActivity.class:                 compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/ClientUserSession.class:                                        compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/events/EntityEditEvent$Handler.class:                           compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/events/EntityEditEvent.class:                                   compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/events/InventoryItemSelectionEvent$Handler.class:               compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/events/InventoryItemSelectionEvent.class:                       compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client

临时解决方案

这可能只是 maven 存储库的问题,但似乎 2.1.0 gin 包是用 1.7.0 构建的。我将我的依赖项降级到 2.0.0,现在它工作正常。

desktop-mini:2.1.0 chinshaw$ pwd
/Users/chinshaw/.m2/repository/com/google/gwt/inject/gin/2.1.0
desktop-mini:inject chinshaw$ find . -name '*.class'  -exec file {} \; | head -10
./client/AbstractGinModule.class: compiled Java class data, version 51.0
./client/assistedinject/BindingCollector.class: compiled Java class data, version 51.0
./client/assistedinject/FactoryModule.class: compiled Java class data, version 51.0
./client/assistedinject/GinFactoryModuleBuilder.class: compiled Java class data, version 51.0
./client/AsyncProvider.class: compiled Java class data, version 51.0
./client/binder/GinAnnotatedBindingBuilder.class: compiled Java class data, version 51.0
./client/binder/GinAnnotatedConstantBindingBuilder.class: compiled Java class data, version 51.0
./client/binder/GinAnnotatedElementBuilder.class: compiled Java class data, version 51.0
./client/binder/GinBinder.class: compiled Java class data, version 51.0
./client/binder/GinConstantBindingBuilder.class: compiled Java class data, version 51.0

这是错误ID,希望我先看那里。假设它首先是另一个罐子的问题。 http://code.google.com/p/google-gin/issues/detail?id=190

4

1 回答 1

2

enforceBytecodeVersion Enforcer Rule 应该能够帮助您解决这些问题它将遍历所有依赖项以检查它们是否与所需的类版本匹配。

于 2013-07-13T18:40:05.427 回答