diff --git a/core/src/main/java/org/kohsuke/stapler/lang/FieldRef.java b/core/src/main/java/org/kohsuke/stapler/lang/FieldRef.java index 446b04d335..6b1a3ba3e7 100644 --- a/core/src/main/java/org/kohsuke/stapler/lang/FieldRef.java +++ b/core/src/main/java/org/kohsuke/stapler/lang/FieldRef.java @@ -50,6 +50,13 @@ public boolean keep(FieldRef m) { */ public abstract String getQualifiedName(); + /** + * Returns the {@code Class} object representing the class or interface + * that declares the executable represented by this object. + * @see java.lang.reflect.Member#getDeclaringClass() + */ + public abstract Class getDeclaringClass(); + /** * Gets the signature for this for use in lists * @@ -107,6 +114,11 @@ public String getSignature() { return String.join(" ", prefix, f.getDeclaringClass().getName(), getName()); } + @Override + public Class getDeclaringClass() { + return f.getDeclaringClass(); + } + @Override public String getQualifiedName() { return f.getDeclaringClass().getName()+"."+getName(); diff --git a/jelly/src/test/java/org/kohsuke/stapler/jelly/issue76/ProtectedClass.java b/jelly/src/test/java/org/kohsuke/stapler/jelly/issue76/ProtectedClass.java index b88e3b4fbc..12a05b558b 100644 --- a/jelly/src/test/java/org/kohsuke/stapler/jelly/issue76/ProtectedClass.java +++ b/jelly/src/test/java/org/kohsuke/stapler/jelly/issue76/ProtectedClass.java @@ -97,6 +97,11 @@ protected FieldRef getBase() { return f; } + @Override + public Class getDeclaringClass() { + return f.getDeclaringClass(); + } + @Override public String getSignature() { return f.getQualifiedName(); // doesn't really matter