From bb8d5f99b6f28a53165e55addf77fffd3d9b1a90 Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Mon, 28 Apr 2025 14:27:56 +0200 Subject: [PATCH] IDEA-223372 Unable to see image if remote target is headless GitOrigin-RevId: a5ea72b76bb12025ea25853737231828583b98c2 --- .../com/intellij/rt/debugger/ImageSerializer.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/java/java-runtime/src/com/intellij/rt/debugger/ImageSerializer.java b/java/java-runtime/src/com/intellij/rt/debugger/ImageSerializer.java index c03f18b1f847..6abd747b0fcf 100644 --- a/java/java-runtime/src/com/intellij/rt/debugger/ImageSerializer.java +++ b/java/java-runtime/src/com/intellij/rt/debugger/ImageSerializer.java @@ -1,4 +1,4 @@ -// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.rt.debugger; import javax.imageio.ImageIO; @@ -51,8 +51,15 @@ public final class ImageSerializer { else { final int w = icon.getIconWidth(); final int h = icon.getIconHeight(); - final BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment() - .getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(w, h, Transparency.TRANSLUCENT); + BufferedImage image; + try { + image = GraphicsEnvironment.getLocalGraphicsEnvironment() + .getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(w, h, Transparency.TRANSLUCENT); + } + catch (HeadlessException e) { + //noinspection UndesirableClassUsage + image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); + } final Graphics2D g = image.createGraphics(); icon.paintIcon(null, g, 0, 0); g.dispose();