You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Erik Price <ep...@ptc.com> on 2003/05/16 19:14:20 UTC

[Friday] Re: I never knew! super class to subclass method lookup issue


Brandon Goodin wrote:
> as i expected... same results :-D
> 
> If you wanna view the code:
> http://www.phase.ws/paradox
> 
> Brandon Goodin

You are right.  The protected methods are visible only with 
getDeclaredMethods, or getDeclaredMethod, but not protected methods that 
are inherited.  I realized this after reviewing your demo (thanks for 
whipping it up, it's informative), but then I also realized that this is 
stated in the API documentation.


Hm... now I can't remember what got us onto this subject!
(Though I agree it is an interesting thread to discuss.  I Friday'd it 
b/c I'm not sure if this actually goes back to a Struts issue or not... ;)


Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [Friday] [Craig]Re: I never knew! super class to subclass method lookup issue

Posted by Erik Price <ep...@ptc.com>.

Brandon Goodin wrote:
>>Nothing stops you from introspecting on the superclass yourself, and
>>uncovering its protected methods :-).  And so on up the class hierarchy.
> 
> 
> That is true. But, then that would break my reuse mojo, man!
> 
> That would mean that I would have to do a super.getClass().getMethode() from
> the extended class onto the super. But, when it is the framework that is
> calling the method and not the extended class itself then it wouldn't work.

What about Class.getSuperClass() ?  Then you can trawl back up the 
hierarchy, calling getDeclaredMethods().  (?)


I was going to say "well, maybe the reason that 'getDeclaredMethods' 
doesn't return the inherited methods is because the class itself doesn't 
really keep anything other than a reference to them, and those methods 
-must- be fetched from the class in which they are declared", but then I 
realized that (a) that is inconsistent with 'getMethods' which *does* 
return inherited [public] methods, and (b) I don't know jack about the 
way in which the Java language is actually implemented... i just a 
client programmer.


Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [Friday] [Craig]Re: I never knew! super class to subclass method lookup issue

Posted by Brandon Goodin <ma...@phase.ws>.
>Nothing stops you from introspecting on the superclass yourself, and
>uncovering its protected methods :-).  And so on up the class hierarchy.

That is true. But, then that would break my reuse mojo, man!

That would mean that I would have to do a super.getClass().getMethode() from
the extended class onto the super. But, when it is the framework that is
calling the method and not the extended class itself then it wouldn't work.
The DispatchAction is the perfect example. You can't use protected methods
when you extend it. If you do the introspection will fail to find the
protected methods. Craig, being the the super java coding stud that you
are... wouldn't you say that this functionality would be an appropriate
feature for java to support? How about putting in a word to the J2SE 1.5
guys to beef up the reflection flexibilities. :-D Oh well, I can always
dream.

Again, you can check my demo code at:
http://www.phase.ws/paradox

Brandon Goodin

-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Friday, May 16, 2003 11:21 AM
To: Struts Users Mailing List
Subject: Re: [Friday] Re: I never knew! super class to subclass method
lookup issue




On Fri, 16 May 2003, Erik Price wrote:

> Date: Fri, 16 May 2003 13:14:20 -0400
> From: Erik Price <ep...@ptc.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: [Friday] Re: I never knew! super class to subclass method lookup
>     issue
>
>
>
> Brandon Goodin wrote:
> > as i expected... same results :-D
> >
> > If you wanna view the code:
> > http://www.phase.ws/paradox
> >
> > Brandon Goodin
>
> You are right.  The protected methods are visible only with
> getDeclaredMethods, or getDeclaredMethod, but not protected methods that
> are inherited.  I realized this after reviewing your demo (thanks for
> whipping it up, it's informative), but then I also realized that this is
> stated in the API documentation.
>

Nothing stops you from introspecting on the superclass yourself, and
uncovering its protected methods :-).  And so on up the class hierarchy.

>
> Hm... now I can't remember what got us onto this subject!
> (Though I agree it is an interesting thread to discuss.  I Friday'd it
> b/c I'm not sure if this actually goes back to a Struts issue or not... ;)
>
>
> Erik
>

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [Friday] Re: I never knew! super class to subclass method lookup issue

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 16 May 2003, Erik Price wrote:

> Date: Fri, 16 May 2003 13:14:20 -0400
> From: Erik Price <ep...@ptc.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: [Friday] Re: I never knew! super class to subclass method lookup
>     issue
>
>
>
> Brandon Goodin wrote:
> > as i expected... same results :-D
> >
> > If you wanna view the code:
> > http://www.phase.ws/paradox
> >
> > Brandon Goodin
>
> You are right.  The protected methods are visible only with
> getDeclaredMethods, or getDeclaredMethod, but not protected methods that
> are inherited.  I realized this after reviewing your demo (thanks for
> whipping it up, it's informative), but then I also realized that this is
> stated in the API documentation.
>

Nothing stops you from introspecting on the superclass yourself, and
uncovering its protected methods :-).  And so on up the class hierarchy.

>
> Hm... now I can't remember what got us onto this subject!
> (Though I agree it is an interesting thread to discuss.  I Friday'd it
> b/c I'm not sure if this actually goes back to a Struts issue or not... ;)
>
>
> Erik
>

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: [Friday] Re: I never knew! super class to subclass method lookup issue

Posted by Brandon Goodin <ma...@phase.ws>.
:-)) Yep, it is stated so in the docs. Someone mentioned that about 15 posts
back :o) But, it was fun to exploit the reality. It seems like a limitation
to me. I was hoping someone would pipe up and say why the security functions
this way.

BTW. This discussion started when I was using a customer version of the
LookupDispatchAction (ValidatorLookupDispatchAction) that I wrote. I have
always marked my methods in my extended actions as public. So, I decided I
would make them protected. When I did that the method lookups in my dispatch
action failed to locate the protected methods. So, it led me on this
witch-hunt of curiosity.

Brandon Goodin

-----Original Message-----
From: Erik Price [mailto:eprice@ptc.com]
Sent: Friday, May 16, 2003 11:14 AM
To: Struts Users Mailing List
Subject: [Friday] Re: I never knew! super class to subclass method
lookup issue




Brandon Goodin wrote:
> as i expected... same results :-D
>
> If you wanna view the code:
> http://www.phase.ws/paradox
>
> Brandon Goodin

You are right.  The protected methods are visible only with
getDeclaredMethods, or getDeclaredMethod, but not protected methods that
are inherited.  I realized this after reviewing your demo (thanks for
whipping it up, it's informative), but then I also realized that this is
stated in the API documentation.


Hm... now I can't remember what got us onto this subject!
(Though I agree it is an interesting thread to discuss.  I Friday'd it
b/c I'm not sure if this actually goes back to a Struts issue or not... ;)


Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org