diff --git a/src/com/webcodepro/applecommander/storage/filters/imagehandlers/AppleImage.java b/src/com/webcodepro/applecommander/storage/filters/imagehandlers/AppleImage.java index 236b982..09638e1 100644 --- a/src/com/webcodepro/applecommander/storage/filters/imagehandlers/AppleImage.java +++ b/src/com/webcodepro/applecommander/storage/filters/imagehandlers/AppleImage.java @@ -21,6 +21,7 @@ package com.webcodepro.applecommander.storage.filters.imagehandlers; import java.io.IOException; import java.io.OutputStream; +import java.lang.reflect.Constructor; /** * AppleImage is an abstract class that represents a generic interface @@ -42,20 +43,31 @@ public abstract class AppleImage { */ private String[] availableExtensions; /** - * Create a specific instance of AppleImage. + * Create a specific instance of AppleImage. This has been coded + * using Reflection to ease native compilation for the most part. */ public static AppleImage create(int width, int height) { - try { - return new ImageIoImage(width, height); - } catch (ClassNotFoundException ignored) { - } - try { - return new SunJpegImage(width, height); - } catch (ClassNotFoundException ignored) { - } - try { - return new SwtImage(width, height); - } catch (ClassNotFoundException ignored) { + String[] classes = { + "ImageIoImage", "SunJpegImage", "SwtImage" }; + Class[] constructorArgClasses = new Class[] { + int.class, int.class }; + Object[] constructorArgs = new Object[] { + new Integer(width), new Integer(height) }; + for (int i=0; i