problems with the list of windows in the dock menu for an application

I have several applications (written in Java, although I doubt that matters). Some of these applications define custom dock menus and some do not. None of them are NSDocument based. Most of the time, the dock menus for these applications include at the top a list of the document's windows. Windows that are hidden (minimized?) are included in the list with a diamond icon. I don't think that my applications or Java are creating these menu items. What I don't understand is that when the application is hidden, sometimes these menu items disappear from the dock menu and sometimes they remain. Is this a bug, or is there some rational explanation? (I would prefer that the menu items remain.) I'm running macOS 13.3.1 (Ventura).