jsConstructor returns undefined

51 views
Skip to first unread message

pavel....@gmail.com

unread,
Nov 2, 2021, 4:49:41 AM11/2/21
to GWT Users
Hi all,

I have noticed that the next code returns the undefined value in gwt 2.9.0

public static native <T> Object getCtorFn(Class<T> cls) /*-{
$wnd.console.log(cls)
$wnd.console.log(cls.@java.lang.Class::jsConstructor)

return cls.@java.lang.Class::jsConstructor;
}-*/;

Does someone know is jsConstroctor still supported?
Or could be there is another way to achieve the same

Jens

unread,
Nov 5, 2021, 5:33:00 AM11/5/21
to GWT Users
You can use jsinterop-base library. It has a method 'Js.asConstructorFn(Class)'

-- J.

Thomas Broyer

unread,
Nov 5, 2021, 7:02:14 AM11/5/21
to GWT Users
On Friday, November 5, 2021 at 10:33:00 AM UTC+1 Jens wrote:
You can use jsinterop-base library. It has a method 'Js.asConstructorFn(Class)'

…which uses cls.@java.lang.Class::jsConstructor, so if it's null/undefined in your own JSNI, there's no reason it won't be in jsinterop-base's JSNI: https://github.com/google/jsinterop-base/blob/3db256c87fea1b90786451b1814f6354bb39f370/java/jsinterop/base/InternalJsUtil.java#L164-L166
🤔
Reply all
Reply to author
Forward
0 new messages