Running /root/org/teavm/jsinterop/ClassExportTest
Tests run: 18, failed: 0,
:-)
Hey - that looks promising.
But really cumbersome to set up - it took me some time until I figured
out that I need to start src/test/js/run.sh and then open start
src/test/js/index.html in Firefox before the timeout wins the
Promise.race() so that a websocket connection is established from
Firefox to Node to run the tests.
Is there an easier way to do it?
On 2017-04-27 22:34, Patrick Pfeifer wrote:
> On 2017-04-17 16:46, Alexey Andreev wrote:
>>
>>> But I'm wondering if it would be better to create an
>>> implementation of GWT JsInterop for TeaVM.
>>>
>>> Is it technically possible to create a implementation of JsInterop
>>> using full or partial GWT JsInterop 1.0?
>> Yes, it's possible
>>> The current JSO implementation could be a good starting point to
>>> implement it?
>> JSO implementation is a good starting point, yes. Another starting
>> point is html4j
>> <
http://bits.netbeans.org/html+java/1.4/overview-summary.html>
>> implementation (which can be found here
>> <
https://github.com/konsoletyper/teavm/tree/master/html4j>). Also, I
>> started jsinterop implementation myself, but abandoned it due to lack
>> of free time. It can be found in this branch
>> <
https://github.com/konsoletyper/teavm/tree/jsinterop>. The most
>> non-trivial thing here is to understand how to interact with dead
>> code elimination (which is for historical reasons is called
>> DependencyChecker). JSO is designed to have very low impact on DCE,
>> while html4j is not, so you can examine its code to understand how to
>> extend TeaVM to properly track dataflow information for jsinterop.
>
> I decided to give that a try (i.e. JSO implementation). Thus I have
> migrated your branch back into current master and basically dumped all
> diffs and just kept the /jsonterop module and the files added in
> /tests . So far so good? It seems to work (e.g. it compiles).
> (JsInteropPostProcessor now implements RendererListener - which seems
> to be the successor of the AbstractRendererListener class that it
> extended.)
>
> I haven't run the tests (-DskipTests) but added the following two
> lines to HelloWorld Client instead.
>
> import static elemental2.dom.DomGlobal.window;
>
> window.alert("Ok");
>
> Now, when I try to compile that, I get the below errors. So I just
> wanted to ask a few things:
>
> * Do you think my approach is correct?
> * Can you point me in the right direction to make further progress?
> * When you look at the below error output, how would you go about
> fixing it? (In the teavm-samples-hello POM, I removed the "teavm-js"
> dependency and added "teavm-jsinterop" and "elemental2-dom".)
>
>
> [INFO] Building JavaScript file
> [INFO] Output file built with errors
> [ERROR] JS name collision (postMessage) detected on method
> elemental2.dom.DomGlobal.postMessage(Ljava/lang/Object;Ljava/lang/String;)V
> at elemental2.dom.DomGlobal.postMessage
> at org.teavm.samples.hello.Client.sayHello(Client.java:47)
> at org.teavm.samples.hello.Client.lambda$main$0(Client.java:35)
> at $$LAMBDA0$$.handleEvent
> at $$LAMBDA0$$.handleEvent
> [ERROR] JS name collision (postMessage) detected on method
> elemental2.dom.DomGlobal.postMessage(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V
> at elemental2.dom.DomGlobal.postMessage
> at org.teavm.samples.hello.Client.sayHello(Client.java:47)
> at org.teavm.samples.hello.Client.lambda$main$0(Client.java:35)
> at $$LAMBDA0$$.handleEvent
> at $$LAMBDA0$$.handleEvent
>
> ..... [truncated; ~ 100 more "JS name collision" errors] .....
>
> [ERROR] JS name collision (arguments) detected on method
> jsinterop.base.Js.arguments()Ljsinterop/base/JsArrayLikeOfAny;
> at jsinterop.base.Js.arguments
> [ERROR] JS name collision (undefined) detected on method
> jsinterop.base.Js.undefined()Ljava/lang/Object;
> at jsinterop.base.Js.undefined
> [INFO] Debug information successfully written
> [INFO] Source maps successfully written
> [INFO] Source files successfully written
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
>
>
>