Re: Reflection, how to understand




Oliver Wong wrote:
"John_Woo" <john_woo@xxxxxxxxxx> wrote in message
news:1157044317.744253.105310@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I'm trying understand jdk 5 reflection.

I know it's for loading/invoking method on the fly. I'm wondering, any
simple core-java example (not sort of EJB, rmi) illuestrated how an app
re-compile then invoke the newly classes/methods, and why need to do
that (recompile)?

Reflection isn't nescessarily related to recompilations. I think the
name "reflection" is supposed to convey the image of a Java program looking
at itself in a mirror, or in other words, to look at itself.

For example, you might have an object which is an instance of Class. You
can query this object to find out what methods it has, and invoke these
methods. This would be using reflection, even if no (re)compilation was
involved.


Thanks, Oliver.

if I want to see how a class recompiled and its method updated then
invoked, do you have an example, and what cases need a class to be
compiled in running time?

John

.



Relevant Pages

  • Re: java - invoke
    ... You have stumbled on one of the most subtle features of Java called ... You create call lists of parameters on the fly and invoke methods. ... It is a tool to allow java code to use arbitrary class files handed to ... You can usually get what you want without resorting to reflection ...
    (comp.lang.java.help)
  • Re: How to query n web services
    ... When I added web references, I wrote 10 different web references name. ... and then invoke service01.someMethod... ... The subset is given by strings. ... Using Reflection, you can use a string to create an instance of an object and then invoke methods on that instance. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: How can I detect the presense of an optional assembly and call a method within it?
    ... Basically you will need to use Reflection. ... allows you to dynamically create instances at runtime and invoke method. ... > 1- Read a configuration file where the client provides the assembly name ... > (DLL) and the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How would you invoke arrayList.get() through reflection in 1.4 ??
    ... Sébastien de Mapias wrote: ... It seems to be pretty hard to invoke the List getmethod through ... I didn't manage to have my code working with my 1.4 ... That is *much* easier than using reflection. ...
    (comp.lang.java.programmer)
  • TransparentProxy and Reflection
    ... I'm using reflection to instantiate classes and then to invoke methods ... know the type at compile time, ...
    (microsoft.public.dotnet.framework)