Throwing exceptions has always been a somewhat expensive operation, so certainly where high performance is a concern I wouldn't even think of doing this. But, if it's a handful of especially sensitive methods that aren't called all the time, it might be acceptable. Some quick and easy tests should give an answer pretty readily.
-- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] On Thu, February 16, 2006 3:22 pm, Michael Jouravlev said: > On 2/16/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: >> I saw a very similar question asked a few months back in a general Java >> forum, and I suggested an answer that I've never had the chance to >> actually try out... the theory is interesting though... >> >> In the method you want to "protect", immediately throw an exception and >> catch it. Then, parse the stack trace and see who the caller was. If >> it's not a class you want to have access to the method, throw an >> IllegalAccessException. > > I guess it can be costly if the callers are mostly the ones that you > want to allow access to. On the other hand, I don't know the metrics > on how costly is to create and throw an exception. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]