From dfb0cde3f74adc09bb64f988515c4d61c98c591b Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 5 May 2020 14:38:54 +0200 Subject: [PATCH] ToolkitBugsProcessor is outdated GitOrigin-RevId: df508be2f489480507bdbfa2c82293cba3176186 --- .../src/com/intellij/ide/IdeEventQueue.java | 6 +- .../intellij/ide/ToolkitBugsProcessor.java | 177 ------------------ 2 files changed, 2 insertions(+), 181 deletions(-) delete mode 100644 platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index f8d3e6a188d9..0539871af06f 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -104,7 +104,6 @@ public final class IdeEventQueue extends EventQueue { private final IdeKeyEventDispatcher myKeyEventDispatcher = new IdeKeyEventDispatcher(this); private final IdeMouseEventDispatcher myMouseEventDispatcher = new IdeMouseEventDispatcher(); private final IdePopupManager myPopupManager = new IdePopupManager(); - private final ToolkitBugsProcessor myToolkitBugsProcessor = new ToolkitBugsProcessor(); /** * Counter of processed events. It is used to assert that data context lives only inside single @@ -692,9 +691,8 @@ public final class IdeEventQueue extends EventQueue { if (isTestMode()) { ExceptionUtil.rethrow(t); } - if (!myToolkitBugsProcessor.process(t)) { - StartupAbortedException.processException(t); - } + + StartupAbortedException.processException(t); } @NotNull diff --git a/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java b/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java deleted file mode 100644 index dd0be7d09c71..000000000000 --- a/platform/platform-impl/src/com/intellij/ide/ToolkitBugsProcessor.java +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2000-2019 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. -package com.intellij.ide; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.registry.Registry; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.BitUtil; - -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.List; - -public class ToolkitBugsProcessor { - private static final Logger LOG = Logger.getInstance("ToolkitBugProcessor"); - - private final List myHandlers = new ArrayList<>(); - - public ToolkitBugsProcessor() { - Class[] classes = getClass().getDeclaredClasses(); - for (Class each : classes) { - if (!BitUtil.isSet(each.getModifiers(), Modifier.ABSTRACT) && Handler.class.isAssignableFrom(each)) { - try { - Handler eachHandler = (Handler)each.newInstance(); - if (eachHandler.isActual()) { - myHandlers.add(eachHandler); - } - } - catch (Throwable e) { - LOG.error(e); - } - } - } - } - - public boolean process(Throwable e) { - if (!Registry.is("ide.consumeKnownToolkitBugs")) return false; - - StackTraceElement[] stack = e.getStackTrace(); - for (Handler each : myHandlers) { - if (each.process(e, stack)) { - LOG.info("Ignored exception by toolkit bug processor, bug id=" + each.toString() + " desc=" + each.getDetails()); - return true; - } - } - return false; - } - - - private abstract static class Handler { - private final String myDetails; - - protected Handler() { - myDetails = StringUtil.getShortName(getClass().getName()); - } - - protected Handler(String details) { - myDetails = details; - } - - public abstract boolean process(Throwable e, StackTraceElement[] stack); - - public boolean isActual() { - return true; - } - - public String getDetails() { - return myDetails; - } - - @Override - public String toString() { - String className = getClass().getName(); - String name = className.substring(className.lastIndexOf("$") + 1); - if (name.startsWith("Sun_")) { - name = name.substring("Sun_".length()); - return "http://bugs.sun.com/view_bug.do?bug_id=" + name; - } - return super.toString(); - } - } - - @SuppressWarnings("UnusedDeclaration") - private static class Sun_6857057 extends Handler { - Sun_6857057() { - super("text editor component - sync between model and view while dnd operations"); - } - - @Override - public boolean process(Throwable e, StackTraceElement[] stack) { - if (e instanceof ArrayIndexOutOfBoundsException && stack.length > 5) { - return stack[0].getClassName().equals("sun.font.FontDesignMetrics") - && stack[0].getMethodName().equals("charsWidth") - && stack[5].getClassName().equals("javax.swing.text.CompositeView") - && stack[5].getMethodName().equals("viewToModel"); - } - return false; - } - } - - @SuppressWarnings("UnusedDeclaration") - private static class Sun_6785663 extends Handler { - Sun_6785663() { - super("Nimbus L&F problem -- update style"); - } - - @Override - public boolean process(Throwable e, StackTraceElement[] stack) { - if (e instanceof ClassCastException && stack.length > 1) { - return stack[0].getClassName().equals("javax.swing.plaf.synth.SynthButtonUI") - && stack[0].getMethodName().equals("updateStyle"); - } - return false; - } - } - - @SuppressWarnings("UnusedDeclaration") - private static class Apple_ExceptionOnChangingMonitors extends Handler { - Apple_ExceptionOnChangingMonitors() { } - - @Override - public boolean isActual() { - return SystemInfo.isMac; - } - - @Override - public boolean process(Throwable e, StackTraceElement[] stack) { - if (e instanceof ArrayIndexOutOfBoundsException && stack.length > 1) { - return stack[0].getClassName().equals("apple.awt.CWindow") - && stack[0].getMethodName().equals("displayChanged"); - } - - return false; - } - - @Override - public String toString() { - return "http://www.jetbrains.net/devnet/thread/278896"; - } - } - - @SuppressWarnings("UnusedDeclaration") - private static class Apple_CAccessible_NPE extends Handler { - Apple_CAccessible_NPE() { - super("apple.awt.CAccessible.getAccessibleContext(CAccessible.java:74)"); - } - - @Override - public boolean isActual() { - return SystemInfo.isMac; - } - - @Override - public boolean process(Throwable e, StackTraceElement[] stack) { - if (e instanceof NullPointerException && stack.length > 1) { - return SwingCleanuper.isCAccessible(stack[0].getClassName()) && stack[0].getMethodName().equals("getAccessibleContext"); - } - return false; - } - } - - @SuppressWarnings("UnusedDeclaration") - private static class HeadlessGraphicsEnvironmentUnderWindows extends Handler { - HeadlessGraphicsEnvironmentUnderWindows() { - super("HeadlessGraphicsEnvironment cannot be cast to Win32GraphicsEnvironment"); - } - - @Override - public boolean process(Throwable e, StackTraceElement[] stack) { - // http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6607186 - if (e instanceof ClassCastException && stack.length > 1 && e.getMessage() != null) { - return e.getMessage().equals("sun.java2d.HeadlessGraphicsEnvironment cannot be cast to sun.awt.Win32GraphicsEnvironment"); - } - return false; - } - } -}