commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <dmi...@apache.org>
Subject [reflect] Method lookup
Date Sun, 16 Jun 2002 23:39:12 GMT
Here's something that might belong in reflect.  Check out this class:

http://jakarta.apache.org/commons/jxpath/xref/org/apache/commons/jxpath/util
/MethodLookupUtils.html

I know, I know, it could benefit from a lot more javadoc and I will add it
soon.

The basic idea of MethodLookupUtils is that it performs dynamically the type
of method lookup that a Java compiler does statically.

For example, let's say I have this class:

    class Foo {
      void bar(int x);
      void bar(String y);
    }

Then,

    Method method = MethodLookupUtils.lookupMethod(Foo.class, "bar", new
Integer(3));

will perform a method lookup based on the class, method name, argument types
and, if there is no exact type match, on _convertability_ of the arguments
to the parameter types.

MethodLookupUtils are used by JXPath to choose among extension functions.

Just another drop in the pool of ideas.

- Dmitri


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message