Code Comments
Programming Forum and web based access to our favorite programming groups.Hi all, What is the reason that getMethods() method (in java.lang.Class) return only public methods? After all, couldn't it return all methods, and then, upon invocation, throw a SecurityException (or IllegalAccessException)? What is the rationale for this? ----- P.S. After reading http://www.yoda.arachsys.com/java/newsgroups.html, http://mindprod.com/jgloss/newsgroups.html and http://www.faqs.org/faqs/computer-l.../help/minifaq/, I do feel this cross-post is justified. If there's a more authoritative source, please point them out to me. Advocacy was chosen because this is a point of Sun's choice, and security -- because this is related to access of methods.
Post Follow-up to this message> What is the reason that getMethods() method (in java.lang.Class) > return only > public methods? After all, couldn't it return all methods, and then, > upon > invocation, throw a SecurityException (or IllegalAccessException)? > What > is the rationale for this? Seen getDeclaredMethods()? There are two functions because: - getMethods() exhibits all methods that "object" of class implements, (inc luding inherited), - getDeclaredMethods() exhibits only methods declared in "class" (including private, not including inherited) so getDeclaredMethods() is more powerful... but in most cases less convenien t than simple getMethods(). -- jarekr
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.