فهرست منبع

use multi-catch to simplify code

Stephen Gold 4 سال پیش
والد
کامیت
6298283c2e
25فایلهای تغییر یافته به همراه107 افزوده شده و 301 حذف شده
  1. 3 8
      jme3-bullet/src/common/java/com/jme3/bullet/BulletAppState.java
  2. 3 7
      jme3-core/src/main/java/com/jme3/anim/tween/Tweens.java
  3. 1 3
      jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java
  4. 1 2
      jme3-core/src/main/java/com/jme3/export/SavableClassUtil.java
  5. 2 2
      jme3-core/src/main/java/com/jme3/renderer/opengl/GLTracer.java
  6. 2 4
      jme3-core/src/main/java/com/jme3/system/JmeSystem.java
  7. 5 10
      jme3-core/src/main/java/com/jme3/util/MaterialDebugAppState.java
  8. 10 16
      jme3-core/src/main/java/com/jme3/util/ReflectionAllocator.java
  9. 4 7
      jme3-core/src/test/java/com/jme3/scene/MPOTestUtils.java
  10. 7 7
      jme3-core/src/tools/java/jme3tools/optimize/TextureAtlas.java
  11. 4 6
      jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java
  12. 5 13
      jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java
  13. 4 11
      jme3-examples/src/main/java/jme3test/TestChooser.java
  14. 4 6
      jme3-examples/src/main/java/jme3test/awt/AppHarness.java
  15. 4 6
      jme3-examples/src/main/java/jme3test/awt/TestApplet.java
  16. 4 6
      jme3-examples/src/main/java/jme3test/awt/TestCanvas.java
  17. 1 3
      jme3-networking/src/main/java/com/jme3/network/message/SerializerRegistrationsMessage.java
  18. 4 6
      jme3-networking/src/main/java/com/jme3/network/service/rmi/MethodInfo.java
  19. 5 11
      jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/obj/FbxObjectFactory.java
  20. 1 5
      jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MeshLoader.java
  21. 1 5
      jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SceneLoader.java
  22. 1 5
      jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SceneMaterialLoader.java
  23. 1 6
      jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SkeletonLoader.java
  24. 28 140
      jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java
  25. 2 6
      jme3-plugins/src/xml/java/com/jme3/export/xml/XMLImporter.java

+ 3 - 8
jme3-bullet/src/common/java/com/jme3/bullet/BulletAppState.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2020 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -192,10 +192,7 @@ public class BulletAppState
         };
         try {
             return executor.submit(call).get();
-        } catch (InterruptedException ex) {
-            Logger.getLogger(BulletAppState.class.getName()).log(Level.SEVERE, null, ex);
-            return false;
-        } catch (ExecutionException ex) {
+        } catch (InterruptedException | ExecutionException ex) {
             Logger.getLogger(BulletAppState.class.getName()).log(Level.SEVERE, null, ex);
             return false;
         }
@@ -388,9 +385,7 @@ public class BulletAppState
             try {
                 physicsFuture.get();
                 physicsFuture = null;
-            } catch (InterruptedException ex) {
-                Logger.getLogger(BulletAppState.class.getName()).log(Level.SEVERE, null, ex);
-            } catch (ExecutionException ex) {
+            } catch (InterruptedException | ExecutionException ex) {
                 Logger.getLogger(BulletAppState.class.getName()).log(Level.SEVERE, null, ex);
             }
         }

+ 3 - 7
jme3-core/src/main/java/com/jme3/anim/tween/Tweens.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2020 jMonkeyEngine
+ * Copyright (c) 2015-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -469,9 +469,7 @@ public class Tweens {
         protected void doInterpolate(double t) {
             try {
                 method.invoke(target, args);
-            } catch (IllegalAccessException e) {
-                throw new RuntimeException("Error running method:" + method + " for object:" + target, e);
-            } catch (InvocationTargetException e) {
+            } catch (IllegalAccessException | InvocationTargetException e) {
                 throw new RuntimeException("Error running method:" + method + " for object:" + target, e);
             }
         }
@@ -600,9 +598,7 @@ public class Tweens {
                     args[tIndex] = t;
                 }
                 method.invoke(target, args);
-            } catch (IllegalAccessException e) {
-                throw new RuntimeException("Error running method:" + method + " for object:" + target, e);
-            } catch (InvocationTargetException e) {
+            } catch (IllegalAccessException | InvocationTargetException e) {
                 throw new RuntimeException("Error running method:" + method + " for object:" + target, e);
             }
         }

