对于GWT中的System类型,方法nanoTime()未定义

Der*_*rek 7 gwt

在eclipse中编译我的libgdx应用程序时,我不断收到此错误:

 [ERROR] Errors in 'file:/C:/Users/Zorfie/Programing/Java/workspace/Libgdx/src/sim/states/BasicBox2DState.java'
      [ERROR] Line 157:  The method nanoTime() is undefined for the type System
      [ERROR] Line 159:  The method nanoTime() is undefined for the type System
      [ERROR] Line 160:  The method nanoTime() is undefined for the type System
      [ERROR] Line 161:  The method nanoTime() is undefined for the type System
   [ERROR] Errors in 'jar:file:/C:/Program%20Files/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201203300216-rel-r37/gwt-2.4.0/gwt-user.jar!/com/google/web/bindery/autobean/shared/impl/StringQuoter.java'
      [ERROR] Line 21:  The import org.json cannot be resolved
      [ERROR] Line 69:  JSONObject cannot be resolved
   [ERROR] Errors in 'jar:file:/C:/Program%20Files/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201203300216-rel-r37/gwt-2.4.0/gwt-user.jar!/com/google/web/bindery/autobean/vm/impl/JsonSplittable.java'
      [ERROR] Line 23:  The import org.json cannot be resolved
      [ERROR] Line 24:  The import org.json cannot be resolved
      [ERROR] Line 25:  The import org.json cannot be resolved
      [ERROR] Line 40:  JSONObject cannot be resolved to a type
      [ERROR] Line 47:  JSONObject cannot be resolved to a type
Run Code Online (Sandbox Code Playgroud)

这意味着GWT不支持.nanoTime(),是这种情况还是我只是运行错误的JRE?(我检查了项目,它说它是1.6).

jus*_*sio 10

不存在用于支持nanoTime()在GWT因为是在JavaScript它不支持.

GWT中最接近的模拟是 Duration.currentTimeMillis()

  • 我们还添加了一个指向文档的链接:https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation (2认同)