• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reflection Question

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic