Fix my idiot attempt to fix this warning

My fix for the unchecked warning in AppleImage.java was completely dumb
and I had no idea what I was doing.  My understanding of how this works
is now greatly improved and the bug I introduced in 292afd2 is fixed.
This commit is contained in:
T. Joseph Carter 2017-11-13 09:23:05 -08:00
parent 43796815bf
commit c74e9ad3bd
1 changed files with 4 additions and 4 deletions

View File

@ -49,8 +49,7 @@ public abstract class AppleImage {
public static AppleImage create(int width, int height) {
String[] classes = {
"ImageIoImage", "SunJpegImage", "SwtImage" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Class<?> constructorArgType = AppleImage.class;
Class<?>[] constructorArgClasses = new Class[] { AppleImage.class };
Class[] constructorArgClasses = new Class[] { int.class, int.class };
Object[] constructorArgs = new Object[] {
new Integer(width), new Integer(height) };
for (int i=0; i<classes.length; i++) {
@ -58,8 +57,9 @@ public abstract class AppleImage {
Class<?> appleImageClass = Class.forName(
"com.webcodepro.applecommander.storage.filters.imagehandlers." //$NON-NLS-1$
+ classes[i]);
Constructor constructor =
constructorArgType.getConstructor(constructorArgClasses);
Constructor<?> constructor =
appleImageClass.getConstructor(constructorArgClasses);
AppleImage appleImage = (AppleImage)
constructor.newInstance(constructorArgs);
return appleImage;