If you've heard of Truffle or Graal you probably know that it can run as a JIT or produce a standalone executable, but there's actually so many more configurations it can run in - it's a true universal runtime system.
But it would run badly. WASM isn't designed to do the sorts of things a Graal backend needs (at least not fast).
It'd be much more direct to ship apps directly to the desktop, or to develop a kind of Graal browser. You could even fork Chromium to add GraalVM inside Blink. Trying to put Java into the browser is a dead end though, browser makers won't tolerate competing platforms they don't control.
> What one wants is a .class to WASM converter and there already a couple of them to choose from, namely TeaVM and CheerpJ as the most advanced ones
Do they provide the kind of best-in-class whole-world-analysis optimisations that Graal does?
But we should take a look at what they produce some time!
I think in practicality Graal's LLVM output is not terribly platform agnostic, as LLVM lacks some expressiveness for the thing that Graal needs to do for deoptimisation.
But you can't apply high-level optimisations by the time all you have is WASM bytecode and all your high-level structure is gone. You also don't have enough time to apply these optimisations if you're JIT compiling.