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: 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)
  • 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)
  • Reflection Issues
    ... I"m trying to invoke a method using reflection on a DLL that is already ... Reflection in the past, so I'm familiar with Reflection a little bit. ... classes and assemblies are very complex to invoke, ... Any advice on trying to track ...
    (microsoft.public.dotnet.languages.csharp)
  • invoke a method by reflection£¬the methods parameters can not be ArrayList?
    ... I invoke a method by reflection, when this method's parameters is simple ... type like int or string,the invoking is correct and secceed. ...
    (microsoft.public.dotnet.faqs)