GWT编译器错误:在子类上缺少接口方法(PlayN HTML) [英] GWT Compiler Error: Missing Interface Methods on Subclass (PlayN HTML)

查看:150
本文介绍了GWT编译器错误:在子类上缺少接口方法(PlayN HTML)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

免责声明:我是GWT / PlayN的新手,所以这可能是我制作的一个明显的错误。



当我有一个基本的(启动器) PlayN项目中,我的 BlahGame 类方法实现了 Game 接口,该接口需要三个方法: init paint update 。初学者类看起来像这样:

  public class BlahGame implements Game {
public void init(){... }
public void paint(float alpha){...}
public void update(float alpha){...}
}

我创建了一个 BaseGame 类来实现游戏,如下所示:

  public class BaseGame implements Game {
public void init(){...}
public void paint(float alpha){.. 。}
public void update(float alpha){...}
}

然后我的主要游戏类成为 BaseGame 这样的子类:

  public class BlahGame extends BaseGame {
public void init(){... base.init(); ...}
}

所有东西都是从Java编译和工作的。但是,当我尝试GWT编译我的游戏的HTML版本时,出现此错误:

  com.google.gwt。 dev.jjs.InternalCompilerException:未能通过com.google.gwt.dev在com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:140)
处获取JNode
。 jjs.impl.TypeMap.get(TypeMap.java:71)
,位于com.google.gwt.dev.jjs.impl.BuildTypeMap.getType(BuildTypeMap.java:730)

。 ..


[错误]<无源信息>:public class com.deengames.BaseGame
extends java.lang.Object
implements:playn.core .game
/ * methods * /
public void< init>()
public void init()
[unresolved] public void paint(float)
[未解决] public void update(float)
[unresolved] public int updateRate()

I我不确定我在这里错过了什么。是否需要更新一些GWT类?或者是别的什么?自从Java版本编译之后,我曾预期要编译HTML vesrion;这些类的签名不应该从子类更改。



编辑:我使用全新的样板PlayN项目。在类中,如果我扩展基类并实现接口,它仍然不能编译;只删除基类扩展工作。

解决方案

这是您的问题:

  [错误]<无源信息>:public class com.deengames.BaseGame 

您已将代码放入顶层包 com.deengames 中。我敢打赌,你的GWT模块文件也在同一个软件包目录中,可能类似于 com / deengames / MyGame.gwt.xml 。 GWT模块文件必须为GWT将看到的所有代码指定 sub -package目录。



使用PlayN Maven生成项目原型,它有这样的结构:

$核心/ src / main / java / com / foozle / core / Barzle.java
core / src / main / java / com / foozle / resources / images / bg.png
html / src / main / java / com / foozle / Barzle.gwt.xml
html / src / main / java / com / foozle / html / BarzleHtml.java

所有的游戏代码都在 com.foozle.core 包,资源位于 com.foozle.resources 包中。如果您查看生成的 Barzle.gwt.xml 文件,您将看到:

 < module rename-to ='barzle'> 
< inherits name ='playn.PlayN'/>
< source path ='core'/>
< source path ='html'/>
< public path =resources/>
< entry-point class ='com.foozle.html.BarzleHtml'/>
< / module>

两个< source> 行显式将 com.foozle.core com.foozle.html 子包添加到GWT项目中。 GWT模块文件中未列出明确的任何内容都将被忽略。由于GWT指定这些包的方式,因此无法将顶级包添加到GWT项目中。您无法使用:

 < source path =/> 

或:

 < source path =。/> 

您必须将所有代码放在您的GWT模块文件中明确列举的子包中。


Disclaimer: I'm new to GWT/PlayN, so this might be an obvious mistake that I'm making.

When I have a basic (starter) PlayN project, my BlahGame class method implements the Game interface, which requires three methods: init, paint, and update. The starter class looks something like:

public class BlahGame implements Game { 
  public void init() { ... }
  public void paint(float alpha) { ... }
  public void update(float alpha) { ... }
}

I created a BaseGame class to implement game, like so:

public class BaseGame implements Game { 
  public void init() { ... }
  public void paint(float alpha) { ... }
  public void update(float alpha) { ... }
}

My main game class then became a sublass of BaseGame like so:

public class BlahGame extends BaseGame {
  public void init() { ... base.init(); ... }
}

Everything compiles and works from Java. But when I try to GWT-compile the HTML version of my game, I get this error:

com.google.gwt.dev.jjs.InternalCompilerException: Failed to get JNode
    at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:140)
    at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:71)
    at com.google.gwt.dev.jjs.impl.BuildTypeMap.getType(BuildTypeMap.java:730)

...


      [ERROR] <no source info>: public class com.deengames.BaseGame
    extends java.lang.Object
    implements : playn.core.Game
/*   methods   */
public void <init>() 
public void init() 
[unresolved] public void paint(float) 
[unresolved] public void update(float) 
[unresolved] public int updateRate() 

I'm not sure what I'm missing here. Is it that some GWT classes need to be updated? Or is it something else? I had expected the HTML vesrion to compile since the Java version compiles; the signatures of the classes shouldn't change from subclassing.

Edit: I'm using a brand new, boilerplate PlayN project. In the class, if I extend the base class AND implement the interface, it still doesn't compile; only removing the base class extension works.

解决方案

This is your problem right here:

  [ERROR] <no source info>: public class com.deengames.BaseGame

You have put code in the top-level package com.deengames. I bet that your GWT module file is also in that same package directory, probably something like com/deengames/MyGame.gwt.xml. The GWT module file has to specify sub-package directories for all code that GWT will see.

When you generate a project using the PlayN Maven archetype, it has this structure:

core/src/main/java/com/foozle/core/Barzle.java
core/src/main/java/com/foozle/resources/images/bg.png
html/src/main/java/com/foozle/Barzle.gwt.xml
html/src/main/java/com/foozle/html/BarzleHtml.java

All of the game code is in the com.foozle.core package and the resources are in the com.foozle.resources package. If you look at the generated Barzle.gwt.xml file you will see:

<module rename-to='barzle'>
  <inherits name='playn.PlayN'/>
  <source path='core'/>
  <source path='html'/>
  <public path="resources" />
  <entry-point class='com.foozle.html.BarzleHtml'/>
</module>

The two <source> lines explicitly add the com.foozle.core and com.foozle.html sub-packages to the GWT project. Anything that is not explicitly listed in this GWT module file will be ignored by GWT. Due to the way GWT specifies these packages, it is not possible to add the top-level package to your GWT project. You cannot use:

<source path=""/>

or:

<source path="."/>

You have to put all of your code in sub-packages that are explicitly enumerated in your GWT module file.

这篇关于GWT编译器错误:在子类上缺少接口方法(PlayN HTML)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