()
| 510 | } |
| 511 | |
| 512 | function ensureDisplayEdt() { |
| 513 | const state = checkDisplayInitState(); |
| 514 | if (state.edt) { |
| 515 | return true; |
| 516 | } |
| 517 | if (!state.instance) { |
| 518 | emitDiagLine("PARPAR:DIAG:EDT_ENSURE:instanceMissing=1"); |
| 519 | return false; |
| 520 | } |
| 521 | const threadClass = jvm.classes && jvm.classes["java_lang_Thread"]; |
| 522 | if (!threadClass) { |
| 523 | emitDiagLine("PARPAR:DIAG:EDT_ENSURE:threadClassMissing=1"); |
| 524 | return false; |
| 525 | } |
| 526 | const mainThread = jvm.mainThreadObject || (jvm.currentThread && jvm.currentThread.object); |
| 527 | if (!mainThread) { |
| 528 | emitDiagLine("PARPAR:DIAG:EDT_ENSURE:mainThreadMissing=1"); |
| 529 | return false; |
| 530 | } |
| 531 | const existingActive = threadClass.staticFields && threadClass.staticFields["activeThreads"]; |
| 532 | if (existingActive && existingActive > 0) { |
| 533 | state.instance.cn1_java_lang_Display_edt = mainThread; |
| 534 | emitDiagLine("PARPAR:DIAG:EDT_ENSURE:reusedMainThread=1"); |
| 535 | return true; |
| 536 | } |
| 537 | const edtThread = jvm.newObject("java_lang_Thread"); |
| 538 | edtThread.cn1_java_lang_Thread_alive = 1; |
| 539 | edtThread.cn1_java_lang_Thread_name = jvm.createStringLiteral("EDT"); |
| 540 | edtThread.cn1_java_lang_Thread_nativeThreadId = jvm.nextThreadId++; |
| 541 | state.instance.cn1_java_lang_Display_edt = edtThread; |
| 542 | if (threadClass.staticFields) { |
| 543 | threadClass.staticFields["activeThreads"] = (threadClass.staticFields["activeThreads"] || 0) + 1; |
| 544 | } |
| 545 | emitDiagLine("PARPAR:DIAG:EDT_ENSURE:createdSyntheticEdt=1"); |
| 546 | return true; |
| 547 | } |
| 548 | |
| 549 | function emitDisplayInitDiag(marker) { |
| 550 | const state = checkDisplayInitState(); |
no test coverage detected