【问题标题】:Does GWT support classes in packages of external jars?GWT 是否支持外部 jar 包中的类?
【发布时间】:2014-11-07 22:24:28
【问题描述】:

我有this 类:

package com.badlogic.gdx.physics.box2d;

/** placed in this package to have access to the protected {@code addr} fields */
public class Box2DUtils {

    /** @return {@link Body#addr} */
    public static long getAddr(Body body) {
        return body.addr;
    }

    // more methods...

}

包com.badlogic.gdx.physics.box2d 位于依赖项jar 中。 不过,该课程是我的代码的一部分。是的,我知道这是一个 hack。

编译此代码会导致此错误:

Compiling module com.mygdx.game.GdxDefinition
   Validating units:
      [ERROR] Errors in 'jar:file:/home/dermetfan/.gradle/caches/modules-2/files-2.1/net.dermetfan.libgdx-utils/libgdx-utils-box2d/0.7.2/c4b052017a597e18b40c0dd7e42eff400d2f0731/libgdx-utils-box2d-0.7.2-sources.jar!/com/badlogic/gdx/physics/box2d/Box2DUtils.java'
         [ERROR] Line 24: addr cannot be resolved or is not a field
         [ERROR] Line 29: addr cannot be resolved or is not a field
         [ERROR] Line 34: addr cannot be resolved or is not a field
   [ERROR] Aborting compile due to errors in some input files

我怀疑 GWT 存在问题,因为我的类是来自外部 jar 的包的一部分。真的吗?有什么解决方法吗?

谢谢!

【问题讨论】:

    标签: gwt libgdx box2d


    【解决方案1】:

    是的,GWT 支持外部 jar 包中的类。

    但是,如果这是将在客户端运行的代码,即正在转换为 javascript 的代码,那么您也需要源代码。

    【讨论】:

    • 源可用,但 GWT 后端中确实不存在 addr 字段。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多