Details
-
Bug
-
Resolution: Unresolved
-
P4
-
22
-
None
Description
Elements.overrides does not check that the overrider method is a member of the class or interface from where that method presumably overrides the overridee.
Although the intent is clear, the spec does not say what happens when a non-member is passed:
@param type the class or interface of which the first method is a member
An exception, the `false` result, or a note in the specification would seem to be in order. Consider this surprising result. Suppose:
public class S { public void m() { } }
public class T1 extends S { public void m() { } }
public class T2 extends S { public void m() { } }
Then (pseudocode):
Elements.overrides(/* overrider */ T2::m, /* overridee */ S::m, /* from */ T3) == true
Although the intent is clear, the spec does not say what happens when a non-member is passed:
@param type the class or interface of which the first method is a member
An exception, the `false` result, or a note in the specification would seem to be in order. Consider this surprising result. Suppose:
public class S { public void m() { } }
public class T1 extends S { public void m() { } }
public class T2 extends S { public void m() { } }
Then (pseudocode):
Elements.overrides(/* overrider */ T2::m, /* overridee */ S::m, /* from */ T3) == true