Re: New Reflection/Beans API

"Juozas Baliuka" <[email protected]>
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <005c01c20b28$e0814200$0111010a@user>
It is no problem to invoke static method :

publi class MyClass{
  public static void foo(){

}

}

public class GeneratedReflectForMyClass{

public Object invoke(Object instance/*can be null for static method*/, int
index, Object args[] ){
        ..............
       case FOO_INDEX :
      MyClass.foo();
      return null;
      ..................

}
}




> [email protected] wrote:
>
> > I don't see what you are talking about.  You know what class you are
> > calling the static method on, it's just a matter of casting the return
> > value of the method.  Where does the dispatcher come in?
>
> Ok,
>
>
> you have added a static method foo() to the "to be reflected class" A,
> what you would write in plain source code then is
>
> A.foo()
>
> And that's the crucial point, because we're not on source code level
> here, i.e., there's no place where this code is present. The method
> exists, but you can not call it (without using "normal" reflection).
> With instance methods it works, because have have an instance, i.e.,
> an object which can cast to something appropriate. as shown in the
> example.
> With static methods you don't have an instance, thus no cast possible.
> You need to generate an additional object on the fly that calls that
> method, and that's what I'm talking about.
>
> Cheers
> Markus
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:[email protected]>
> For additional commands, e-mail: <mailto:[email protected]>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.