Skip to content

Store main thread in Jvm.init() - #12991

Open
kevinresol wants to merge 1 commit into
HaxeFoundation:developmentfrom
kevinresol:patch-16
Open

Store main thread in Jvm.init()#12991
kevinresol wants to merge 1 commit into
HaxeFoundation:developmentfrom
kevinresol:patch-16

Conversation

@kevinresol

@kevinresol kevinresol commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Edit: this actually does not fix my event loop problem. We actually need to probe the haxe.EventLoop class in the main function in order to capture the correct "main eventloop" into the TLS....

I made a temp patch lib here: https://github.com/kevinresol/haxe12985/blob/main/src/haxe/issue12985/Patch.hx

A quick fix that is probably not ideal as it still brings in 3 extra classes (w/ full dce) into the output jar for a minimal trace() Haxe app. But they are quite minimal (see below) and I think we should have it.

A more proper fix is probably to store only the native java thread ref, and update sys.thread.Thread to use it.

See #12985

Screenshot 2026-07-16 at 21 55 16 Screenshot 2026-07-16 at 21 55 09 Screenshot 2026-07-16 at 21 55 24

@kevinresol

Copy link
Copy Markdown
Contributor Author

I actually tried to follow up by implementing the suggested alternative above. But that won't really fly because the __init__ function is really assuming itself to be run in the main thread (see below)

currentTLS.value = mainThread;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant