tag:blogger.com,1999:blog-8712770457197348465.post2710124507347395158..comments2024-03-18T22:04:10.382-07:00Comments on Javarevisited: How to Invoke Method by Name in Java Dynamically Using Reflection? Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-8712770457197348465.post-78229097844319116962013-07-30T02:42:15.865-07:002013-07-30T02:42:15.865-07:00@Raja if you're so concerned about the securit...@Raja if you're so concerned about the security of your program, you can prohibit reflections in production using security policies. You may want to look at http://stackoverflow.com/questions/770635/disable-java-reflection-for-the-current-threadAnonymoushttps://www.blogger.com/profile/01268439310348979703noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-60108280020373329282012-06-22T01:33:30.806-07:002012-06-22T01:33:30.806-07:00don't invoke java method using Reflection its ...don't invoke java method using Reflection its very slow, Instead use Interface to call methods, even though object will be created by Reflection, calling method using Interfaces rather than java.lang.reflect Method would be much faster. Another disadvantage of invoking method dynamically is that its difficult to debug.Sukhbeernoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-39296135822556136112012-05-23T23:09:09.320-07:002012-05-23T23:09:09.320-07:00@raja, yes you can get all information about a par...@raja, yes you can get all information about a particular class using reflection like all declared field include public and private, all declared method including public and private, methods inherited from super class or super interface. I suggest looking on reflection API for complete details.Pushkarhttp://en.wikipedia.org/wiki/Reflection_(computer_programming)noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-48269831360798737512012-05-23T23:06:43.138-07:002012-05-23T23:06:43.138-07:00Tip 4 "Use Interface to call method using ref...Tip 4 "Use Interface to call method using reflection" is also explained in Effective Java book with good detail. I love that tip. no doubt reflection is powerful but as you said there should be guideline when to call method using reflection and when directly. My approach is to call method normally if information is available on compile time or call method by its name when method name isPandithttp://docs.oracle.com/javase/tutorial/reflect/index.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-29872054589784682522012-05-17T02:50:08.096-07:002012-05-17T02:50:08.096-07:00Due this Reflection its possible to get all the in...Due this Reflection its possible to get all the information about a particular classrajahttp://allinalljava.blogspot.comnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-58657846544421532452012-04-17T07:05:54.731-07:002012-04-17T07:05:54.731-07:00@Anonymous, changing private to public is not good...@Anonymous, changing private to public is not good practice, there are very few scenario when you want to use Reflection to change private field to public, like for testing purpose you can use reflection to make private method accessible.I agree that Reflection is very powerful in terms of flexibility it offer like you can create an object from xml configuration but it comes with cost of Javin @ programming questionshttp://javarevisited.blogspot.com/2011/06/top-programming-interview-questions.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-2233815525501620782012-04-16T15:50:01.068-07:002012-04-16T15:50:01.068-07:00If it's so powerful to turn private into publi...If it's so powerful to turn private into public, why not re-introduce the even more powerful GOTO? Lets call it a design pattern :DAnonymousnoreply@blogger.com