SettingsDialog

Two things that could be improved:

  1. It’s swallowing exceptions without a comment, in many cases masking bugs in the caller. Most should be logged with at least WARNING level.
    Affected funtions are setImage(String), safeSetIconImages(List), and getURL(String) (which should be moved close to its single call site to make clear that it’s just a helper function for that constructor).

  2. safeSetIconImage(List) takes great care to run under Java 1.5. However, other parts of JME won’t compile on 1.5 anyway. So that reflection stuff could be replaced by straightforward method calls (I think).

Didn’t make a patch because I’m not 100% sure about the logging levels to use, or about whether I missed something about the reflection stuff.
IOW I’ll do the patch once I have feedback that encourages this.

I’m the last one to make changes to the settings dialogue so if you want to post a patch I can take a look at it. No promises beyond looking though.

JME (the core libraries) are entirely 1.5 compatible afaik.

Warning seems like a good logging level for eaten exceptions.

Core does a lot of @Override on interfaces, which was introduced in 1.6 AFAIK.

Here’s the patch for logging exceptions:

[java]Index: src/desktop/com/jme3/app/SettingsDialog.java

— src/desktop/com/jme3/app/SettingsDialog.java (Revision 10499)
+++ src/desktop/com/jme3/app/SettingsDialog.java (Arbeitskopie)
@@ -258,9 +258,9 @@
try {
URL file = new URL(“file:” + image);
setImage(file);

  •        // We can safely ignore the exception - it just means that the user
    
  •        // gave us a bogus file
       } catch (MalformedURLException e) {
    
  •        logger.log(Level.WARNING,
    
  •            "Couldn't read from file '" + image + "'", e);
       }
    
    }

@@ -503,7 +503,8 @@
Method setIconImages = getClass().getMethod(“setIconImages”, List.class);
setIconImages.invoke(this, icons);
} catch (Exception e) {

  •        return;
    
  •        logger.log(Level.WARNING,
    
  •            "Error setting icon images", e);
       }
    
    }

@@ -697,6 +698,8 @@
try {
url = new URL(“file:” + file);
} catch (MalformedURLException e) {

  •        logger.log(Level.WARNING,
    
  •            "Invalid file name '" + file + "'", e);
       }
       return url;
    
    }[/java]
@toolforger said: Core does a lot of @Override on interfaces, which was introduced in 1.6 AFAIK.

…but will still RUN on 1.5. You need 1.6 to compile it.

Pretty sure JME is still setup to run on 1.5.

Logging added to those exceptions - will be in next nightly.

@zarch Ah okay, I didn’t consider cross-compiling Java 1.6 sources for 1.5.
Then of course the reflection stuff needs to stay in.