• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Reflection Dynemic Invocation  RSS feed

 
Alan Hermin
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys... i have problem in using this code for dynamic invocation for showMe() method,,which produce Exception like this: NoShuchMethod Exception().....



any one tell me what is the problem?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16045
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will work if you make the showMe() method in class B public.

The API documentation of Class.getMethod(...) says:

Returns a Method object that reflects the specified public member method of the class or interface represented by this Class object.
 
Alan Hermin
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohh...that is right...
thnx very much man.. currently i'am learning Java Reflection from "Manning Java Reflection In Action"
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could use getDeclaredMethod() to get a non-public method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!