提交 199dfed4 编写于 作者: K Kohsuke Kawaguchi

Allow instance methods for @Initializer and @Terminator

This simplifies typical usage of them.
上级 2579ceaf
......@@ -56,9 +56,6 @@ abstract class TaskMethodFinder<T extends Annotation> extends TaskBuilder {
for (Method e : Index.list(type, cl, Method.class)) {
if (filter(e)) continue; // already reported once
if (!Modifier.isStatic(e.getModifiers()))
throw new IOException(e+" is not a static method");
T i = e.getAnnotation(type);
if (i==null) continue; // stale index
......@@ -103,7 +100,10 @@ abstract class TaskMethodFinder<T extends Annotation> extends TaskBuilder {
Object[] args = new Object[pt.length];
for (int i=0; i<args.length; i++)
args[i] = lookUp(pt[i]);
e.invoke(null,args);
e.invoke(
Modifier.isStatic(e.getModifiers()) ? null : lookUp(e.getDeclaringClass()),
args);
} catch (IllegalAccessException x) {
throw (Error)new IllegalAccessError().initCause(x);
} catch (InvocationTargetException x) {
......@@ -149,7 +149,7 @@ abstract class TaskMethodFinder<T extends Annotation> extends TaskBuilder {
}
/**
* Static method that runs the initialization, that this task wraps.
* Method that runs the initialization, that this task wraps.
*/
public Method getMethod() {
return e;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册