I have a problem with part of GluonJ library: javassist.gluonj.util.Loader
I have this code:
Loader loader = new Loader(Class.class.getClassLoader(), new String[0]);
Class<?> sanselan1 = loader.loadClass("org.apache.sanselan.Sanselan");
// Read image.
Method getBI = sanselan1.getMethod("getBufferedImage", new Class[]{ File.class } );
BufferedImage image = (BufferedImage) getBI.invoke(null, new Object[]{ imageIn });
And this code work correctly!
But this code don't works:
Method setBI = sanselan1.getMethod(
"writeImage",
new Class[]{ BufferedImage.class, File.class, ImageFormat.class, Map.class }
);
setBI.invoke(null, new Object[]{ image, imageOut, ImageFormat.IMAGE_FORMAT_PNG, null });
I get an error:
java.lang.NoSuchMethodException: org.apache.sanselan.Sanselan.writeImage(java.awt.image.BufferedImage, java.io.File, org.apache.sanselan.ImageFormat, java.util.Map)
But if I using standart class loader:
Class<?> sanselan2 = Class.forName("org.apache.sanselan.Sanselan");
//...
Method setBI = sanselan2.getMethod(
"writeImage",
new Class[]{ BufferedImage.class, File.class, ImageFormat.class, Map.class }
);
setBI.invoke(null, new Object[]{ image, imageOut, ImageFormat.IMAGE_FORMAT_PNG, null });
Everithing works fine! It meanse, that org.apache.sanselan.Sanselan have method writeImage and I correctly called it.
But if I using javassist.gluonj.util.Loader I have an exception: NoSuchMethodException.
What is a problem?