Search code examples
javareflectionannotationsudprmi

Locate method from subclass in superclass using reflection


I'm working on a reflection system for use with KryoNet RMI to allow me to do unreliable object calls. However, this relies on using an annotation to mark various methods as being '@Unreliable'.

The problem here if I store a map of Methods to their 'infos' describing the annotations and such, a method in a subclass does not match one in its superclass, so the Method cannot be located. Due to the complexity of methods, all the information available is needed to differentiate a method, but I don't require the type info in its tree -- just the pure method data, name, arguments and return type.

Is there any API available to create a more flexible Method object (maybe in an external lib) or do I have to code it myself?

Cheers,
Chris


Solution

  • I 'fixed' this issue by iterating over subclasses and locating the method manually using the name and parameter types of the method to add them also to the same map (the map stores method to method info, so I use the same method info instance for multiple method keys).