File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Reflection Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reflection Question" Watch "Reflection Question" New topic
Author

Reflection Question

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
When a method returns a primitive, but you invoked it from Method.invoke(...), does it return a the primitive wrapper?
example:
public boolean yes()
{
return true;
}
invoking from reflection:
(DO I HAVE TO DO THE FOLLOWING?)
( ( Boolean )meth.invoke( target, null ) ).booleanValue();
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Correct.


"I'm not back." - Bill Harding, Twister
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Simple answer: yes. Parameters passed to an invoked method need to be wrapped whenever the origninal parameter happens to be of primitive type and the same counts for the return values of reflective invokation methods. You need to unwrap them yourself.
kind regards
 
jQuery in Action, 2nd edition
 
subject: Reflection Question
 
Similar Threads
wrapper and == question
static factory method
getclass() mthod
Boolean type from 0 length string
Wanted: How to return multiple values when using java.lang.reflection.invoke?