我正在尝试使用 JSO 的包私有方法在 JSNI 方法体内实例化一个 java 类型::new()
,但所有实例都作为空句柄返回。怎么会?
是否可以使用与 Java 类似的语法来实例化该类?
以下是相关代码:
public class OnChangeHandlerJso extends JavaScriptObject {
protected OnChangeHandlerJso() {};
public static native JavaScriptObject create() /*-{
return function(cm, changeInfo) {
var eventBus = @com.gigaspaces.codemirror_gwt.client.events.EventUtils::CODE_MIRROR_EVENT_BUS;
var event = @com.gigaspaces.codemirror_gwt.client.events.EditorContentChangeEvent::new()();
// could something like this work?
// var event = new @com.gigaspaces.codemirror_gwt.client.events.EditorContentChangeEvent;
event.@com.gigaspaces.codemirror_gwt.client.events.EditorContentChangeEvent::setCm(Lcom/gigaspaces/codemirror_gwt/client/jsni/CodeMirrorJso;)(cm);
event.@com.gigaspaces.codemirror_gwt.client.events.EditorContentChangeEvent::setChangeInfo(Lcom/gigaspaces/codemirror_gwt/client/jsni/ChangeInfoJso;)(changeInfo);
eventBus.@com.google.gwt.event.shared.EventBus::fireEvent(Lcom/google/gwt/event/shared/GwtEvent;)(event);
};
}-*/;
}