Runtime & concurrency
Reveal answer and reasoning
A discovery query needs a clear selection contract: public or nonpublic, instance or static, and declared-only or inherited behavior. Those choices determine which methods are candidates before any invocation is attempted. Reflection can also expose generated accessor methods, so a handwritten list of visible source methods is not always the same as the public method set. Sorting is appropriate when a deterministic report is required.
The lesson selects only public instance methods declared on Probe, then performs separate inherited and private lookups. A common wrong answer omits the instance-or-static dimension or assumes the first returned method is the intended command. Real command discovery should also validate signatures, annotations, duplicate names, and deployment metadata availability. Finding a member does not prove it can be safely invoked in every host or that a trimmed native artifact retained unrelated members outside the declared search contract.
What a strong answer covers
- Selection flags define discovery scope.
- Generated accessors and overloads matter.
- Sorting does not replace signature validation.
Common pitfall
Treating reflection enumeration order or a name-only lookup as a complete command contract.
Follow-up questions
- How does DeclaredOnly affect inherited methods?
- How would you handle overloaded command names?
Self-review
Choose what to revisit. These marks are your own assessment and are separate from lesson completion.