On Fri, 8 Aug 2025 21:38:27 GMT, Phil Race <p...@openjdk.org> wrote:

> Remove finalize() from WInputMethod.java - it is used to free a native id.
> Also the reason dispose() didn't free it seems no longer relevant.
> Although I did see (when instrumenting) that dispose() was called when I 
> disposed() the Frame referencing the IM,
> I don't know if I can be sure that is always done. So safest to add the 
> Disposer in case it isn't.

src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java line 165:

> 163:     @Override
> 164:     public void dispose() {
> 165:         disposerRecord.dispose();

The native dispose will call `ImmDestroyContext` which is specified as:
> However, before calling ImmDestroyContext, the application must remove the 
> input context from any association with windows in the thread by using the 
> [ImmAssociateContext](https://learn.microsoft.com/en-us/windows/desktop/api/imm/nf-imm-immassociatecontext)
>  function.

I did not check the code, but maybe we are calling `ImmAssociateContext` in the 
wrong moment and have to postpone this "dispose" until all the object is really 
unused?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26706#discussion_r2277816637

Reply via email to