+ 1 - 3
jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java

@@ -148,9 +148,7 @@ public class DesktopAssetManager implements AssetManager {
         Class<? extends AssetLoader> clazz = null;
         try{
             clazz = (Class<? extends AssetLoader>) Class.forName(clsName);
-        }catch (ClassNotFoundException ex){
-            logger.log(Level.WARNING, "Failed to find loader: "+clsName, ex);
-        }catch (NoClassDefFoundError ex){
+        } catch (ClassNotFoundException | NoClassDefFoundError ex) {
             logger.log(Level.WARNING, "Failed to find loader: "+clsName, ex);
         }
         if (clazz != null){

+ 1 - 2
jme3-core/src/main/java/com/jme3/export/SavableClassUtil.java

@@ -212,8 +212,7 @@ public class SavableClassUtil {
                 }
                 try {
                     return (Savable) loadedClass.newInstance();
-                } catch (InstantiationException e) {
-                } catch (IllegalAccessException e) {
+                } catch (InstantiationException | IllegalAccessException e) {
                 }
             }
         }

+ 2 - 2
jme3-core/src/main/java/com/jme3/renderer/opengl/GLTracer.java

@@ -152,8 +152,8 @@ public final class GLTracer implements InvocationHandler {
                         int val = field.getInt(null);
                         String name = field.getName();
                         constMap.put(val, name);
-                    } catch (IllegalArgumentException ex) {
-                    } catch (IllegalAccessException ex) {
+                    } catch (IllegalArgumentException
+                            | IllegalAccessException ex) {
                     }
                 }
             }

+ 2 - 4
jme3-core/src/main/java/com/jme3/system/JmeSystem.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2019 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -212,9 +212,7 @@ public class JmeSystem {
                         }
                     }
                 }
-            } catch (InstantiationException ex) {
-                Logger.getLogger(JmeSystem.class.getName()).log(Level.SEVERE, "Failed to create JmeSystem delegate:\n{0}", ex);
-            } catch (IllegalAccessException ex) {
+            } catch (InstantiationException | IllegalAccessException ex) {
                 Logger.getLogger(JmeSystem.class.getName()).log(Level.SEVERE, "Failed to create JmeSystem delegate:\n{0}", ex);
             }
         }

+ 5 - 10
jme3-core/src/main/java/com/jme3/util/MaterialDebugAppState.java

@@ -349,9 +349,7 @@ public class MaterialDebugAppState extends AbstractAppState {
                         }
                     }
                 }
-            } catch (IllegalArgumentException ex) {
-                Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex);
-            } catch (IllegalAccessException ex) {
+            } catch (IllegalArgumentException | IllegalAccessException ex) {
                 Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex);
             }
 
@@ -388,13 +386,10 @@ public class MaterialDebugAppState extends AbstractAppState {
                     file = new File(url.getFile());
                     fileLastM = file.lastModified();
 
-                } catch (NoSuchFieldException ex) {
-                    Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex);
-                } catch (SecurityException ex) {
-                    Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex);
-                } catch (IllegalArgumentException ex) {
-                    Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex);
-                } catch (IllegalAccessException ex) {
+                } catch (NoSuchFieldException
+                        | SecurityException
+                        | IllegalArgumentException
+                        | IllegalAccessException ex) {
                     Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex);
                 }
             }

+ 10 - 16
jme3-core/src/main/java/com/jme3/util/ReflectionAllocator.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2020 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -64,8 +64,7 @@ public final class ReflectionAllocator implements BufferAllocator {
         Class<?> clazz = bb.getClass();
         try {
             freeMethod = clazz.getMethod("free");
-        } catch (NoSuchMethodException ex) {
-        } catch (SecurityException ex) {
+        } catch (NoSuchMethodException | SecurityException ex) {
         }
     }
 
@@ -74,12 +73,10 @@ public final class ReflectionAllocator implements BufferAllocator {
             Method method = Class.forName(className).getMethod(methodName);
             method.setAccessible(true);// according to the Java documentation, by default, a reflected object is not accessible
             return method;
-        } catch (NoSuchMethodException ex) {
-            return null; // the method was not found
-        } catch (SecurityException ex) {
-            return null; // setAccessible not allowed by security policy
-        } catch (ClassNotFoundException ex) {
-            return null; // the direct buffer implementation was not found
+        } catch (NoSuchMethodException // the method was not found
+                | SecurityException // setAccessible not allowed by security policy
+                | ClassNotFoundException ex) { // the direct buffer implementation was not found
+            return null;
         } catch (Throwable t) {
             if (t.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")) {
                 return null;// the class is in an unexported module
@@ -162,13 +159,10 @@ public final class ReflectionAllocator implements BufferAllocator {
                     }
                 }
             }
