2
0

Better exception logging to avoid hiding class initialization exceptions.

This commit is contained in:
Maarten Billemont 2018-04-26 12:45:02 -04:00
parent dc19806e02
commit 71f1b3c130

View File

@ -19,7 +19,7 @@
package com.lyndir.masterpassword.gui; package com.lyndir.masterpassword.gui;
import com.google.common.base.Charsets; import com.google.common.base.*;
import com.google.common.io.*; import com.google.common.io.*;
import com.lyndir.lhunath.opal.system.logging.Logger; import com.lyndir.lhunath.opal.system.logging.Logger;
import com.lyndir.lhunath.opal.system.util.TypeUtils; import com.lyndir.lhunath.opal.system.util.TypeUtils;
@ -27,6 +27,7 @@ import com.lyndir.lhunath.opal.system.util.TypeUtils;
import com.lyndir.masterpassword.gui.view.PasswordFrame; import com.lyndir.masterpassword.gui.view.PasswordFrame;
import com.lyndir.masterpassword.gui.view.UnlockFrame; import com.lyndir.masterpassword.gui.view.UnlockFrame;
import java.io.*; import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import java.util.Enumeration; import java.util.Enumeration;
@ -48,17 +49,27 @@ public class GUI implements UnlockFrame.SignInCallback {
private PasswordFrame<?, ?> passwordFrame; private PasswordFrame<?, ?> passwordFrame;
public static void main(final String... args) { public static void main(final String... args) {
if (Config.get().checkForUpdates()) if (Config.get().checkForUpdates())
checkUpdate(); checkUpdate();
// Try and set the system look & feel, if available.
try { try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} }
catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException ignored) { catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException ignored) {
} }
TypeUtils.<GUI>newInstance( "com.lyndir.masterpassword.gui.platform.mac.AppleGUI" ).or( new GUI() ).open(); try {
// AppleGUI adds support for macOS features.
Optional<Class<GUI>> appleGUI = TypeUtils.loadClass( "com.lyndir.masterpassword.gui.platform.mac.AppleGUI" );
if (appleGUI.isPresent())
appleGUI.get().getConstructor().newInstance().open();
else // No special platform handling.
new GUI().open();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw logger.bug( e );
}
} }
private static void checkUpdate() { private static void checkUpdate() {