提交 4857164a 编写于 作者: K kohsuke

Added extra type checking to detect problems like...

Added extra type checking to detect problems like http://www.nabble.com/Creating-a-new-parameter-Type-%3A-Masked-Parameter-td24786554.html early on.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@20440 71c3de6d-444a-0410-be80-ed276b4c234a
上级 f69abee0
......@@ -225,6 +225,18 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
if(!t.isAssignableFrom(clazz))
throw new AssertionError("Outer class "+clazz+" of "+getClass()+" is not assignable to "+t+". Perhaps wrong outer class?");
}
// detect a type error. this Descriptor is supposed to be returned from getDescriptor(), so make sure its type match up.
// this prevents a bug like http://www.nabble.com/Creating-a-new-parameter-Type-%3A-Masked-Parameter-td24786554.html
try {
Method getd = clazz.getMethod("getDescriptor");
if(!getd.getReturnType().isAssignableFrom(getClass())) {
throw new AssertionError(getClass()+" must be assignable to "+getd.getReturnType());
}
} catch (NoSuchMethodException e) {
throw new AssertionError(getClass()+" is missing getDescriptor method.");
}
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册