-        } catch (IllegalAccessException ex) {
-            Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE, "{0}", ex);
-        } catch (IllegalArgumentException ex) {
-            Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE, "{0}", ex);
-        } catch (InvocationTargetException ex) {
-            Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE, "{0}", ex);
-        } catch (SecurityException ex) {
+        } catch (IllegalAccessException
+                | IllegalArgumentException
+                | InvocationTargetException
+                | SecurityException ex) {
             Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE, "{0}", ex);
         }
     }

+ 4 - 7
jme3-core/src/test/java/com/jme3/scene/MPOTestUtils.java

@@ -102,13 +102,10 @@ public class MPOTestUtils {
             Field refreshFlagsField = Spatial.class.getDeclaredField("refreshFlags");
             refreshFlagsField.setAccessible(true);
             return (Integer) refreshFlagsField.get(scene);
-        } catch (NoSuchFieldException ex) {
-            throw new AssertionError(ex);
-        } catch (SecurityException ex) {
-            throw new AssertionError(ex);
-        } catch (IllegalArgumentException ex) {
-            throw new AssertionError(ex);
-        } catch (IllegalAccessException ex) {
+        } catch (NoSuchFieldException
+                | SecurityException
+                | IllegalArgumentException
+                | IllegalAccessException ex) {
             throw new AssertionError(ex);
         }
     }

+ 7 - 7
jme3-core/src/tools/java/jme3tools/optimize/TextureAtlas.java

@@ -359,13 +359,13 @@ public class TextureAtlas {
             Image newImage = new Image(format, source.getWidth(), source.getHeight(), BufferUtils.createByteBuffer(source.getWidth() * source.getHeight() * 4), null, ColorSpace.Linear);
             clazz.getMethod("convert", Image.class, Image.class).invoke(clazz.newInstance(), source, newImage);
             return newImage;
-        } catch (InstantiationException ex) {
-        } catch (IllegalAccessException ex) {
-        } catch (IllegalArgumentException ex) {
-        } catch (InvocationTargetException ex) {
-        } catch (NoSuchMethodException ex) {
-        } catch (SecurityException ex) {
-        } catch (ClassNotFoundException ex) {
+        } catch (InstantiationException
+                | IllegalAccessException
+                | IllegalArgumentException
+                | InvocationTargetException
+                | NoSuchMethodException
+                | SecurityException
+                | ClassNotFoundException ex) {
         }
         return null;
     }

+ 4 - 6
jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2020 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -105,11 +105,9 @@ public class AppletHarness extends Applet {
         try{
             Class clazz = Class.forName(appClass);
             app = (LegacyApplication) clazz.newInstance();
-        }catch (ClassNotFoundException ex){
-            ex.printStackTrace();
-        }catch (InstantiationException ex){
-            ex.printStackTrace();
-        }catch (IllegalAccessException ex){
+        } catch (ClassNotFoundException
+                | InstantiationException 
+                | IllegalAccessException ex) {
             ex.printStackTrace();
         }
 

+ 5 - 13
jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2020 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -209,9 +209,7 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
             }
 
             return (JmeContext) ctxClazz.newInstance();
