From bcf191fadb93968c98279c7d084ee298adfed1d5 Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 24 Mar 2022 15:11:02 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-68127=20=E3=80=90=E4=B8=93=E9=A2=98?= =?UTF-8?q?=E3=80=91jdk11=E7=9A=84=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=94=A8bat?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E5=90=AF=E5=8A=A8=E5=A4=B1=E8=B4=A5=EF=BC=8C?= =?UTF-8?q?exe=E5=90=AF=E5=8A=A8=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 Reflect.on方法会抛出异常,需要主动catch 【改动思路】 无 【review建议】 --- .../Install4jStartupNotificationProvider.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/startup/Install4jStartupNotificationProvider.java b/designer-base/src/main/java/com/fr/design/startup/Install4jStartupNotificationProvider.java index 5402032f94..b239698897 100644 --- a/designer-base/src/main/java/com/fr/design/startup/Install4jStartupNotificationProvider.java +++ b/designer-base/src/main/java/com/fr/design/startup/Install4jStartupNotificationProvider.java @@ -22,14 +22,22 @@ public class Install4jStartupNotificationProvider implements FineStartupNotifica @Override public void registerStartupListener(Listener listener) { - Class StartupNotificationListenerClass = Reflect.on("com.install4j.api.launcher.StartupNotification$Listener").type(); + Class StartupNotificationListenerClass = null; + try { + StartupNotificationListenerClass = Reflect.on("com.install4j.api.launcher.StartupNotification$Listener").type(); + } catch (Exception ignored) { + } + if (StartupNotificationListenerClass == null) { return; } ListenerHandler mHandler = new ListenerHandler(listener); Object listenerCallbackInstance = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { StartupNotificationListenerClass }, mHandler); - Reflect.on("com.install4j.api.launcher.StartupNotification").call("registerStartupListener", listenerCallbackInstance); + try { + Reflect.on("com.install4j.api.launcher.StartupNotification").call("registerStartupListener", listenerCallbackInstance); + } catch (Exception ignored) { + } } private static class ListenerHandler implements InvocationHandler { @@ -48,4 +56,13 @@ public class Install4jStartupNotificationProvider implements FineStartupNotifica return null; } } + + public static void main(String[] args) { + Install4jStartupNotificationProvider.getInstance().registerStartupListener(new Listener() { + @Override + public void startupPerformed(String parameters) { + + } + }); + } }