On Fri, 15 Aug 2025 20:10:10 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:
> Maybe disableNativeIME is called when the top level Window is disposed, No it is not. Nothing calls disableNativeIME when the window is disposed. I tried this with the disposer removed and finalize restored just to be sure. Also it needs to be called 'early' but not 'too early' during WIndow.dispose() If the input method is active when you try to dispose it via APIs like disableNativeIM() then an exception is thrown. If you call it too late - after removeNotify() then it will not be sent because the peer is now nulled out. src/java.desktop/windows/native/libawt/windows/awt_Toolkit.cpp @@ -1082,6 +1082,7 @@ LRESULT CALLBACK AwtToolkit::WndProc(HWND hWnd, UINT message, AwtComponent* comp = (AwtComponent*)JNI_GET_PDATA(peer); if (comp != NULL) { comp->SetInputMethod(self, useNativeCompWindow); comp->ImmAssociateContext((HIMC)((intptr_t)context)); } Since we never call it, then this migration to disposer changes nothing. If we do call it I think it should be called in WInputMethod.removeNotify() which will clearly be before dispose(). I will add that and we'll be better off then we were before this change. I also found that if the window has focus when it is dispose()'d that it will receive a focus lost event which ironically creates a new WInputMethod because Window.dispose() had nulled out the existing one Either don't null out the disposed one, or do something else to avoid re-creation, or decide that it is harmless . For now I will leave that as it seems to be harmless, pre-existing and un-related to this change, although a little wasteful. It also would be more than a windows-only change. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/26706#discussion_r2285798990