-        } catch (InstantiationException ex) {
-            logger.log(Level.SEVERE, "Failed to create context", ex);
-        } catch (IllegalAccessException ex) {
+        } catch (InstantiationException | IllegalAccessException ex) {
             logger.log(Level.SEVERE, "Failed to create context", ex);
         } catch (ClassNotFoundException ex) {
             logger.log(Level.SEVERE, "CRITICAL ERROR: Context class is missing!\n"
@@ -239,9 +237,7 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
             }
 
             return (JmeContext) ctxClazz.newInstance();
-        } catch (InstantiationException ex) {
-            logger.log(Level.SEVERE, "Failed to create context", ex);
-        } catch (IllegalAccessException ex) {
+        } catch (InstantiationException | IllegalAccessException ex) {
             logger.log(Level.SEVERE, "Failed to create context", ex);
         } catch (ClassNotFoundException ex) {
             logger.log(Level.SEVERE, "CRITICAL ERROR: Context class is missing!\n"
@@ -257,9 +253,7 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
 
             Class ctxClazz = Class.forName(className);
             return (JmeContext) ctxClazz.newInstance();
-        } catch (InstantiationException ex) {
-            logger.log(Level.SEVERE, "Failed to create context", ex);
-        } catch (IllegalAccessException ex) {
+        } catch (InstantiationException | IllegalAccessException ex) {
             logger.log(Level.SEVERE, "Failed to create context", ex);
         } catch (ClassNotFoundException ex) {
             logger.log(Level.SEVERE, "CRITICAL ERROR: Context class is missing!", ex);
@@ -302,9 +296,7 @@ public class JmeDesktopSystem extends JmeSystemDelegate {
         } catch (ClassNotFoundException ex) {
             logger.log(Level.SEVERE, "CRITICAL ERROR: Audio implementation class "
                     + className + " is missing!\n", ex);
-        } catch (IllegalAccessException ex) {
-            logger.log(Level.SEVERE, "Failed to create context", ex);
-        } catch (InstantiationException ex) {
+        } catch (IllegalAccessException | InstantiationException ex) {
             logger.log(Level.SEVERE, "Failed to create context", ex);
         }
 

+ 4 - 11
jme3-examples/src/main/java/jme3test/TestChooser.java

@@ -180,17 +180,10 @@ public class TestChooser extends JDialog {
                 if (!getClass().equals(cls)) {
                     return cls;
                 }
-            } catch (NoClassDefFoundError e) {
-                // class has unresolved dependencies
-                return null;
-            } catch (ClassNotFoundException e) {
-                // class not in classpath
-                return null;
-            } catch (NoSuchMethodException e) {
-                // class does not have a main method
-                return null;
-            } catch (UnsupportedClassVersionError e){
-                // unsupported version
+            } catch (NoClassDefFoundError // class has unresolved dependencies
+                    | ClassNotFoundException // class not in classpath
+                    | NoSuchMethodException // class does not have a main method
+                    | UnsupportedClassVersionError e) { // unsupported version             
                 return null;
             }
         }

+ 4 - 6
jme3-examples/src/main/java/jme3test/awt/AppHarness.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2020 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -81,11 +81,9 @@ public class AppHarness extends Applet {
         try{
             Class clazz = Class.forName(appClass);
             app = (LegacyApplication) clazz.newInstance();
-        }catch (ClassNotFoundException ex){
-            ex.printStackTrace();
-        }catch (InstantiationException ex){
-            ex.printStackTrace();
-        }catch (IllegalAccessException ex){
+        }catch (ClassNotFoundException
+                | InstantiationException
+                | IllegalAccessException ex){
             ex.printStackTrace();
         }
 

+ 4 - 6
jme3-examples/src/main/java/jme3test/awt/TestApplet.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2020 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -64,11 +64,9 @@ public class TestApplet extends Applet {
         try{
             Class clazz = Class.forName(appClass);
             app = (LegacyApplication) clazz.newInstance();
-        }catch (ClassNotFoundException ex){
-            ex.printStackTrace();
-        }catch (InstantiationException ex){
-            ex.printStackTrace();
-        }catch (IllegalAccessException ex){
+        } catch (ClassNotFoundException
+                | InstantiationException
+                | IllegalAccessException ex){
             ex.printStackTrace();
         }
 

+ 4 - 6
jme3-examples/src/main/java/jme3test/awt/TestCanvas.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2020 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -211,11 +211,9 @@ public class TestCanvas {
         try{
             Class clazz = Class.forName(appClass);
             app = (LegacyApplication)clazz.newInstance();
-        }catch (ClassNotFoundException ex){
-            ex.printStackTrace();
-        }catch (InstantiationException ex){
-            ex.printStackTrace();
-        }catch (IllegalAccessException ex){
+        }catch (ClassNotFoundException
+                | InstantiationException
+                | IllegalAccessException ex){
             ex.printStackTrace();
         }
 

+ 1 - 3
jme3-networking/src/main/java/com/jme3/network/message/SerializerRegistrationsMessage.java

@@ -217,9 +217,7 @@ public class SerializerRegistrationsMessage extends AbstractMessage {
                 log.log(Level.FINE, "   result:{0}", result);                
             } catch( ClassNotFoundException e ) {
                 throw new RuntimeException( "Class not found attempting to register:" + this, e );
-            } catch( InstantiationException e ) {
-                throw new RuntimeException( "Error instantiating serializer registering:" + this, e );
-            } catch( IllegalAccessException e ) {
+            } catch( InstantiationException | IllegalAccessException e ) {
                 throw new RuntimeException( "Error instantiating serializer registering:" + this, e );
             }            
         }

+ 4 - 6
jme3-networking/src/main/java/com/jme3/network/service/rmi/MethodInfo.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 jMonkeyEngine
+ * Copyright (c) 2015-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -70,11 +70,9 @@ public final class MethodInfo {
     public Object invoke( Object target, Object... parms ) {
         try {
             return method.invoke(target, parms);
-        } catch (IllegalAccessException e) {
-            throw new RuntimeException("Error invoking:" + method + " on:" + target, e);
-        } catch (IllegalArgumentException e) {
-            throw new RuntimeException("Error invoking:" + method + " on:" + target, e);
-        } catch (InvocationTargetException e) {
+        } catch (IllegalAccessException
+                | IllegalArgumentException
+                | InvocationTargetException e) {
             throw new RuntimeException("Error invoking:" + method + " on:" + target, e);
         }
     }

+ 5 - 11
jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/obj/FbxObjectFactory.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2015 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -194,16 +194,10 @@ public final class FbxObjectFactory {
                                                     ") forgot to call super.fromElement() in their fromElement() implementation");
                 }
                 return obj;
-            } catch (InvocationTargetException ex) {
-                // Programmer error.
-                throw new IllegalStateException(ex);
-            } catch (NoSuchMethodException ex) {
-                // Programmer error.
-                throw new IllegalStateException(ex);
-            } catch (InstantiationException ex) {
-                // Programmer error.
-                throw new IllegalStateException(ex);
-            } catch (IllegalAccessException ex) {
+            } catch (InvocationTargetException
+                    | NoSuchMethodException
+                    | InstantiationException
+                    | IllegalAccessException ex) {
                 // Programmer error.
                 throw new IllegalStateException(ex);
             }

+ 1 - 5
jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/MeshLoader.java

@@ -887,11 +887,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
             }
 
             return compileModel();
-        } catch (SAXException ex) {
-            IOException ioEx = new IOException("Error while parsing Ogre3D mesh.xml");
-            ioEx.initCause(ex);
-            throw ioEx;
-        } catch (ParserConfigurationException ex) {
+        } catch (SAXException | ParserConfigurationException ex) {
             IOException ioEx = new IOException("Error while parsing Ogre3D mesh.xml");
             ioEx.initCause(ex);
             throw ioEx;

+ 1 - 5
jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SceneLoader.java

@@ -543,11 +543,7 @@ public class SceneLoader extends DefaultHandler implements AssetLoader {
             }
 
             return root;
-        } catch (SAXException ex) {
-            IOException ioEx = new IOException("Error while parsing Ogre3D dotScene");
-            ioEx.initCause(ex);
-            throw ioEx;
-        } catch (ParserConfigurationException ex) {
+        } catch (SAXException | ParserConfigurationException ex) {
             IOException ioEx = new IOException("Error while parsing Ogre3D dotScene");
             ioEx.initCause(ex);
             throw ioEx;

+ 1 - 5
jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SceneMaterialLoader.java

@@ -145,11 +145,7 @@ class SceneMaterialLoader extends DefaultHandler {
             }
             
             return materialList;
-        } catch (SAXException ex) {
-            IOException ioEx = new IOException("Error while parsing Ogre3D dotScene");
-            ioEx.initCause(ex);
-            throw ioEx;
-        } catch (ParserConfigurationException ex) {
+        } catch (SAXException | ParserConfigurationException ex) {
             IOException ioEx = new IOException("Error while parsing Ogre3D dotScene");
             ioEx.initCause(ex);
             throw ioEx;

+ 1 - 6
jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SkeletonLoader.java

@@ -277,12 +277,7 @@ public class SkeletonLoader extends DefaultHandler implements AssetLoader {
             armature = null;
             animClips = null;
             return data;
-        } catch (SAXException ex) {
-            IOException ioEx = new IOException("Error while parsing Ogre3D dotScene");
-            ioEx.initCause(ex);
-            fullReset();
-            throw ioEx;
-        } catch (ParserConfigurationException ex) {
+        } catch (SAXException | ParserConfigurationException ex) {
             IOException ioEx = new IOException("Error while parsing Ogre3D dotScene");
             ioEx.initCause(ex);
             fullReset();

+ 28 - 140
jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java

@@ -130,14 +130,10 @@ public class DOMInputCapsule implements InputCapsule {
         if (tmpString == null || tmpString.length() < 1) return defVal;
         try {
             return Byte.parseByte(tmpString);
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -170,14 +166,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -217,14 +209,10 @@ public class DOMInputCapsule implements InputCapsule {
             return byteArrays.toArray(new byte[0][]);
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -234,14 +222,10 @@ public class DOMInputCapsule implements InputCapsule {
         if (tmpString == null || tmpString.length() < 1) return defVal;
         try {
             return Integer.parseInt(tmpString);
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -273,14 +257,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -323,14 +303,10 @@ public class DOMInputCapsule implements InputCapsule {
             return intArrays.toArray(new int[0][]);
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -340,14 +316,10 @@ public class DOMInputCapsule implements InputCapsule {
         if (tmpString == null || tmpString.length() < 1) return defVal;
         try {
             return Float.parseFloat(tmpString);
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -412,14 +384,10 @@ public class DOMInputCapsule implements InputCapsule {
                 }
             }
             return tmp;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -429,14 +397,10 @@ public class DOMInputCapsule implements InputCapsule {
         if (tmpString == null || tmpString.length() < 1) return defVal;
         try {
             return Double.parseDouble(tmpString);
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -468,14 +432,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -514,14 +474,10 @@ public class DOMInputCapsule implements InputCapsule {
             return doubleArrays.toArray(new double[0][]);
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -531,14 +487,10 @@ public class DOMInputCapsule implements InputCapsule {
         if (tmpString == null || tmpString.length() < 1) return defVal;
         try {
             return Long.parseLong(tmpString);
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -570,14 +522,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -616,14 +564,10 @@ public class DOMInputCapsule implements InputCapsule {
             return longArrays.toArray(new long[0][]);
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -633,14 +577,10 @@ public class DOMInputCapsule implements InputCapsule {
         if (tmpString == null || tmpString.length() < 1) return defVal;
         try {
             return Short.parseShort(tmpString);
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -672,14 +612,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -719,14 +655,10 @@ public class DOMInputCapsule implements InputCapsule {
             return shortArrays.toArray(new short[0][]);
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -813,14 +745,10 @@ public class DOMInputCapsule implements InputCapsule {
             return booleanArrays.toArray(new boolean[0][]);
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -871,14 +799,10 @@ public class DOMInputCapsule implements InputCapsule {
             return strings.toArray(new String[0]);
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -917,14 +841,10 @@ public class DOMInputCapsule implements InputCapsule {
             return stringArrays.toArray(new String[0][]);
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -942,14 +862,10 @@ public class DOMInputCapsule implements InputCapsule {
                 }
             }
             return set;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -1175,14 +1091,10 @@ public class DOMInputCapsule implements InputCapsule {
             return savableArrayLists.toArray(new ArrayList[0]);
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -1249,14 +1161,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -1379,14 +1287,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -1413,14 +1317,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -1447,14 +1347,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -1481,14 +1377,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
     }
 
@@ -1518,14 +1410,10 @@ public class DOMInputCapsule implements InputCapsule {
             return tmp;
         } catch (IOException ioe) {
             throw ioe;
-        } catch (NumberFormatException nfe) {
+        } catch (NumberFormatException | DOMException nfe) {
             IOException io = new IOException(nfe.toString());
             io.initCause(nfe);
             throw io;
-        } catch (DOMException de) {
-            IOException io = new IOException(de.toString());
-            io.initCause(de);
-            throw io;
         }
         }
 

+ 2 - 6
jme3-plugins/src/xml/java/com/jme3/export/xml/XMLImporter.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2020 jMonkeyEngine
+ * Copyright (c) 2009-2021 jMonkeyEngine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -100,11 +100,7 @@ public class XMLImporter implements JmeImporter {
         try {
             domIn = new DOMInputCapsule(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f), this);
             return domIn.readSavable(null, null);
-        } catch (SAXException e) {
-            IOException ex = new IOException();
-            ex.initCause(e);
-            throw ex;
-        } catch (ParserConfigurationException e) {
+        } catch (SAXException | ParserConfigurationException e) {
             IOException ex = new IOException();
             ex.initCause(e);
             throw ex;