Index: /trunk/src/gnu/getopt/Getopt.java
===================================================================
--- /trunk/src/gnu/getopt/Getopt.java	(revision 13646)
+++ /trunk/src/gnu/getopt/Getopt.java	(revision 13647)
@@ -657,4 +657,5 @@
   // strictly follow the POSIX standard.  This replaces the "POSIXLY_CORRECT"
   // environment variable in the C version
+  try {
   if (System.getProperty("gnu.posixly_correct", null) == null)
     posixly_correct = false;
@@ -665,4 +666,7 @@
                              //                      Locale.US);
     }
+  } catch (SecurityException e) {
+    System.err.println(e.getMessage());
+  }
 
   // Determine how to handle the ordering of options and non-options
Index: /trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/Main.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/Main.java	(revision 13647)
@@ -165,5 +165,9 @@
             asynchronousRunnableTasks().forEach(service::submit);
             asynchronousCallableTasks().forEach(service::submit);
-            service.shutdown();
+            try {
+                service.shutdown();
+            } catch (SecurityException e) {
+                Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown executor service", e);
+            }
         } catch (InterruptedException | ExecutionException ex) {
             throw new JosmRuntimeException(ex);
Index: /trunk/src/org/openstreetmap/josm/actions/AboutAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/AboutAction.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/actions/AboutAction.java	(revision 13647)
@@ -34,4 +34,5 @@
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.Shortcut;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -89,5 +90,5 @@
                 "<p>" + tr("Last change at {0}", version.getTime()) + "</p>" +
                 "<p style='font-size:50%'></p>" +
-                "<p>" + tr("Java Version {0}", System.getProperty("java.version")) + "</p>" +
+                "<p>" + tr("Java Version {0}", Utils.getSystemProperty("java.version")) + "</p>" +
                 "<p style='font-size:50%'></p>" +
                 "</html>");
