Skip to content

Commit 7651cce

Browse files
committed
workaround idea platform guarding Task.immediate, unblock 6.1 Linux CI
1 parent b387acb commit 7651cce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+NativeTranslation.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,14 +867,20 @@ extension JNISwift2JavaGenerator {
867867
}
868868
}
869869

870+
printer.print("var taskInitialized = false") // FIXME: horrible hack so we can keep having CI for Linux with 6.1.2 until build issues with 6.2 are resovled
871+
printer.print("#if canImport(Darwin)")
870872
printer.printBraceBlock("if #available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *)") { printer in
873+
printer.print("taskInitialized = true")
871874
printer.printBraceBlock("Task.immediate") { printer in
872875
// Immediate runs on the caller thread, so we don't need to attach the environment again.
873876
printer.print("var environment = environment!") // this is to ensure we always use the same environment name, even though we are rebinding it.
874877
printTask(printer: &printer)
875878
}
876879
}
877-
printer.printBraceBlock("else") { printer in
880+
printer.print("#endif // canImport(Darwin)")
881+
882+
// printer.printBraceBlock("else") { printer in
883+
printer.printBraceBlock("if !taskInitialized") { printer in
878884
printer.printBraceBlock("Task") { printer in
879885
// We can be on any thread, so we need to attach the thread.
880886
printer.print("var environment = try! JavaVirtualMachine.shared().environment()")

0 commit comments

Comments
 (0)