[ui] get rid of usage of internal SunGraphicsEnvironment class in JreHiDpiUtil
authorNikolay Chashnikov <Nikolay.Chashnikov@jetbrains.com>
Wed, 12 Aug 2020 15:05:13 +0000 (18:05 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Wed, 12 Aug 2020 17:09:07 +0000 (17:09 +0000)
This is needed to be able to compile intellij.platform.util.ui module using JDK 11 (IDEA-248086).

GitOrigin-RevId: a3d8f49c379f0d8478a0e53daa2e92a91317897c

platform/util/ui/src/com/intellij/ui/JreHiDpiUtil.java

index 3428da96c5011c5cc4965fb194a175b24c615f0e..7a7dedc8e5d3604c88d47d45194ed69c2cef90f4 100644 (file)
@@ -11,7 +11,6 @@ import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.annotations.TestOnly;
-import sun.java2d.SunGraphicsEnvironment;
 
 import java.awt.*;
 import java.lang.reflect.Method;
@@ -55,8 +54,9 @@ public final class JreHiDpiUtil {
             if (SystemInfo.isJetBrainsJvm) {
               try {
                 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
-                if (ge instanceof SunGraphicsEnvironment) {
-                  Method m = ReflectionUtil.getDeclaredMethod(SunGraphicsEnvironment.class, "isUIScaleEnabled");
+                Class<?> sunGraphicsEnvironmentClass = Class.forName("sun.java2d.SunGraphicsEnvironment");
+                if (sunGraphicsEnvironmentClass.isInstance(ge)) {
+                  Method m = ReflectionUtil.getDeclaredMethod(sunGraphicsEnvironmentClass, "isUIScaleEnabled");
                   value = m != null && (Boolean)m.invoke(ge);
                   jreHiDPI_earlierVersion = false;
                 }