【问题标题】:GWT 2.6.0 - Uncaught java.lang.ClassCastExceptionGWT 2.6.0 - 未捕获的 java.lang.ClassCastException
【发布时间】:2015-07-07 16:34:21
【问题描述】:

我在超级开发模式下使用 GWT 2.6.0(在 Linux 上使用 IntelliJ Idea 14 + Chrome 43.0.2357.130(64 位))。

在页面加载过程中,Chrome 控制台出现异常

Uncaught java.lang.ClassCastException Impl.java:99
(anonymous function) @ Impl.java:99
gwtOnLoad @ oldstar-0.js:87303
(anonymous function) @ ClassLiteralHolder.java:23

Impl.java:99throw e;com.google.gwt.core.client.impl.Impl

 public static native JavaScriptObject entry(JavaScriptObject jsFunction) /*-{
    return function() {
      try {
        return @com.google.gwt.core.client.impl.Impl::entry0(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)(jsFunction, this, arguments);
      } catch (e) {
        // This catch block is here to ensure that the finally block in entry0
        // will be executed correctly on IE6/7.  We can't put a catch Throwable
        // in entry0 because this would always cause the unhandled exception to
        // be wrapped in a JavaScriptException type.
        throw e;
      }
    };
  }-*/;

oldstar-0.js:87303 在生成的 oldstar-0.js 中是 $entry(init_2)();

function gwtOnLoad(errFn, modName, modBase, softPermutationId){
  $moduleName = modName;
  $moduleBase = modBase;
  if (errFn)
    try {
      $entry(init_2)();
    }
     catch (e) {
      errFn(modName);
    }
   else {
    $entry(init_2)();
  }
}
package com.google.gwt.lang;

final class ClassLiteralHolder {
}

还有 init_2() 这是对init() in EntryMethodHolder.java的引用

package com.google.gwt.lang;

/**
 * This class holds the boot strap entry method that the compiler generates.
 */
public class EntryMethodHolder {
  public static final void init() {
    // Filled in by the compiler to call entry methods.
  }
}

【问题讨论】:

标签: javascript java debugging gwt


【解决方案1】:

粘贴的代码是 JS 和 Java 的边界,极不可能抛出这个异常(我敢说不可能)。

如消息所示,这是一个未捕获异常,它在您的代码中的其他地方抛出,并在它从 Java 泄漏到 JS 之前被此接线捕获。

认为您的 EntryPoint 由 EntryMethodHolder.init 调用 - 这强烈暗示您的 EntryPoint 在您的应用尝试启动时抛出 ClassCastException,但 UncaughtExceptionHandler(如果您有...... .) 尚未设置为处理此问题。

尝试查看 onModuleLoad 中的内容,或添加 try/catch 以确定其来源。

【讨论】:

  • 另外,您可以要求 Chrome 在每个抛出异常时停止。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-07
  • 1970-01-01
  • 1970-01-01
  • 2020-02-25
  • 1970-01-01
  • 2014-03-15
  • 1970-01-01
相关资源
最近更新 更多