java-native-access/jna · warning · UnsupportedOperationException

This platform is not supported, yet.

Error message

This platform is not supported, yet.

What it means

W32WindowUtils (base Provider) getWindowIcon always throws UnsupportedOperationException because retrieving a window icon is only implemented for specific platforms. Any caller on a non-implemented platform gets this unconditional throw.

Source

Thrown at contrib/platform/src/com/sun/jna/platform/WindowUtils.java:634

                }
            }
        }

        /**
         * Obtains the set icon for the window associated with the specified
         * window handle.
         *
         * @param hwnd
         *            The concerning window handle.
         * @return Either the window's icon or {@code null} if an error
         *         occurred.
         *
         * @throws UnsupportedOperationException
         *             Thrown if this method wasn't yet implemented for the
         *             current platform.
         */
        protected BufferedImage getWindowIcon(final HWND hwnd) {
            throw new UnsupportedOperationException("This platform is not supported, yet.");
        }

        /**
         * Detects the size of an icon.
         *
         * @param hIcon
         *            The icon handle type.
         * @return Either the requested icon's dimension or an {@link Dimension}
         *         instance of {@code (0, 0)}.
         *
         * @throws UnsupportedOperationException
         *             Thrown if this method wasn't yet implemented for the
         *             current platform.
         */
        protected Dimension getIconSize(final HICON hIcon) {
            throw new UnsupportedOperationException("This platform is not supported, yet.");
        }

View on GitHub (pinned to d036ad9781)

Solutions

  1. Only call getWindowIcon after confirming platform support (Platform.isWindows())
  2. Catch UnsupportedOperationException and provide a fallback icon
  3. Implement the method in a platform-specific Provider subclass

Example fix

// before
BufferedImage icon = WindowUtils.getWindowIcon(frame);
// after
BufferedImage icon = null;
try {
    icon = WindowUtils.getWindowIcon(frame);
} catch (UnsupportedOperationException e) {
    icon = frame.getIconImage() != null
        ? (BufferedImage) frame.getIconImage() : defaultIcon;
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!Platform.isWindows()) {
    throw new UnsupportedOperationException("getWindowIcon not implemented on " + System.getProperty("os.name"));
}

Type guard

boolean windowIconSupported() {
    return Platform.isWindows();
}

Try / catch

try {
    icon = WindowUtils.getWindowIcon(frame);
} catch (UnsupportedOperationException e) {
    icon = frame.getIconImage();
}

Prevention

When it happens

Trigger: Calling WindowUtils.getWindowIcon(Window) on a platform where the underlying protected getWindowIcon(HWND) was never implemented (not Windows in this provider).

Common situations: Code written against Windows behavior running on Linux/macOS; new JDKs where the native peer lookup fails and the unsupported base path is reached.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12). Data as JSON: /api/errors/6911252a22ccd494. Report an issue: GitHub.