353192 Better warning for classes of wrong type

This commit is contained in:
Greg Wilkins 2011-08-29 14:38:38 +10:00
parent 39d0d4fee9
commit 904a0026e1
1 changed files with 4 additions and 1 deletions

View File

@ -310,7 +310,10 @@ public class XmlConfiguration
// Check the class of the object
Class<?> oClass = (Class<?>)nodeClass(_config);
if (oClass != null && !oClass.isInstance(obj))
throw new IllegalArgumentException("Object is not of type " + oClass);
{
String loaders = (oClass.getClassLoader()==obj.getClass().getClassLoader())?"":"Object Class and type Class are from different loaders.";
throw new IllegalArgumentException("Object of class '"+obj.getClass().getCanonicalName()+"' is not of type '" + oClass.getCanonicalName()+"'. "+loaders);
}
configure(obj,_config,0);
return obj;
}