konsoletyper / teavm

Compiles Java bytecode to JavaScript, WebAssembly and C
https://teavm.org
Apache License 2.0
2.65k stars 265 forks source link

Endless loop / serious performance issue during "dependency resolution" stage #241

Open Pfiver opened 7 years ago

Pfiver commented 7 years ago

Hello

While trying to compile the thymeleaf library, it seems that teavm get stuck during the "dependency resolution" phase.

I am not that patient and have not ever let it run for more than 10 minutes on my mid 2012 MacBook Pro.

I somehow doubt that it would eventually halt, but have no clue really, what is going on. Can anybody at least try to come up with some explanation? What, if any, measures are taken in the code to prevent dependency cycles from producing an infinitely huge dependency graph. Unique node ID's? Are the ID's somehow getting messed up in this particular case?

It is not hard to reproduce at all. I created a very simple project based on the maven teavm-archetype and the "hello" sample in teavm: https://github.com/Pfiver/hello-teavm

Cheers Patrick

konsoletyper commented 7 years ago

It's definitely a bug that TeaVM enters infinite loop, instead of thinking, say, for 40 seconds and then reporting errors. I need major investigation of what's causing such behaviour (and it's going to be really big challenge). However, I can tell from the very start: give up. You won't ever be able to compile thymeleaf with TeaVM. It simply wasn't designed to compile every library for JVM. TeaVM's goal is to provide ability to write new code in JVM-compatible languages. This code would run under both TeaVM and JVM. It's possible to port some libraries for JVM to TeaVM by replacing all unsupported code. As for thymeleaf, I can guess porting will be huge task. Sorry.

If you need some HTML tempating under TeaVM, you can look at TeaVM Flavour project. It lacks documentation and works only under 0.4.3 (but I'm porting it to latest TeaVM right now). But if you are interested, I can help you with learning and possible start writing some docs.