Explicitly check the type of I2PSocketManager

This commit is contained in:
zab2
2013-06-28 14:56:55 +00:00
parent 552f91b6b8
commit f8648ff4c4

View File

@@ -180,7 +180,9 @@ public class I2PSocketManagerFactory {
I2PAppContext context = I2PAppContext.getGlobalContext();
String classname = opts.getProperty(PROP_MANAGER, DEFAULT_MANAGER);
try {
Class cls = Class.forName(classname);
Class<?> cls = Class.forName(classname);
if (!I2PSocketManager.class.isAssignableFrom(cls))
throw new IllegalArgumentException(classname + " is not an I2PSocketManager");
Constructor<I2PSocketManager> con = (Constructor<I2PSocketManager>)
cls.getConstructor(new Class[] {I2PAppContext.class, I2PSession.class, Properties.class, String.class});
I2PSocketManager mgr = con.newInstance(new Object[] {context, session, opts, name});