commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Price <epr...@ptc.com>
Subject Re: [digester] give Digester access to private data
Date Mon, 17 Mar 2003 16:34:18 GMT


Dominique Devienne wrote:
> Why do you need to call a private method???
> 
> In any case, if you're running without a security manager, you can simply
> call AccessibleObject/Method.setAccessible(true) to bypass Java's access
> checking rules (and get all methods instead of just the public ones, by
> calling Class.getDeclaredMethods). It's technically possible, but again, why
> would you need it... --DD

I didn't know about the setAccessible method -- guess I have more to 
learn about java.lang.reflect.

As for where I'd need it, I have a class that uses a digester to "set 
itself up" (setting some parameters) using methods that I wanted to keep 
private simply because the class shouldn't be used /without/ a digester. 
  But it's not according to some official design, I'm sort of just 
playing about with it and making these methods public isn't really going 
to compromise my class's integrity, so it will be just easier to do 
that.  I was simply following the suggestion that generally methods 
should be left private unless they absolutely have to be public in order 
to fulfill their purpose.

Thanks for the pointer Dominique.


Erik


Mime
View raw message