Index: /trunk/src/org/openstreetmap/josm/actions/JosmAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/JosmAction.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/actions/JosmAction.java	(revision 13647)
@@ -36,4 +36,5 @@
 import org.openstreetmap.josm.tools.Destroyable;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.ImageResource;
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.Shortcut;
@@ -81,6 +82,10 @@
             String toolbarId, boolean installAdapters) {
         super(name);
-        if (icon != null)
-            icon.getResource().attachImageIcon(this, true);
+        if (icon != null) {
+            ImageResource resource = icon.getResource();
+            if (resource != null) {
+                resource.attachImageIcon(this, true);
+            }
+        }
         setHelpId();
         sc = shortcut;
@@ -119,5 +124,5 @@
     public JosmAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean registerInToolbar,
             String toolbarId, boolean installAdapters) {
-        this(name, iconName == null ? null : new ImageProvider(iconName), tooltip, shortcut, registerInToolbar,
+        this(name, iconName == null ? null : new ImageProvider(iconName).setOptional(true), tooltip, shortcut, registerInToolbar,
                 toolbarId == null ? iconName : toolbarId, installAdapters);
     }
Index: /trunk/src/org/openstreetmap/josm/actions/RestartAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/RestartAction.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/actions/RestartAction.java	(revision 13647)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
 import java.awt.event.ActionEvent;
@@ -71,5 +72,5 @@
      */
     public static boolean isRestartSupported() {
-        return System.getProperty("sun.java.command") != null;
+        return getSystemProperty("sun.java.command") != null;
     }
 
@@ -82,5 +83,5 @@
         // it is executed by a start script that can handle restart.
         // Request for restart is indicated by exit code 9.
-        String scriptRestart = System.getProperty("josm.restart");
+        String scriptRestart = getSystemProperty("josm.restart");
         if ("true".equals(scriptRestart)) {
             MainApplication.exitJosm(true, 9, SaveLayersDialog.Reason.RESTART);
@@ -90,5 +91,5 @@
         final List<String> cmd;
         // special handling for OSX .app package
-        if (Main.isPlatformOsx() && System.getProperty("java.library.path").contains("/JOSM.app/Contents/MacOS")) {
+        if (Main.isPlatformOsx() && getSystemProperty("java.library.path").contains("/JOSM.app/Contents/MacOS")) {
             cmd = getAppleCommands();
         } else {
@@ -134,7 +135,7 @@
         // Determine webstart JNLP file. Use jnlpx.origFilenameArg instead of jnlp.application.href,
         // because only this one is present when run from j2plauncher.exe (see #10795)
-        final String jnlp = System.getProperty("jnlpx.origFilenameArg");
+        final String jnlp = getSystemProperty("jnlpx.origFilenameArg");
         // program main and program arguments (be careful a sun property. might not be supported by all JVM)
-        final String javaCommand = System.getProperty("sun.java.command");
+        final String javaCommand = getSystemProperty("sun.java.command");
         if (javaCommand == null) {
             throw new IOException("Unable to retrieve sun.java.command property");
@@ -160,5 +161,5 @@
                 // else it's a .class, add the classpath and mainClass
                 cmd.add("-cp");
-                cmd.add('"' + System.getProperty("java.class.path") + '"');
+                cmd.add('"' + getSystemProperty("java.class.path") + '"');
                 cmd.add(mainCommand[0].replace("jdk.plugin/", "")); // Main class appears to be invalid on Java WebStart 9
             }
@@ -174,5 +175,5 @@
 
     private static String getJavaRuntime() throws IOException {
-        final String java = System.getProperty("java.home") + File.separator + "bin" + File.separator +
+        final String java = getSystemProperty("java.home") + File.separator + "bin" + File.separator +
                 (Main.isPlatformWindows() ? "java.exe" : "java");
         if (!new File(java).isFile()) {
Index: /trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/actions/ShowStatusReportAction.java	(revision 13647)
@@ -4,4 +4,6 @@
 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.Utils.getSystemEnv;
+import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
 import java.awt.Dimension;
@@ -84,5 +86,5 @@
     public static String getReportHeader() {
         StringBuilder text = new StringBuilder(256);
-        String runtimeVersion = System.getProperty("java.runtime.version");
+        String runtimeVersion = getSystemProperty("java.runtime.version");
         text.append(Version.getInstance().getReleaseAttributes())
             .append("\nIdentification: ").append(Version.getInstance().getAgentString());
@@ -98,7 +100,7 @@
             .append(Runtime.getRuntime().freeMemory()/1024/1024)
             .append(" MB allocated, but free)\nJava version: ")
-            .append(runtimeVersion != null ? runtimeVersion : System.getProperty("java.version")).append(", ")
-            .append(System.getProperty("java.vendor")).append(", ")
-            .append(System.getProperty("java.vm.name"))
+            .append(runtimeVersion != null ? runtimeVersion : getSystemProperty("java.version")).append(", ")
+            .append(getSystemProperty("java.vendor")).append(", ")
+            .append(getSystemProperty("java.vm.name"))
             .append("\nScreen: ");
         if (!GraphicsEnvironment.isHeadless()) {
@@ -227,7 +229,7 @@
      */
     private static String paramCleanup(String param) {
-        final String envJavaHome = System.getenv("JAVA_HOME");
+        final String envJavaHome = getSystemEnv("JAVA_HOME");
         final String envJavaHomeAlt = Main.isPlatformWindows() ? "%JAVA_HOME%" : "${JAVA_HOME}";
-        final String propJavaHome = System.getProperty("java.home");
+        final String propJavaHome = getSystemProperty("java.home");
         final String propJavaHomeAlt = "<java.home>";
         final String prefDir = Config.getDirs().getPreferencesDirectory(false).toString();
@@ -237,7 +239,7 @@
         final String userCacheDir = Config.getDirs().getCacheDirectory(false).toString();
         final String userCacheDirAlt = "<josm.cache>";
-        final String userHomeDir = System.getProperty("user.home");
+        final String userHomeDir = getSystemProperty("user.home");
         final String userHomeDirAlt = Main.isPlatformWindows() ? "%UserProfile%" : "${HOME}";
-        final String userName = System.getProperty("user.name");
+        final String userName = getSystemProperty("user.name");
         final String userNameAlt = "<user.name>";
 
@@ -250,5 +252,5 @@
         val = paramReplace(val, userCacheDir, userCacheDirAlt);
         val = paramReplace(val, userHomeDir, userHomeDirAlt);
-        if (userName.length() >= 3) {
+        if (userName != null && userName.length() >= 3) {
             val = paramReplace(val, userName, userNameAlt);
         }
Index: /trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 13647)
@@ -4,4 +4,6 @@
 import static org.openstreetmap.josm.tools.I18n.marktr;
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.Utils.getSystemEnv;
+import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
 import java.io.File;
@@ -218,5 +220,5 @@
      */
     public String getJOSMDirectoryBaseName() {
-        String name = System.getProperty("josm.dir.name");
+        String name = getSystemProperty("josm.dir.name");
         if (name != null)
             return name;
@@ -343,12 +345,12 @@
         addPossibleResourceDir(locations, dirs.getPreferencesDirectory(false).getPath());
         addPossibleResourceDir(locations, dirs.getUserDataDirectory(false).getPath());
-        addPossibleResourceDir(locations, System.getenv("JOSM_RESOURCES"));
-        addPossibleResourceDir(locations, System.getProperty("josm.resources"));
+        addPossibleResourceDir(locations, getSystemEnv("JOSM_RESOURCES"));
+        addPossibleResourceDir(locations, getSystemProperty("josm.resources"));
         if (Main.isPlatformWindows()) {
-            String appdata = System.getenv("APPDATA");
-            if (appdata != null && System.getenv("ALLUSERSPROFILE") != null
+            String appdata = getSystemEnv("APPDATA");
+            if (appdata != null && getSystemEnv("ALLUSERSPROFILE") != null
                     && appdata.lastIndexOf(File.separator) != -1) {
                 appdata = appdata.substring(appdata.lastIndexOf(File.separator));
-                locations.add(new File(new File(System.getenv("ALLUSERSPROFILE"),
+                locations.add(new File(new File(getSystemEnv("ALLUSERSPROFILE"),
                         appdata), "JOSM").getPath());
             }
@@ -456,4 +458,6 @@
                 new PrintWriter(new File(prefFile + "_tmp"), StandardCharsets.UTF_8.name()), false, defaults)) {
             writer.write(settings);
+        } catch (SecurityException e) {
+            throw new IOException(e);
         }
 
@@ -686,5 +690,11 @@
                     save();
                 } catch (IOException e) {
-                    Logging.log(Logging.LEVEL_WARN, tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()), e);
+                    File file = getPreferenceFile();
+                    try {
+                        file = file.getAbsoluteFile();
+                    } catch (SecurityException ex) {
+                        Logging.trace(ex);
+                    }
+                    Logging.log(Logging.LEVEL_WARN, tr("Failed to persist preferences to ''{0}''", file), e);
                 }
             }
Index: /trunk/src/org/openstreetmap/josm/data/StructUtils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/StructUtils.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/data/StructUtils.java	(revision 13647)
@@ -160,6 +160,6 @@
                 continue;
             }
-            Utils.setObjectsAccessible(f);
             try {
+                Utils.setObjectsAccessible(f);
                 Object fieldValue = f.get(struct);
                 Object defaultFieldValue = f.get(structPrototype);
@@ -176,5 +176,5 @@
                     }
                 }
-            } catch (IllegalAccessException ex) {
+            } catch (IllegalAccessException | SecurityException ex) {
                 throw new JosmRuntimeException(ex);
             }
Index: /trunk/src/org/openstreetmap/josm/data/Version.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/Version.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/data/Version.java	(revision 13647)
@@ -13,4 +13,5 @@
 import org.openstreetmap.josm.tools.LanguageInfo;
 import org.openstreetmap.josm.tools.Logging;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -198,5 +199,5 @@
      */
     public String getFullAgentString() {
-        return getAgentString() + " Java/"+System.getProperty("java.version");
+        return getAgentString() + " Java/"+Utils.getSystemProperty("java.version");
     }
 }
Index: /trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java	(revision 13647)
@@ -62,36 +62,40 @@
         // http://westsworld.dk/blog/2008/01/jcs-and-performance/
         jcsLog = Logger.getLogger("org.apache.commons.jcs");
-        jcsLog.setLevel(Level.INFO);
-        jcsLog.setUseParentHandlers(false);
-        // we need a separate handler from Main's, as we downgrade LEVEL.INFO to DEBUG level
-        Arrays.stream(jcsLog.getHandlers()).forEach(jcsLog::removeHandler);
-        jcsLog.addHandler(new Handler() {
-            final SimpleFormatter formatter = new SimpleFormatter();
-
-            @Override
-            public void publish(LogRecord record) {
-                String msg = formatter.formatMessage(record);
-                if (record.getLevel().intValue() >= Level.SEVERE.intValue()) {
-                    Logging.error(msg);
-                } else if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
-                    Logging.warn(msg);
-                    // downgrade INFO level to debug, as JCS is too verbose at INFO level
-                } else if (record.getLevel().intValue() >= Level.INFO.intValue()) {
-                    Logging.debug(msg);
-                } else {
-                    Logging.trace(msg);
-                }
-            }
-
-            @Override
-            public void flush() {
-                // nothing to be done on flush
-            }
-
-            @Override
-            public void close() {
-                // nothing to be done on close
-            }
-        });
+        try {
+            jcsLog.setLevel(Level.INFO);
+            jcsLog.setUseParentHandlers(false);
+            // we need a separate handler from Main's, as we downgrade LEVEL.INFO to DEBUG level
+            Arrays.stream(jcsLog.getHandlers()).forEach(jcsLog::removeHandler);
+            jcsLog.addHandler(new Handler() {
+                final SimpleFormatter formatter = new SimpleFormatter();
+
+                @Override
+                public void publish(LogRecord record) {
+                    String msg = formatter.formatMessage(record);
+                    if (record.getLevel().intValue() >= Level.SEVERE.intValue()) {
+                        Logging.error(msg);
+                    } else if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
+                        Logging.warn(msg);
+                        // downgrade INFO level to debug, as JCS is too verbose at INFO level
+                    } else if (record.getLevel().intValue() >= Level.INFO.intValue()) {
+                        Logging.debug(msg);
+                    } else {
+                        Logging.trace(msg);
+                    }
+                }
+
+                @Override
+                public void flush() {
+                    // nothing to be done on flush
+                }
+
+                @Override
+                public void close() {
+                    // nothing to be done on close
+                }
+            });
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to configure JCS logs", e);
+        }
     }
 
@@ -101,5 +105,5 @@
 
     @SuppressWarnings("resource")
-    private static void initialize()  {
+    private static void initialize() {
         File cacheDir = new File(Config.getDirs().getCacheDirectory(true), "jcs");
 
@@ -124,5 +128,5 @@
         Properties props = new Properties();
         // these are default common to all cache regions
-        // use of auxiliary cache and sizing of the caches is done with giving proper geCache(...) params
+        // use of auxiliary cache and sizing of the caches is done with giving proper getCache(...) params
         // CHECKSTYLE.OFF: SingleSpaceSeparator
         props.setProperty("jcs.default.cacheattributes",                      CompositeCacheAttributes.class.getCanonicalName());
Index: /trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java	(revision 13647)
@@ -48,5 +48,5 @@
                     Map.class);
         } catch (NoSuchMethodException | SecurityException e) {
-            Logging.warn(e);
+            Logging.log(Logging.LEVEL_WARN, "Unable to initialize cache tile loader factory", e);
             throw new IllegalArgumentException(e);
         }
@@ -58,5 +58,5 @@
             defPath = new File(Config.getDirs().getCacheDirectory(true), "tiles").getAbsolutePath();
         } catch (SecurityException e) {
-            Logging.warn(e);
+            Logging.log(Logging.LEVEL_WARN, "Unable to get tile cache directory", e);
         }
         return new StringProperty("imagery.generic.loader.cachedir", defPath);
Index: /trunk/src/org/openstreetmap/josm/data/preferences/JosmBaseDirectories.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/preferences/JosmBaseDirectories.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/data/preferences/JosmBaseDirectories.java	(revision 13647)
@@ -3,4 +3,5 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
 import java.io.File;
@@ -27,4 +28,8 @@
     }
 
+    /**
+     * Returns the unique instance.
+     * @return the unique instance
+     */
     public static JosmBaseDirectories getInstance() {
         return InstanceHolder.INSTANCE;
@@ -49,10 +54,9 @@
     public File getPreferencesDirectory(boolean createIfMissing) {
         if (preferencesDir == null) {
-            String path;
-            path = System.getProperty("josm.pref");
+            String path = getSystemProperty("josm.pref");
             if (path != null) {
                 preferencesDir = new File(path).getAbsoluteFile();
             } else {
-                path = System.getProperty("josm.home");
+                path = getSystemProperty("josm.home");
                 if (path != null) {
                     preferencesDir = new File(path).getAbsoluteFile();
@@ -62,12 +66,16 @@
             }
         }
-        if (createIfMissing && !preferencesDir.exists() && !preferencesDir.mkdirs()) {
-            Logging.warn(tr("Failed to create missing preferences directory: {0}", preferencesDir.getAbsoluteFile()));
-            JOptionPane.showMessageDialog(
-                    Main.parent,
-                    tr("<html>Failed to create missing preferences directory: {0}</html>", preferencesDir.getAbsoluteFile()),
-                    tr("Error"),
-                    JOptionPane.ERROR_MESSAGE
-            );
+        try {
+            if (createIfMissing && !preferencesDir.exists() && !preferencesDir.mkdirs()) {
+                Logging.warn(tr("Failed to create missing preferences directory: {0}", preferencesDir.getAbsoluteFile()));
+                JOptionPane.showMessageDialog(
+                        Main.parent,
+                        tr("<html>Failed to create missing preferences directory: {0}</html>", preferencesDir.getAbsoluteFile()),
+                        tr("Error"),
+                        JOptionPane.ERROR_MESSAGE
+                );
+            }
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to check if preferences dir must be created", e);
         }
         return preferencesDir;
@@ -77,10 +85,9 @@
     public File getUserDataDirectory(boolean createIfMissing) {
         if (userdataDir == null) {
-            String path;
-            path = System.getProperty("josm.userdata");
+            String path = getSystemProperty("josm.userdata");
             if (path != null) {
                 userdataDir = new File(path).getAbsoluteFile();
             } else {
-                path = System.getProperty("josm.home");
+                path = getSystemProperty("josm.home");
                 if (path != null) {
                     userdataDir = new File(path).getAbsoluteFile();
@@ -90,12 +97,16 @@
             }
         }
-        if (createIfMissing && !userdataDir.exists() && !userdataDir.mkdirs()) {
-            Logging.warn(tr("Failed to create missing user data directory: {0}", userdataDir.getAbsoluteFile()));
-            JOptionPane.showMessageDialog(
-                    Main.parent,
-                    tr("<html>Failed to create missing user data directory: {0}</html>", userdataDir.getAbsoluteFile()),
-                    tr("Error"),
-                    JOptionPane.ERROR_MESSAGE
-            );
+        try {
+            if (createIfMissing && !userdataDir.exists() && !userdataDir.mkdirs()) {
+                Logging.warn(tr("Failed to create missing user data directory: {0}", userdataDir.getAbsoluteFile()));
+                JOptionPane.showMessageDialog(
+                        Main.parent,
+                        tr("<html>Failed to create missing user data directory: {0}</html>", userdataDir.getAbsoluteFile()),
+                        tr("Error"),
+                        JOptionPane.ERROR_MESSAGE
+                );
+            }
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to check if user data dir must be created", e);
         }
         return userdataDir;
@@ -105,9 +116,9 @@
     public File getCacheDirectory(boolean createIfMissing) {
         if (cacheDir == null) {
-            String path = System.getProperty("josm.cache");
+            String path = getSystemProperty("josm.cache");
             if (path != null) {
                 cacheDir = new File(path).getAbsoluteFile();
             } else {
-                path = System.getProperty("josm.home");
+                path = getSystemProperty("josm.home");
                 if (path != null) {
                     cacheDir = new File(path, "cache");
@@ -122,12 +133,16 @@
             }
         }
-        if (createIfMissing && !cacheDir.exists() && !cacheDir.mkdirs()) {
-            Logging.warn(tr("Failed to create missing cache directory: {0}", cacheDir.getAbsoluteFile()));
-            JOptionPane.showMessageDialog(
-                    Main.parent,
-                    tr("<html>Failed to create missing cache directory: {0}</html>", cacheDir.getAbsoluteFile()),
-                    tr("Error"),
-                    JOptionPane.ERROR_MESSAGE
-            );
+        try {
+            if (createIfMissing && !cacheDir.exists() && !cacheDir.mkdirs()) {
+                Logging.warn(tr("Failed to create missing cache directory: {0}", cacheDir.getAbsoluteFile()));
+                JOptionPane.showMessageDialog(
+                        Main.parent,
+                        tr("<html>Failed to create missing cache directory: {0}</html>", cacheDir.getAbsoluteFile()),
+                        tr("Error"),
+                        JOptionPane.ERROR_MESSAGE
+                );
+            }
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to check if cache dir must be created", e);
         }
         return cacheDir;
Index: /trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Proj4DirGridShiftFileSource.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Proj4DirGridShiftFileSource.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Proj4DirGridShiftFileSource.java	(revision 13647)
@@ -14,4 +14,5 @@
 import org.openstreetmap.josm.tools.Platform;
 import org.openstreetmap.josm.tools.PlatformVisitor;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -51,5 +52,5 @@
         // If not, search into PROJ_LIB directory
         if (grid == null) {
-            String projLib = System.getProperty("PROJ_LIB");
+            String projLib = Utils.getSystemProperty("PROJ_LIB");
             if (projLib != null && !projLib.isEmpty()) {
                 File dir = new File(projLib);
Index: /trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java	(revision 13647)
@@ -66,4 +66,5 @@
 import org.openstreetmap.josm.gui.layer.ValidatorLayer;
 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
+import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.tools.AlphanumComparator;
@@ -176,5 +177,11 @@
      */
     public static String getValidatorDir() {
-        return new File(Config.getDirs().getUserDataDirectory(true), "validator").getAbsolutePath();
+        File dir = new File(Config.getDirs().getUserDataDirectory(true), "validator");
+        try {
+            return dir.getAbsolutePath();
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, null, e);
+            return dir.getPath();
+        }
     }
 
@@ -184,6 +191,10 @@
     private static void checkValidatorDir() {
         File pathDir = new File(getValidatorDir());
-        if (!pathDir.exists()) {
-            Utils.mkDirs(pathDir);
+        try {
+            if (!pathDir.exists()) {
+                Utils.mkDirs(pathDir);
+            }
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to check validator directory", e);
         }
     }
@@ -193,12 +204,16 @@
         if (ValidatorPrefHelper.PREF_USE_IGNORE.get()) {
             Path path = Paths.get(getValidatorDir()).resolve("ignorederrors");
-            if (path.toFile().exists()) {
-                try {
-                    ignoredErrors.addAll(Files.readAllLines(path, StandardCharsets.UTF_8));
-                } catch (final FileNotFoundException e) {
-                    Logging.debug(Logging.getErrorMessage(e));
-                } catch (final IOException e) {
-                    Logging.error(e);
+            try {
+                if (path.toFile().exists()) {
+                    try {
+                        ignoredErrors.addAll(Files.readAllLines(path, StandardCharsets.UTF_8));
+                    } catch (FileNotFoundException e) {
+                        Logging.debug(Logging.getErrorMessage(e));
+                    } catch (IOException e) {
+                        Logging.error(e);
+                    }
                 }
+            } catch (SecurityException e) {
+                Logging.log(Logging.LEVEL_ERROR, "Unable to load ignored errors", e);
             }
         }
@@ -385,9 +400,10 @@
                 }
             } catch (Exception e) { // NOPMD
-                Logging.error(e);
+                String message = tr("Error initializing test {0}:\n {1}", test.getClass().getSimpleName(), e);
+                Logging.error(message);
                 if (!GraphicsEnvironment.isHeadless()) {
-                    JOptionPane.showMessageDialog(Main.parent,
-                            tr("Error initializing test {0}:\n {1}", test.getClass().getSimpleName(), e),
-                            tr("Error"), JOptionPane.ERROR_MESSAGE);
+                    GuiHelper.runInEDT(() -> {
+                        JOptionPane.showMessageDialog(Main.parent, message, tr("Error"), JOptionPane.ERROR_MESSAGE);
+                    });
                 }
             }
Index: /trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/GettingStarted.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/GettingStarted.java	(revision 13647)
@@ -33,4 +33,5 @@
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.OpenBrowser;
+import org.openstreetmap.josm.tools.Utils;
 import org.openstreetmap.josm.tools.WikiReader;
 
@@ -85,5 +86,5 @@
 
         private final int myVersion = Version.getInstance().getVersion();
-        private final String myJava = System.getProperty("java.version");
+        private final String myJava = Utils.getSystemProperty("java.version");
         private final String myLang = LanguageInfo.getWikiLanguagePrefix();
 
Index: /trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 13647)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 import static org.openstreetmap.josm.tools.I18n.trn;
+import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
 import java.awt.BorderLayout;
@@ -357,6 +358,6 @@
             ed.setIcon(JOptionPane.WARNING_MESSAGE);
             StringBuilder content = new StringBuilder(tr("You are running version {0} of Java.",
-                    "<b>"+System.getProperty("java.version")+"</b>")).append("<br><br>");
-            if ("Sun Microsystems Inc.".equals(System.getProperty("java.vendor")) && !platform.isOpenJDK()) {
+                    "<b>"+getSystemProperty("java.version")+"</b>")).append("<br><br>");
+            if ("Sun Microsystems Inc.".equals(getSystemProperty("java.vendor")) && !platform.isOpenJDK()) {
                 content.append("<b>").append(tr("This version is no longer supported by {0} since {1} and is not recommended for use.",
                         "Oracle", eolDate)).append("</b><br><br>");
@@ -421,5 +422,5 @@
                     try {
                         OsmApi.getOsmApi().initialize(null, true);
-                    } catch (OsmTransferCanceledException | OsmApiInitializationException e) {
+                    } catch (OsmTransferCanceledException | OsmApiInitializationException | SecurityException e) {
                         Logging.warn(Logging.getErrorMessage(Utils.getRootCause(e)));
                     }
@@ -485,5 +486,9 @@
     protected void shutdown() {
         if (!GraphicsEnvironment.isHeadless()) {
-            worker.shutdown();
+            try {
+                worker.shutdown();
+            } catch (SecurityException e) {
+                Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown worker", e);
+            }
             JCSCacheManager.shutdown();
         }
@@ -498,5 +503,9 @@
         super.shutdown();
         if (!GraphicsEnvironment.isHeadless()) {
-            worker.shutdownNow();
+            try {
+                worker.shutdownNow();
+            } catch (SecurityException e) {
+                Logging.log(Logging.LEVEL_ERROR, "Unable to shutdown worker", e);
+            }
         }
     }
@@ -872,20 +881,28 @@
         I18n.set(language.orElse(null));
 
-        Policy.setPolicy(new Policy() {
-            // Permissions for plug-ins loaded when josm is started via webstart
-            private PermissionCollection pc;
-
-            {
-                pc = new Permissions();
-                pc.add(new AllPermission());
-            }
-
-            @Override
-            public PermissionCollection getPermissions(CodeSource codesource) {
-                return pc;
-            }
-        });
-
-        Thread.setDefaultUncaughtExceptionHandler(new BugReportExceptionHandler());
+        try {
+            Policy.setPolicy(new Policy() {
+                // Permissions for plug-ins loaded when josm is started via webstart
+                private PermissionCollection pc;
+
+                {
+                    pc = new Permissions();
+                    pc.add(new AllPermission());
+                }
+
+                @Override
+                public PermissionCollection getPermissions(CodeSource codesource) {
+                    return pc;
+                }
+            });
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to set permissions", e);
+        }
+
+        try {
+            Thread.setDefaultUncaughtExceptionHandler(new BugReportExceptionHandler());
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to set uncaught exception handler", e);
+        }
 
         // initialize the platform hook, and
@@ -917,5 +934,9 @@
         }
 
-        Main.pref.init(args.hasOption(Option.RESET_PREFERENCES));
+        try {
+            Main.pref.init(args.hasOption(Option.RESET_PREFERENCES));
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to initialize preferences", e);
+        }
 
         args.getPreferencesToSet().forEach(Main.pref::put);
@@ -979,7 +1000,22 @@
             Logging.warn(Logging.getErrorMessage(Utils.getRootCause(ex)));
         }
-        Authenticator.setDefault(DefaultAuthenticator.getInstance());
-        DefaultProxySelector proxySelector = new DefaultProxySelector(ProxySelector.getDefault());
-        ProxySelector.setDefault(proxySelector);
+        try {
+            Authenticator.setDefault(DefaultAuthenticator.getInstance());
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to set default authenticator", e);
+        }
+        DefaultProxySelector proxySelector = null;
+        try {
+            proxySelector = new DefaultProxySelector(ProxySelector.getDefault());
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to get default proxy selector", e);
+        }
+        try {
+            if (proxySelector != null) {
+                ProxySelector.setDefault(proxySelector);
+            }
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to set default proxy selector", e);
+        }
         OAuthAccessTokenHolder.getInstance().init(CredentialsManager.getInstance());
 
@@ -1093,5 +1129,5 @@
             } catch (ReflectiveOperationException | RuntimeException e) { // NOPMD
                 // Catch RuntimeException in order to catch InaccessibleObjectException, new in Java 9
-                Logging.warn(e);
+                Logging.log(Logging.LEVEL_WARN, null, e);
             }
         }
@@ -1120,5 +1156,5 @@
         // Workaround for JDK-8180379: crash on Windows 10 1703 with Windows L&F and java < 8u141 / 9+172
         // To remove during Java 9 migration
-        if (System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows 10") &&
+        if (getSystemProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows 10") &&
                 platform.getDefaultStyle().equals(LafPreference.LAF.get())) {
             try {
@@ -1135,4 +1171,6 @@
             } catch (NumberFormatException | ReflectiveOperationException | JosmRuntimeException e) {
                 Logging.error(e);
+            } catch (ExceptionInInitializerError e) {
+                Logging.log(Logging.LEVEL_ERROR, null, e);
             }
         }
@@ -1196,7 +1234,7 @@
         }
 
-        UIManager.put("OptionPane.okIcon", ImageProvider.get("ok"));
+        UIManager.put("OptionPane.okIcon", ImageProvider.getIfAvailable("ok"));
         UIManager.put("OptionPane.yesIcon", UIManager.get("OptionPane.okIcon"));
-        UIManager.put("OptionPane.cancelIcon", ImageProvider.get("cancel"));
+        UIManager.put("OptionPane.cancelIcon", ImageProvider.getIfAvailable("cancel"));
         UIManager.put("OptionPane.noIcon", UIManager.get("OptionPane.cancelIcon"));
         // Ensures caret color is the same than text foreground color, see #12257
@@ -1228,5 +1266,9 @@
 
         monitor.indeterminateSubTask(tr("Installing updated plugins"));
-        PluginHandler.installDownloadedPlugins(pluginsToLoad, true);
+        try {
+            PluginHandler.installDownloadedPlugins(pluginsToLoad, true);
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to install plugins", e);
+        }
 
         monitor.indeterminateSubTask(tr("Loading early plugins"));
@@ -1404,5 +1446,9 @@
                     }
                 }
-                autosaveTask.schedule();
+                try {
+                    autosaveTask.schedule();
+                } catch (SecurityException e) {
+                    Logging.log(Logging.LEVEL_ERROR, "Unable to schedule autosave!", e);
+                }
             }
         }
@@ -1426,5 +1472,6 @@
 
         private boolean handleProxyErrors() {
-            return handleNetworkOrProxyErrors(proxySelector.hasErrors(), tr("Proxy errors occurred"),
+            return proxySelector != null &&
+                handleNetworkOrProxyErrors(proxySelector.hasErrors(), tr("Proxy errors occurred"),
                     tr("JOSM tried to access the following resources:<br>" +
                             "{0}" +
Index: /trunk/src/org/openstreetmap/josm/gui/MainFrame.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MainFrame.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/MainFrame.java	(revision 13647)
@@ -17,4 +17,5 @@
 import java.util.List;
 
+import javax.swing.ImageIcon;
 import javax.swing.JFrame;
 import javax.swing.JPanel;
@@ -82,11 +83,11 @@
         geometry.applySafe(this);
         List<Image> l = new LinkedList<>();
-        l.add(ImageProvider.get("logo_16x16x32").getImage());
-        l.add(ImageProvider.get("logo_16x16x8").getImage());
-        l.add(ImageProvider.get("logo_32x32x32").getImage());
-        l.add(ImageProvider.get("logo_32x32x8").getImage());
-        l.add(ImageProvider.get("logo_48x48x32").getImage());
-        l.add(ImageProvider.get("logo_48x48x8").getImage());
-        l.add(ImageProvider.get("logo").getImage());
+        for (String file : new String[] {
+                "logo_16x16x32", "logo_16x16x8", "logo_32x32x32", "logo_32x32x8", "logo_48x48x32", "logo_48x48x8", "logo"}) {
+            ImageIcon img = ImageProvider.getIfAvailable(file);
+            if (img != null) {
+                l.add(img.getImage());
+            }
+        }
         setIconImages(l);
         addWindowListener(new ExitWindowAdapter());
Index: /trunk/src/org/openstreetmap/josm/gui/bugreport/BugReportDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/bugreport/BugReportDialog.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/bugreport/BugReportDialog.java	(revision 13647)
@@ -175,5 +175,5 @@
         panel.add(settings);
 
-        JButton sendBugReportButton = new JButton(tr("Report Bug"), ImageProvider.get("bug"));
+        JButton sendBugReportButton = new JButton(tr("Report Bug"), ImageProvider.getIfAvailable("bug"));
         sendBugReportButton.addActionListener(e -> sendBug());
         panel.add(sendBugReportButton, GBC.eol().insets(0, 0, 0, 0).anchor(GBC.SOUTHEAST));
Index: /trunk/src/org/openstreetmap/josm/gui/bugreport/JosmUpdatePanel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/bugreport/JosmUpdatePanel.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/bugreport/JosmUpdatePanel.java	(revision 13647)
@@ -92,5 +92,5 @@
         add(new JMultilineLabel(tr("Before you file a bug report make sure you have updated to the latest version of JOSM here:")), GBC.eol());
         add(new UrlLabel(Main.getJOSMWebsite(), 2), GBC.eop().insets(8, 0, 0, 0));
-        JButton updateButton = new JButton(tr("Update JOSM"), ImageProvider.get("download"));
+        JButton updateButton = new JButton(tr("Update JOSM"), ImageProvider.getIfAvailable("download"));
         updateButton.addActionListener(e -> openJosmUpdateSite());
         add(updateButton, GBC.eol().anchor(GBC.EAST));
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolutionUtil.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolutionUtil.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolutionUtil.java	(revision 13647)
@@ -21,4 +21,5 @@
 import org.openstreetmap.josm.data.osm.TagCollection;
 import org.openstreetmap.josm.spi.preferences.Config;
+import org.openstreetmap.josm.tools.JosmRuntimeException;
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.Pair;
@@ -137,5 +138,4 @@
             // make sure the empty value is in the tag set such that we can delete the tag
             // in the conflict dialog if necessary
-            //
             tc.add(new Tag(key, ""));
         }
@@ -149,5 +149,9 @@
      */
     public static void applyAutomaticTagConflictResolution(TagCollection tc) {
-        applyAutomaticTagConflictResolution(tc, getAutomaticTagConflictResolvers());
+        try {
+            applyAutomaticTagConflictResolution(tc, getAutomaticTagConflictResolvers());
+        } catch (JosmRuntimeException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to automatically resolve tag conflicts", e);
+        }
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/datatransfer/ClipboardUtils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/datatransfer/ClipboardUtils.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/datatransfer/ClipboardUtils.java	(revision 13647)
@@ -49,6 +49,6 @@
             try {
                 clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
-            } catch (HeadlessException e) {
-                Logging.warn("Headless. Using fake clipboard.", e);
+            } catch (HeadlessException | SecurityException e) {
+                Logging.warn("Using fake clipboard.", e);
                 clipboard = new Clipboard("fake");
             }
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java	(revision 13647)
@@ -450,5 +450,5 @@
             final StyleSource s = model.getRow(sel);
 
-            FileChooserManager fcm = new FileChooserManager(false, "mappaint.clone-style.lastDirectory", System.getProperty("user.home"));
+            FileChooserManager fcm = new FileChooserManager(false, "mappaint.clone-style.lastDirectory", Utils.getSystemProperty("user.home"));
             String suggestion = fcm.getInitialDirectory() + File.separator + s.getFileNamePart();
 
Index: /trunk/src/org/openstreetmap/josm/gui/io/RecentlyOpenedFilesMenu.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/io/RecentlyOpenedFilesMenu.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/io/RecentlyOpenedFilesMenu.java	(revision 13647)
@@ -34,5 +34,5 @@
         super(tr("Open Recent"));
         setToolTipText(tr("List of recently opened files"));
-        setIcon(ImageProvider.get("openrecent", ImageProvider.ImageSizes.MENU));
+        setIcon(new ImageProvider("openrecent").setOptional(true).setSize(ImageProvider.ImageSizes.MENU).get());
         putClientProperty("help", ht("/Action/OpenRecent"));
 
Index: /trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java	(revision 13647)
@@ -55,4 +55,5 @@
 import org.openstreetmap.josm.tools.GBC;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.ImageResource;
 import org.openstreetmap.josm.tools.InputMapUtils;
 import org.openstreetmap.josm.tools.Logging;
@@ -364,5 +365,8 @@
             putValue(NAME, tr("Cancel"));
             putValue(SHORT_DESCRIPTION, tr("Close this dialog and resume editing in JOSM"));
-            new ImageProvider("cancel").getResource().attachImageIcon(this, true);
+            ImageResource resource = new ImageProvider("cancel").setOptional(true).getResource();
+            if (resource != null) {
+                resource.attachImageIcon(this, true);
+            }
             InputMapUtils.addEscapeAction(getRootPane(), this);
         }
@@ -398,18 +402,24 @@
                     putValue(NAME, tr("Exit now!"));
                     putValue(SHORT_DESCRIPTION, tr("Exit JOSM without saving. Unsaved changes are lost."));
-                    new ImageProvider("exit").getResource().attachImageIcon(this, true);
+                    attachImageIcon(new ImageProvider("exit"));
                     break;
                 case RESTART:
                     putValue(NAME, tr("Restart now!"));
                     putValue(SHORT_DESCRIPTION, tr("Restart JOSM without saving. Unsaved changes are lost."));
-                    new ImageProvider("restart").getResource().attachImageIcon(this, true);
+                    attachImageIcon(new ImageProvider("restart"));
                     break;
                 case DELETE:
                     putValue(NAME, tr("Delete now!"));
                     putValue(SHORT_DESCRIPTION, tr("Delete layers without saving. Unsaved changes are lost."));
-                    new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true);
-                    break;
-            }
-
+                    attachImageIcon(new ImageProvider("dialogs", "delete"));
+                    break;
+            }
+        }
+
+        private void attachImageIcon(ImageProvider provider) {
+            ImageResource resource = provider.setOptional(true).getResource();
+            if (resource != null) {
+                resource.attachImageIcon(this, true);
+            }
         }
 
@@ -465,5 +475,5 @@
 
         Image getImage(String name, boolean disabled) {
-            ImageIcon img = new ImageProvider(name).setDisabled(disabled).get();
+            ImageIcon img = new ImageProvider(name).setDisabled(disabled).setOptional(true).get();
             return img != null ? img.getImage() : null;
         }
@@ -474,15 +484,15 @@
                     putValue(NAME, tr("Perform actions before exiting"));
                     putValue(SHORT_DESCRIPTION, tr("Exit JOSM with saving. Unsaved changes are uploaded and/or saved."));
-                    putValue(BASE_ICON, ImageProvider.get("exit"));
+                    putValue(BASE_ICON, ImageProvider.getIfAvailable("exit"));
                     break;
                 case RESTART:
                     putValue(NAME, tr("Perform actions before restarting"));
                     putValue(SHORT_DESCRIPTION, tr("Restart JOSM with saving. Unsaved changes are uploaded and/or saved."));
-                    putValue(BASE_ICON, ImageProvider.get("restart"));
+                    putValue(BASE_ICON, ImageProvider.getIfAvailable("restart"));
                     break;
                 case DELETE:
                     putValue(NAME, tr("Perform actions before deleting"));
                     putValue(SHORT_DESCRIPTION, tr("Save/Upload layers before deleting. Unsaved changes are not lost."));
-                    putValue(BASE_ICON, ImageProvider.get("dialogs", "delete"));
+                    putValue(BASE_ICON, ImageProvider.getIfAvailable("dialogs", "delete"));
                     break;
             }
@@ -491,5 +501,5 @@
 
         public void redrawIcon() {
-            Image base = ((ImageIcon) getValue(BASE_ICON)).getImage();
+            ImageIcon base = ((ImageIcon) getValue(BASE_ICON));
             BufferedImage newIco = new BufferedImage(ICON_SIZE*3, ICON_SIZE, BufferedImage.TYPE_4BYTE_ABGR);
             Graphics2D g = newIco.createGraphics();
@@ -497,5 +507,7 @@
             g.drawImage(model.getLayersToUpload().isEmpty() ? upldDis : upld, ICON_SIZE*0, 0, ICON_SIZE, ICON_SIZE, null);
             g.drawImage(model.getLayersToSave().isEmpty()   ? saveDis : save, ICON_SIZE*1, 0, ICON_SIZE, ICON_SIZE, null);
-            g.drawImage(base,                                                 ICON_SIZE*2, 0, ICON_SIZE, ICON_SIZE, null);
+            if (base != null) {
+                g.drawImage(base.getImage(),                                  ICON_SIZE*2, 0, ICON_SIZE, ICON_SIZE, null);
+            }
             // CHECKSTYLE.ON: SingleSpaceSeparator
             putValue(SMALL_ICON, new ImageIcon(newIco));
Index: /trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/AutosaveTask.java	(revision 13647)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.marktr;
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
 import java.io.BufferedReader;
@@ -383,27 +384,31 @@
     public List<File> getUnsavedLayersFiles() {
         List<File> result = new ArrayList<>();
-        File[] files = autosaveDir.listFiles((FileFilter)
-                pathname -> OsmImporter.FILE_FILTER.accept(pathname) || NoteImporter.FILE_FILTER.accept(pathname));
-        if (files == null)
-            return result;
-        for (File file: files) {
-            if (file.isFile()) {
-                boolean skipFile = false;
-                File pidFile = getPidFile(file);
-                if (pidFile.exists()) {
-                    try (BufferedReader reader = Files.newBufferedReader(pidFile.toPath(), StandardCharsets.UTF_8)) {
-                        String jvmId = reader.readLine();
-                        if (jvmId != null) {
-                            String pid = jvmId.split("@")[0];
-                            skipFile = jvmPerfDataFileExists(pid);
+        try {
+            File[] files = autosaveDir.listFiles((FileFilter)
+                    pathname -> OsmImporter.FILE_FILTER.accept(pathname) || NoteImporter.FILE_FILTER.accept(pathname));
+            if (files == null)
+                return result;
+            for (File file: files) {
+                if (file.isFile()) {
+                    boolean skipFile = false;
+                    File pidFile = getPidFile(file);
+                    if (pidFile.exists()) {
+                        try (BufferedReader reader = Files.newBufferedReader(pidFile.toPath(), StandardCharsets.UTF_8)) {
+                            String jvmId = reader.readLine();
+                            if (jvmId != null) {
+                                String pid = jvmId.split("@")[0];
+                                skipFile = jvmPerfDataFileExists(pid);
+                            }
+                        } catch (IOException | SecurityException t) {
+                            Logging.error(t);
                         }
-                    } catch (IOException | SecurityException t) {
-                        Logging.error(t);
                     }
-                }
-                if (!skipFile) {
-                    result.add(file);
-                }
-            }
+                    if (!skipFile) {
+                        result.add(file);
+                    }
+                }
+            }
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to list unsaved layers files", e);
         }
         return result;
@@ -411,5 +416,5 @@
 
     private static boolean jvmPerfDataFileExists(final String jvmId) {
-        File jvmDir = new File(System.getProperty("java.io.tmpdir") + File.separator + "hsperfdata_" + System.getProperty("user.name"));
+        File jvmDir = new File(getSystemProperty("java.io.tmpdir") + File.separator + "hsperfdata_" + getSystemProperty("user.name"));
         if (jvmDir.exists() && jvmDir.canRead()) {
             File[] files = jvmDir.listFiles((FileFilter) file -> file.getName().equals(jvmId) && file.isFile());
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java	(revision 13647)
@@ -223,5 +223,5 @@
             i = new ImageProvider(i).addOverlay(new ImageOverlay(new ImageProvider("warning-small"), 0.5, 0.5, 1, 1));
         }
-        return i;
+        return i.setOptional(true);
     }
 
Index: /trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java	(revision 13647)
@@ -173,5 +173,5 @@
             mi.setText(label);
             if (iconName != null && Config.getPref().getBoolean("text.popupmenu.useicons", true)) {
-                ImageIcon icon = ImageProvider.get(iconName, ImageProvider.ImageSizes.SMALLICON);
+                ImageIcon icon = new ImageProvider(iconName).setOptional(true).setSize(ImageProvider.ImageSizes.SMALLICON).get();
                 if (icon != null) {
                     mi.setIcon(icon);
Index: /trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 13647)
@@ -205,6 +205,6 @@
             output.write(this.data);
             output.flush();
-        } catch (IOException | InvalidPathException e) {
-            Logging.error(e);
+        } catch (IOException | InvalidPathException | SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to save data", e);
         }
     }
Index: /trunk/src/org/openstreetmap/josm/io/CachedFile.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/io/CachedFile.java	(revision 13647)
@@ -282,5 +282,9 @@
                 }
             } else {
-                cacheFile = checkLocal(url);
+                try {
+                    cacheFile = checkLocal(url);
+                } catch (SecurityException e) {
+                    throw new IOException(e);
+                }
             }
         } catch (MalformedURLException e) {
Index: /trunk/src/org/openstreetmap/josm/io/CertificateAmendment.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/CertificateAmendment.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/io/CertificateAmendment.java	(revision 13647)
@@ -192,7 +192,10 @@
             return;
         KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
-        Path cacertsPath = Paths.get(System.getProperty("java.home"), "lib", "security", "cacerts");
+        Path cacertsPath = Paths.get(Utils.getSystemProperty("java.home"), "lib", "security", "cacerts");
         try (InputStream is = Files.newInputStream(cacertsPath)) {
             keyStore.load(is, "changeit".toCharArray());
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to load keystore", e);
+            return;
         }
 
Index: /trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java	(revision 13647)
@@ -20,4 +20,5 @@
 import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.tools.Logging;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -59,5 +60,5 @@
     private static boolean jvmWillUseSystemProxies;
     static {
-        String v = System.getProperty("java.net.useSystemProxies");
+        String v = Utils.getSystemProperty("java.net.useSystemProxies");
         if (v != null && v.equals(Boolean.TRUE.toString())) {
             jvmWillUseSystemProxies = true;
Index: /trunk/src/org/openstreetmap/josm/io/OsmApi.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 13647)
@@ -252,4 +252,6 @@
                 // In that case, force update and try again
                 initializeCapabilities(cache.updateForceString());
+            } catch (SecurityException e) {
+                Logging.log(Logging.LEVEL_ERROR, "Unable to initialize OSM API", e);
             }
             if (capabilities == null) {
Index: /trunk/src/org/openstreetmap/josm/io/protocols/data/Handler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/protocols/data/Handler.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/io/protocols/data/Handler.java	(revision 13647)
@@ -30,6 +30,6 @@
         String pkg = pkgName.substring(0, pkgName.lastIndexOf('.'));
 
-        String protocolHandlers = System.getProperty("java.protocol.handler.pkgs", "");
-        if (!protocolHandlers.contains(pkg)) {
+        String protocolHandlers = Utils.getSystemProperty("java.protocol.handler.pkgs");
+        if (protocolHandlers != null && !protocolHandlers.contains(pkg)) {
             StringBuilder sb = new StringBuilder(protocolHandlers);
             if (sb.length() > 0) {
Index: /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java	(revision 13647)
@@ -965,5 +965,5 @@
             Set<String> plugins = new HashSet<>(Config.getPref().getList("plugins", new LinkedList<String>()));
             Logging.debug("Plugins list initialized to {0}", plugins);
-            String systemProp = System.getProperty("josm.plugins");
+            String systemProp = Utils.getSystemProperty("josm.plugins");
             if (systemProp != null) {
                 plugins.addAll(Arrays.asList(systemProp.split(",")));
Index: /trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java	(revision 13647)
@@ -138,6 +138,14 @@
         try {
             monitor.beginTask("");
-            scanSiteCacheFiles(monitor, pluginsDirectory);
-            scanPluginFiles(monitor, pluginsDirectory);
+            try {
+                scanSiteCacheFiles(monitor, pluginsDirectory);
+            } catch (SecurityException e) {
+                Logging.log(Logging.LEVEL_ERROR, "Unable to scan site cache files", e);
+            }
+            try {
+                scanPluginFiles(monitor, pluginsDirectory);
+            } catch (SecurityException e) {
+                Logging.log(Logging.LEVEL_ERROR, "Unable to scan plugin files", e);
+            }
         } finally {
             monitor.setCustomText("");
Index: /trunk/src/org/openstreetmap/josm/tools/HttpClient.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/HttpClient.java	(revision 13647)
@@ -70,5 +70,9 @@
 
     static {
-        CookieHandler.setDefault(new CookieManager());
+        try {
+            CookieHandler.setDefault(new CookieManager());
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to set default cookie handler", e);
+        }
     }
 
Index: /trunk/src/org/openstreetmap/josm/tools/I18n.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/I18n.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/I18n.java	(revision 13647)
@@ -351,5 +351,11 @@
         // FIXME: This must be updated after we switch to Java 9.
         // See https://docs.oracle.com/javase/9/docs/api/java/util/spi/LocaleServiceProvider.html
-        System.setProperty("java.locale.providers", "SPI,JRE,CLDR"); // Don't call Utils.updateSystemProperty to avoid spurious log at startup
+        try {
+            // Don't call Utils.updateSystemProperty to avoid spurious log at startup
+            System.setProperty("java.locale.providers", "SPI,JRE,CLDR");
+        } catch (SecurityException e) {
+            // Don't call Logging class, it may not be fully initialized yet
+            System.err.println("Unable to set locale providers: " + e.getMessage());
+        }
     }
 
Index: /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 13647)
@@ -256,6 +256,17 @@
 
     /** set of class loaders to take images from */
-    protected static final Set<ClassLoader> classLoaders = new HashSet<>(Arrays.asList(
-            ClassLoader.getSystemClassLoader(), ImageProvider.class.getClassLoader()));
+    protected static final Set<ClassLoader> classLoaders = new HashSet<>();
+    static {
+        try {
+            classLoaders.add(ClassLoader.getSystemClassLoader());
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to get system classloader", e);
+        }
+        try {
+            classLoaders.add(ImageProvider.class.getClassLoader());
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to get application classloader", e);
+        }
+    }
 
     /** directories in which images are searched */
@@ -1132,8 +1143,12 @@
         switch (type) {
         case SVG:
-            SVGDiagram svg;
+            SVGDiagram svg = null;
             synchronized (getSvgUniverse()) {
-                URI uri = getSvgUniverse().loadSVG(path);
-                svg = getSvgUniverse().getDiagram(uri);
+                try {
+                    URI uri = getSvgUniverse().loadSVG(path);
+                    svg = getSvgUniverse().getDiagram(uri);
+                } catch (SecurityException e) {
+                    Logging.log(Logging.LEVEL_WARN, "Unable to read SVG", e);
+                }
             }
             return svg == null ? null : new ImageResource(svg);
@@ -1149,5 +1164,6 @@
                 }
             } catch (IOException e) {
-                Logging.warn(e);
+                Logging.log(Logging.LEVEL_WARN, "Unable to read image", e);
+                Logging.debug(e);
             }
             return img == null ? null : new ImageResource(img);
@@ -1167,6 +1183,10 @@
         } else {
             File f = new File(path, name);
-            if ((path != null || f.isAbsolute()) && f.exists())
-                return Utils.fileToURL(f);
+            try {
+                if ((path != null || f.isAbsolute()) && f.exists())
+                    return Utils.fileToURL(f);
+            } catch (SecurityException e) {
+                Logging.log(Logging.LEVEL_ERROR, "Unable to access image", e);
+            }
         }
         return null;
@@ -1193,5 +1213,11 @@
         // Try user-data directory
         if (Config.getDirs() != null) {
-            String dir = new File(Config.getDirs().getUserDataDirectory(false), "images").getAbsolutePath();
+            File file = new File(Config.getDirs().getUserDataDirectory(false), "images");
+            String dir = file.getPath();
+            try {
+                dir = file.getAbsolutePath();
+            } catch (SecurityException e) {
+                Logging.debug(e);
+            }
             try {
                 u = getImageUrl(dir, imageName);
@@ -1730,6 +1756,6 @@
             }
             return bi;
-        } catch (IOException e) {
-            throw new IIOException("Can't get input stream from URL!", e);
+        } catch (SecurityException e) {
+            throw new IOException(e);
         }
     }
@@ -1942,8 +1968,12 @@
      */
     public static void shutdown(boolean now) {
-        if (now) {
-            IMAGE_FETCHER.shutdownNow();
-        } else {
-            IMAGE_FETCHER.shutdown();
+        try {
+            if (now) {
+                IMAGE_FETCHER.shutdownNow();
+            } else {
+                IMAGE_FETCHER.shutdown();
+            }
+        } catch (SecurityException ex) {
+            Logging.log(Logging.LEVEL_ERROR, "Failed to shutdown background image fetcher.", ex);
         }
     }
Index: /trunk/src/org/openstreetmap/josm/tools/Logging.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Logging.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/Logging.java	(revision 13647)
@@ -64,5 +64,9 @@
         ConsoleHandler stderr = new ConsoleHandler();
         LOGGER.addHandler(stderr);
-        stderr.setLevel(LEVEL_WARN);
+        try {
+            stderr.setLevel(LEVEL_WARN);
+        } catch (SecurityException e) {
+            System.err.println("Unable to set logging level: " + e.getMessage());
+        }
 
         ConsoleHandler stdout = new ConsoleHandler() {
@@ -81,5 +85,9 @@
         };
         LOGGER.addHandler(stdout);
-        stdout.setLevel(Level.ALL);
+        try {
+            stdout.setLevel(Level.ALL);
+        } catch (SecurityException e) {
+            System.err.println("Unable to set logging level: " + e.getMessage());
+        }
 
         LOGGER.addHandler(WARNINGS);
@@ -404,8 +412,4 @@
         private int messagesLogged;
 
-        RememberWarningHandler() {
-            setLevel(LEVEL_WARN);
-        }
-
         synchronized void clear() {
             messagesLogged = 0;
@@ -415,5 +419,6 @@
         @Override
         public synchronized void publish(LogRecord record) {
-            if (!isLoggable(record)) {
+            // We don't use setLevel + isLoggable to work in WebStart Sandbox mode
+            if (record.getLevel().intValue() < LEVEL_WARN.intValue()) {
                 return;
             }
Index: /trunk/src/org/openstreetmap/josm/tools/Platform.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Platform.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/Platform.java	(revision 13647)
@@ -54,5 +54,5 @@
     public static Platform determinePlatform() {
         if (platform == null) {
-            String os = System.getProperty("os.name");
+            String os = Utils.getSystemProperty("os.name");
             if (os == null) {
                 Logging.warn("Your operating system has no name, so I'm guessing its some kind of *nix.");
Index: /trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/PlatformHook.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/PlatformHook.java	(revision 13647)
@@ -268,5 +268,5 @@
      */
     default boolean isOpenJDK() {
-        String javaHome = System.getProperty("java.home");
+        String javaHome = Utils.getSystemProperty("java.home");
         return javaHome != null && javaHome.contains("openjdk");
     }
Index: /trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java	(revision 13647)
@@ -3,4 +3,5 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
 import java.awt.Desktop;
@@ -393,5 +394,5 @@
     @Override
     public String getOSDescription() {
-        return System.getProperty("os.name") + ' ' + System.getProperty("os.version");
+        return getSystemProperty("os.name") + ' ' + getSystemProperty("os.version");
     }
 
@@ -421,5 +422,5 @@
     @Override
     public File getDefaultCacheDirectory() {
-        return new File(System.getProperty("user.home")+"/Library/Caches",
+        return new File(getSystemProperty("user.home")+"/Library/Caches",
                 Main.pref.getJOSMDirectoryBaseName());
     }
@@ -427,5 +428,5 @@
     @Override
     public File getDefaultPrefDirectory() {
-        return new File(System.getProperty("user.home")+"/Library/Preferences",
+        return new File(getSystemProperty("user.home")+"/Library/Preferences",
                 Main.pref.getJOSMDirectoryBaseName());
     }
@@ -433,5 +434,5 @@
     @Override
     public File getDefaultUserDataDirectory() {
-        return new File(System.getProperty("user.home")+"/Library",
+        return new File(getSystemProperty("user.home")+"/Library",
                 Main.pref.getJOSMDirectoryBaseName());
     }
Index: /trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java	(revision 13647)
@@ -3,4 +3,6 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.Utils.getSystemEnv;
+import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 
 import java.awt.Desktop;
@@ -45,5 +47,5 @@
     public void preStartupHook() {
         // See #12022 - Disable GNOME ATK Java wrapper as it causes a lot of serious trouble
-        if ("org.GNOME.Accessibility.AtkWrapper".equals(System.getProperty("assistive_technologies"))) {
+        if ("org.GNOME.Accessibility.AtkWrapper".equals(getSystemProperty("assistive_technologies"))) {
             System.clearProperty("assistive_technologies");
         }
@@ -154,5 +156,5 @@
      */
     public String getJavaPackageDetails() {
-        String home = System.getProperty("java.home");
+        String home = getSystemProperty("java.home");
         if (home.contains("java-8-openjdk") || home.contains("java-1.8.0-openjdk")) {
             return getPackageDetails("openjdk-8-jre", "java-1_8_0-openjdk", "java-1.8.0-openjdk");
@@ -202,5 +204,5 @@
 
     private String buildOSDescription() {
-        String osName = System.getProperty("os.name");
+        String osName = getSystemProperty("os.name");
         if ("Linux".equalsIgnoreCase(osName)) {
             try {
@@ -339,5 +341,5 @@
     private static File getDotDirectory() {
         String dirName = "." + Main.pref.getJOSMDirectoryBaseName().toLowerCase(Locale.ENGLISH);
-        return new File(System.getProperty("user.home"), dirName);
+        return new File(getSystemProperty("user.home"), dirName);
     }
 
@@ -357,9 +359,9 @@
             return new File(getDotDirectory(), "cache");
         } else {
-            String xdgCacheDir = System.getenv("XDG_CACHE_HOME");
+            String xdgCacheDir = getSystemEnv("XDG_CACHE_HOME");
             if (xdgCacheDir != null && !xdgCacheDir.isEmpty()) {
                 return new File(xdgCacheDir, Main.pref.getJOSMDirectoryBaseName());
             } else {
-                return new File(System.getProperty("user.home") + File.separator +
+                return new File(getSystemProperty("user.home") + File.separator +
                         ".cache" + File.separator + Main.pref.getJOSMDirectoryBaseName());
             }
@@ -372,9 +374,9 @@
             return getDotDirectory();
         } else {
-            String xdgConfigDir = System.getenv("XDG_CONFIG_HOME");
+            String xdgConfigDir = getSystemEnv("XDG_CONFIG_HOME");
             if (xdgConfigDir != null && !xdgConfigDir.isEmpty()) {
                 return new File(xdgConfigDir, Main.pref.getJOSMDirectoryBaseName());
             } else {
-                return new File(System.getProperty("user.home") + File.separator +
+                return new File(getSystemProperty("user.home") + File.separator +
                         ".config" + File.separator + Main.pref.getJOSMDirectoryBaseName());
             }
@@ -387,9 +389,9 @@
             return getDotDirectory();
         } else {
-            String xdgDataDir = System.getenv("XDG_DATA_HOME");
+            String xdgDataDir = getSystemEnv("XDG_DATA_HOME");
             if (xdgDataDir != null && !xdgDataDir.isEmpty()) {
                 return new File(xdgDataDir, Main.pref.getJOSMDirectoryBaseName());
             } else {
-                return new File(System.getProperty("user.home") + File.separator +
+                return new File(getSystemProperty("user.home") + File.separator +
                         ".local" + File.separator + "share" + File.separator + Main.pref.getJOSMDirectoryBaseName());
             }
Index: /trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java	(revision 13647)
@@ -27,4 +27,6 @@
 import static java.awt.event.KeyEvent.VK_Z;
 import static org.openstreetmap.josm.tools.I18n.tr;
+import static org.openstreetmap.josm.tools.Utils.getSystemEnv;
+import static org.openstreetmap.josm.tools.Utils.getSystemProperty;
 import static org.openstreetmap.josm.tools.WinRegistry.HKEY_LOCAL_MACHINE;
 
@@ -270,6 +272,6 @@
     @Override
     public String getOSDescription() {
-        return Utils.strip(System.getProperty("os.name")) + ' ' +
-                ((System.getenv("ProgramFiles(x86)") == null) ? "32" : "64") + "-Bit";
+        return Utils.strip(getSystemProperty("os.name")) + ' ' +
+                ((getSystemEnv("ProgramFiles(x86)") == null) ? "32" : "64") + "-Bit";
     }
 
@@ -316,6 +318,7 @@
             }
             sb.append(" (").append(getCurrentBuild()).append(')');
-        } catch (ReflectiveOperationException | JosmRuntimeException e) {
-            Logging.error(e);
+        } catch (ReflectiveOperationException | JosmRuntimeException | NoClassDefFoundError e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to get Windows build number", e);
+            Logging.debug(e);
         }
         return sb.toString();
@@ -473,8 +476,8 @@
     @Override
     public File getDefaultCacheDirectory() {
-        String p = System.getenv("LOCALAPPDATA");
+        String p = getSystemEnv("LOCALAPPDATA");
         if (p == null || p.isEmpty()) {
             // Fallback for Windows OS earlier than Windows Vista, where the variable is not defined
-            p = System.getenv("APPDATA");
+            p = getSystemEnv("APPDATA");
         }
         return new File(new File(p, Main.pref.getJOSMDirectoryBaseName()), "cache");
@@ -483,5 +486,5 @@
     @Override
     public File getDefaultPrefDirectory() {
-        return new File(System.getenv("APPDATA"), Main.pref.getJOSMDirectoryBaseName());
+        return new File(getSystemEnv("APPDATA"), Main.pref.getJOSMDirectoryBaseName());
     }
 
@@ -524,8 +527,9 @@
             return;
 
-        String javaLibPath = System.getProperty("java.home") + File.separator + "lib";
+        String javaLibPath = getSystemProperty("java.home") + File.separator + "lib";
         Path templateFile = FileSystems.getDefault().getPath(javaLibPath, templateFileName);
-        if (!Files.isReadable(templateFile)) {
-            Logging.warn("extended font config - unable to find font config template file {0}", templateFile.toString());
+        String templatePath = templateFile.toString();
+        if (templatePath.startsWith("null") || !Files.isReadable(templateFile)) {
+            Logging.warn("extended font config - unable to find font config template file {0}", templatePath);
             return;
         }
@@ -612,5 +616,5 @@
         // Use more low-level method to find the installed fonts.
         List<String> fontsAvail = new ArrayList<>();
-        Path fontPath = FileSystems.getDefault().getPath(System.getenv("SYSTEMROOT"), "Fonts");
+        Path fontPath = FileSystems.getDefault().getPath(getSystemEnv("SYSTEMROOT"), "Fonts");
         try (DirectoryStream<Path> ds = Files.newDirectoryStream(fontPath)) {
             for (Path p : ds) {
Index: /trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java	(revision 13647)
@@ -25,8 +25,8 @@
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.DownloadPolicy;
-import org.openstreetmap.josm.data.osm.UploadPolicy;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
+import org.openstreetmap.josm.data.osm.UploadPolicy;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.io.IllegalDataException;
@@ -69,5 +69,9 @@
         if (optimizedWays.isEmpty()) {
             optimizedWays = computeOptimizedBoundaries();
-            saveOptimizedBoundaries(optimizedWays);
+            try {
+                saveOptimizedBoundaries(optimizedWays);
+            } catch (IOException | SecurityException e) {
+                Logging.log(Logging.LEVEL_ERROR, "Unable to save optimized boundaries", e);
+            }
         }
         rlCache = new GeoPropertyIndex<>(new DefaultGeoProperty(optimizedWays), 24);
@@ -154,5 +158,5 @@
     }
 
-    private static void saveOptimizedBoundaries(Collection<Way> optimizedWays) {
+    private static void saveOptimizedBoundaries(Collection<Way> optimizedWays) throws IOException {
         DataSet ds = optimizedWays.iterator().next().getDataSet();
         File file = new File(Config.getDirs().getCacheDirectory(true), "left-right-hand-traffic.osm");
@@ -163,6 +167,4 @@
             w.writeContent(ds);
             w.footer();
-        } catch (IOException ex) {
-            throw new JosmRuntimeException(ex);
         }
     }
@@ -172,5 +174,5 @@
                 Config.getDirs().getCacheDirectory(false).getPath(), "left-right-hand-traffic.osm"))) {
            return OsmReader.parseDataSet(is, null).getWays();
-        } catch (IllegalDataException | IOException | InvalidPathException ex) {
+        } catch (IllegalDataException | IOException | InvalidPathException | SecurityException ex) {
             Logging.trace(ex);
             return Collections.emptyList();
Index: /trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 13647)
@@ -887,5 +887,5 @@
      */
     public static File getJosmTempDir() {
-        String tmpDir = System.getProperty("java.io.tmpdir");
+        String tmpDir = getSystemProperty("java.io.tmpdir");
         if (tmpDir == null) {
             return null;
@@ -1268,4 +1268,39 @@
 
     /**
+     * Gets the value of the specified environment variable.
+     * An environment variable is a system-dependent external named value.
+     * @param name name the name of the environment variable
+     * @return the string value of the variable;
+     *         {@code null} if the variable is not defined in the system environment or if a security exception occurs.
+     * @see System#getenv(String)
+     * @since 13647
+     */
+    public static String getSystemEnv(String name) {
+        try {
+            return System.getenv(name);
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to get system env", e);
+            return null;
+        }
+    }
+
+    /**
+     * Gets the system property indicated by the specified key.
+     * @param key the name of the system property.
+     * @return the string value of the system property;
+     *         {@code null} if there is no property with that key or if a security exception occurs.
+     * @see System#getProperty(String)
+     * @since 13647
+     */
+    public static String getSystemProperty(String key) {
+        try {
+            return System.getProperty(key);
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to get system property", e);
+            return null;
+        }
+    }
+
+    /**
      * Updates a given system property.
      * @param key The property key
@@ -1276,13 +1311,18 @@
     public static String updateSystemProperty(String key, String value) {
         if (value != null) {
-            String old = System.setProperty(key, value);
-            if (Logging.isDebugEnabled() && !value.equals(old)) {
-                if (!key.toLowerCase(Locale.ENGLISH).contains("password")) {
-                    Logging.debug("System property '" + key + "' set to '" + value + "'. Old value was '" + old + '\'');
-                } else {
-                    Logging.debug("System property '" + key + "' changed.");
+            try {
+                String old = System.setProperty(key, value);
+                if (Logging.isDebugEnabled() && !value.equals(old)) {
+                    if (!key.toLowerCase(Locale.ENGLISH).contains("password")) {
+                        Logging.debug("System property '" + key + "' set to '" + value + "'. Old value was '" + old + '\'');
+                    } else {
+                        Logging.debug("System property '" + key + "' changed.");
+                    }
                 }
-            }
-            return old;
+                return old;
+            } catch (SecurityException e) {
+                // Don't call Logging class, it may not be fully initialized yet
+                System.err.println("Unable to update system property: " + e.getMessage());
+            }
         }
         return null;
@@ -1592,5 +1632,5 @@
      */
     public static int getJavaVersion() {
-        String version = System.getProperty("java.version");
+        String version = getSystemProperty("java.version");
         if (version.startsWith("1.")) {
             version = version.substring(2);
@@ -1613,5 +1653,5 @@
      */
     public static int getJavaUpdate() {
-        String version = System.getProperty("java.version");
+        String version = getSystemProperty("java.version");
         if (version.startsWith("1.")) {
             version = version.substring(2);
@@ -1643,5 +1683,5 @@
      */
     public static int getJavaBuild() {
-        String version = System.getProperty("java.runtime.version");
+        String version = getSystemProperty("java.runtime.version");
         int bPos = version.indexOf('b');
         int pPos = version.indexOf('+');
@@ -1757,6 +1797,6 @@
         try {
             return new ScriptEngineManager(null).getEngineByName("JavaScript");
-        } catch (SecurityException e) {
-            Logging.error(e);
+        } catch (SecurityException | ExceptionInInitializerError e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to get JavaScript engine", e);
             return null;
         }
@@ -1789,5 +1829,5 @@
                             FileTime jarTime = Files.readAttributes(jarFile, BasicFileAttributes.class).lastModifiedTime();
                             // Copy it to temp directory (hopefully free of exclamation mark) if needed (missing or older jar)
-                            Path jarCopy = Paths.get(System.getProperty("java.io.tmpdir")).resolve(filename);
+                            Path jarCopy = Paths.get(getSystemProperty("java.io.tmpdir")).resolve(filename);
                             if (!jarCopy.toFile().exists() ||
                                     Files.readAttributes(jarCopy, BasicFileAttributes.class).lastModifiedTime().compareTo(jarTime) < 0) {
Index: /trunk/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java	(revision 13646)
+++ /trunk/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java	(revision 13647)
@@ -10,4 +10,5 @@
 import java.util.Collections;
 import java.util.ConcurrentModificationException;
+import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
@@ -40,8 +41,8 @@
 
     /**
-     * We capture all stack traces on exception creation. This allows us to trace synchonization problems better. We cannot be really sure what
-     * happened but we at least see which threads
-     */
-    private final transient Map<Thread, StackTraceElement[]> allStackTraces;
+     * We capture all stack traces on exception creation. This allows us to trace synchonization problems better.
+     * We cannot be really sure what happened but we at least see which threads
+     */
+    private final transient Map<Thread, StackTraceElement[]> allStackTraces = new HashMap<>();
     private final LinkedList<Section> sections = new LinkedList<>();
     private final transient Thread caughtOnThread;
@@ -55,5 +56,9 @@
         super(exception);
 
-        allStackTraces = Thread.getAllStackTraces();
+        try {
+            allStackTraces.putAll(Thread.getAllStackTraces());
+        } catch (SecurityException e) {
+            Logging.log(Logging.LEVEL_ERROR, "Unable to get thread stack traces", e);
+        }
         this.caughtOnThread = caughtOnThread;
     }
