Browse Source

REPORT-68127 【专题】jdk11的设计器用bat脚本启动失败,exe启动正常

【问题原因】
Reflect.on方法会抛出异常,需要主动catch

【改动思路】
无

【review建议】
new-design
Starryi 3 years ago
parent
commit
bcf191fadb
  1. 21
      designer-base/src/main/java/com/fr/design/startup/Install4jStartupNotificationProvider.java

21
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) {
}
});
}
}

Loading…
Cancel
Save