static int autoVMExit_visibleObjects() { int objectCount = 0; // Scan for windows Map unimportantWindows = cast vm_generalMap_get("unimportant windows"); Window[] windowList = Window.getWindows(); for (Window window : windowList) { if (window.isVisible() && !containsKey(unimportantWindows, window)) ++objectCount; } // Scan for tray icons try { objectCount += SystemTray.getSystemTray().getTrayIcons().length; } catch (Throwable e) { // ignore } // Scan for JavaFX stages try { objectCount += l((L) call(_getClass("com.sun.javafx.robot.impl.FXRobotHelper"), "getStages")); } catch { } ret objectCount; }