konsoletyper / teavm

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

Support for OpenJDK #906

Closed catfoolyou closed 2 months ago

catfoolyou commented 2 months ago

Will there ever be any sort of support for OpenJDK in TeaVM? If not, what should I replace it with?

konsoletyper commented 2 months ago

TeaVM won't ever support OpenJDK. What are you going to replace? TeaVM I don't know, it depends. Perhaps, you can take a look at CheerpJ, but it's slower, supports only Java 8 (at least for now) and non-free.

catfoolyou commented 2 months ago

Why not? What exactly prevents TeaVM support for OpenJDK? Also I think CheerpJ has a free plan, but that won't cut it because I need at least Java 17.

konsoletyper commented 2 months ago

Why not? What exactly prevents TeaVM support for OpenJDK?

TeaVM comes with its own emulation of Java standard library. Reliance on OpenJDK would solve some issues like compatibility. However, the whole OpenJDK was written to be compiled and run against hardware CPUs, not for efficient AOT transpilation into another high-level language that runs in the entirely different environment. This requires to write tons of patches to OpenJDK. Now consider I invested my time into this task. Then, the next version of OpenJDK comes and I have to carefully review all the patches and perhaps fix them. For the project which is maintained mostly by one person in its spare time it's nearly impossible. Other reason is: TeaVM was not designed to run Java applications without modification. Its primary goal is to give developers the tool to share their Java code between platforms, perhaps taking TeaVM specifics in mind when writing code. With the support of OpenJDK developers would result with megabytes of overhead in the generated JavaScript, which is not what they want.