A
Andreas Jakobik
Hi,
is there an efficient way to dynamically invoke a method that returns
a primitive type? I'd like to avoid the Object to primitive type
conversion. The temporary object wrapper should not have to be created
at all.
In our application (a Configuration Service within a telcom platform)
we dynamically call methods on so called Managed Objects (MOs). Such
an MO may implement the folloing method:
public int getPmX();
The configuration service calls this method by means of reflection,
i.e. Method.invoke(...). However the returned value is (of course) an
Object which must be casted.
My question is: If a client application has a reference to an MO, and
knows the name of the method (but only in run-time) and that it
returns an int (as in the above example), is there a better way to
call the method than using Method.invoke(). My assumption is no... (At
compile time the client application does not know the method name.)
BTW, we're on a J2ME CDC foundation profile which provides an Java 1.2
API.
Thanks a lot!
/Andreas
is there an efficient way to dynamically invoke a method that returns
a primitive type? I'd like to avoid the Object to primitive type
conversion. The temporary object wrapper should not have to be created
at all.
In our application (a Configuration Service within a telcom platform)
we dynamically call methods on so called Managed Objects (MOs). Such
an MO may implement the folloing method:
public int getPmX();
The configuration service calls this method by means of reflection,
i.e. Method.invoke(...). However the returned value is (of course) an
Object which must be casted.
My question is: If a client application has a reference to an MO, and
knows the name of the method (but only in run-time) and that it
returns an int (as in the above example), is there a better way to
call the method than using Method.invoke(). My assumption is no... (At
compile time the client application does not know the method name.)
BTW, we're on a J2ME CDC foundation profile which provides an Java 1.2
API.
Thanks a lot!
/Andreas