Closed xupwup closed 1 month ago
It's a crash within TeaVM itself. Looks like you are trying to compile to WebAssembly target code with coroutines, which is known to be quite buggy. I'm not motivated to fix bugs in WebAssembly backend, so I suggest switching to JS backend instead.
Ah, ok, I was planning on getting rid of my Thread use anyway. Nice to know that that's what's causing the problem.
Aside from that, out of curiosity, what's the reason you don't want to work on the wasm backend? I was under the impression that wasm was the future...
@xupwup WebAssembly does not bring anything useful in this case. Performance is not significantly better, but everything other is: generated binary size, debugging, interop with JS, complexity of compiler internals. And there's no demand: people just satisfied with JS and I don't know of anyone who is going to use WebAssembly on production.
Anyway, you better start with JS backend and then, when everything ok, you can start digging in WebAssembly direction
Thanks for the help so far. I'm now running into errors like below. I see classes like TMath where you replace some implementations. It looks like I have to replace your TMath by mine, and I seem to need to override something inside JOML too (to disable MemUtilUnsafe for example). Can you tell me how to do that?
Method java.lang.Math.fma(FFF)F was not found at org.joml.Math.fma(Math.java:445) at org.joml.Vector3f.normalize(Vector3f.java:1402)
Class java.lang.Module was not found
at jdk.internal.reflect.Reflection.
You can write a TeaVM plugin that defines class transformer. In detail: include teavm-core
artifact into your build, implement TeaVMPlugin
and register it using ServiceLoader
convention. Then, implement ClassHolderTransformer
and add your implementation in TeaVMPlugin
implementation to host
(add
method). In ClassHolderTransformer
you can add method fma
to class java.lang.Math
. The best way to create a program is to take it from some other class (which you of course write). Also, you can use ProgramEmitter
class. As for MemUtil
, after brief observation I found that you can patch MemUtil.createInstance
class and make it return MemUtilNIO
instance.
Please, don't ask me for details. Just clone TeaVM sources and find examples of TeaVMPlugin
, ClassHolderTransformer
, ProgramEmitter
, etc. This should be enough.
Ok, I've managed to replace a lot of functions, but the only one I'm struggling with now is java.nio.channels.Channels.
ReadableByteChannel newChannel(InputStream in)
It's just saying Class java.nio.channels.Channels was not found. Is there a way to add that class?
Sure. Notice how emulating classes are named in TeaVM repository. You can create you own class using same naming pattern in your own project and this should work just fine.
I got everything working, thanks for the help and for making such an awesome library!
Hi,
I'm getting this error, but TeaVM doesn't tell me where the problem is. I've tried debugging, and it seems to point me to org/teavm/classlib/java/lang/TThrowable.java, in printStackTrace(PrintStream stream), on the for loop that iterates over the stack trace. But that class seems to be supplied by TeaVM, so that should work, right? I'm trying to generate wasm here by the way.
What am I doing wrong here? And is there a way to get a better error message from TeaVM to help me change my code to make things work?
My teavm configuration options are:
The complete stack trace is: