Browse Source

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

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

【改动思路】
无

【review建议】
bugfix/11.0
Starryi 3 years ago
parent
commit
71cd9c679e
  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 @Override
public void registerStartupListener(Listener listener) { 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) { if (StartupNotificationListenerClass == null) {
return; return;
} }
ListenerHandler mHandler = new ListenerHandler(listener); ListenerHandler mHandler = new ListenerHandler(listener);
Object listenerCallbackInstance = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { StartupNotificationListenerClass }, mHandler); 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 { private static class ListenerHandler implements InvocationHandler {
@ -48,4 +56,13 @@ public class Install4jStartupNotificationProvider implements FineStartupNotifica
return null; return null;
} }
} }
public static void main(String[] args) {
Install4jStartupNotificationProvider.getInstance().registerStartupListener(new Listener() {
@Override
public void startupPerformed(String parameters) {
}
});
}
} }

Loading…
Cancel
Save