Re: java - invoke



On Fri, 21 Aug 2009 11:53:11 -0700 (PDT), KeeKee
<chenkeekee@xxxxxxxxx> wrote, quoted or indirectly quoted someone who
said :

Could anyone explain what the feature of invoke, why do we need
invoke?
Thanks in advance.

You have stumbled on one of the most subtle features of Java called
reflection. Basically it allows you to call methods at run time that
were not written at compile time, and further whose structure too was
unknown, e.g. the names of the methods and the types of the
parameters.

You create call lists of parameters on the fly and invoke methods.
You can probe to find out what methods are available and what parms
they want.

see http://mindprod.com/jgloss/reflection.html

It is a tool to allow java code to use arbitrary class files handed to
it at run time.

You can usually get what you want without resorting to reflection
using dynamic loading.
see http://mindprod.com/jgloss/classforname.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

http://thecovemovie.com : The Cove: a documentary about Japan's secret atrocities against dolphins.
.



Relevant Pages

  • Re: Make Array Unmodifiable?
    ... By using the reflection API it is still possible to ... You can invoke a method, regardless of access modifier, using reflection. ... Sun Certified Developer for the Java 2 Platform ...
    (comp.lang.java.programmer)
  • invoking a method on an object
    ... where I want to invoke a method on the object based on the name of the ... "foo" on object "o". ... I know this is possible in java using reflection. ...
    (comp.lang.cpp)
  • Re: Art of MetaObject Protocol and Reflection (Java, C#, etc.)
    ... well i know about java reflection but not about CLOS MOP. ... java reflection does not allow you to create classes at runtime. ...
    (comp.lang.lisp)
  • Re: Art of MetaObject Protocol and Reflection (Java, C#, etc.)
    ... to "reflection" in Java, C#, etc? ... etc. which they call the "reflection" property ... If you allow programmers to intercede at each and every single step of your program execution, though, your programs slow down considerably, even if noone intercedes anything, because the runtime has to continually check whether someone wants to do something additionally or not. ... I am convinced that a full runtime metaobject protocol is essential. ...
    (comp.lang.lisp)
  • Re: =?ISO-8859-15?Q?Kompatibilit=E4t_von_Konzepten_von_P?= =?ISO-8859-15?Q?HP_zu_Jav
    ... eine Antwort darauf, wie man in Java dynamisch Klassen über Reflection laden kann, hat Heiner dir ja schon gegeben. ... Besser wäre, wenn Du dir ein entsprechendes Interface deklarierst ), und die Methdoe dann einfach so implementierst: ... Vielleicht nennst Du mal ein konkretes Beispiel, bei dem Du in PHP derartiges gemacht hast, dann können wir dir auch sagen, wie man das ganze in Java machen würde. ...
    (de.comp.lang.java)