From 924b86e37504b12121d706e1c38e98e9c6145a6f Mon Sep 17 00:00:00 2001 From: Kevin Leung Date: Thu, 16 Jul 2026 21:53:22 +1000 Subject: [PATCH] Store main thread in Jvm.init() Closes #12985 --- std/jvm/Jvm.hx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/std/jvm/Jvm.hx b/std/jvm/Jvm.hx index cf910a2cd6f..ce350d9f0d4 100644 --- a/std/jvm/Jvm.hx +++ b/std/jvm/Jvm.hx @@ -39,6 +39,9 @@ import jvm.annotation.EnumValueReflectionInformation; @:keep @:native('haxe.jvm.Jvm') class Jvm { + // https://github.com/HaxeFoundation/haxe/issues/12985 + static var mainThread:sys.thread.Thread; + public static function init():Void { #if std_encoding_utf8 try { @@ -46,6 +49,8 @@ class Jvm { java.lang.System.setErr(new java.io.PrintStream(java.lang.System.err, true, "utf-8")); } catch (e:java.io.UnsupportedEncodingException) {} #end + + mainThread = sys.thread.Thread.main(); } static public function getNativeType(obj:T):java.lang.Class {