Article View: borland.public.jbuilder.java.language
Article #8492Re: Is "return super;" a valid statement
From: Dave Bird
Date: Sat, 17 Mar 2001 15:40
Date: Sat, 17 Mar 2001 15:40
44 lines
2272 bytes
2272 bytes
In article <3ab26402$1_1@dnews>, Ralph Quapp <-@?.?> writes
>Hello,
>
>I encountered a compile error in one of my classes when using the statement
>"return super;" and compiling it with javac or jikes.
I don't think "super" is properly a value you can return.
You see, "this" is a truly a reference to [address of] a proper thing,
the current object.
However, "super" is a contextual thing that tells you to view
the nature of THIS object in a different way: when you request
super.method1() instead of this.method1(), you specify
the version of a method OF THIS OBJECT in the superclass
before you over-rode it in the current class definition...
not a reference to different object.
An easy-going compiler will say, "oh he must mean 'this',
I'll fix it for him." A more rigorous one will tell you
that, strictly speaking, 'super' is not a reference to
some different object which you could return.
You may conceivably be doing it to return 'this' cast into
the type of the superclass....
class CurClass extends PrvClass {
PrvClass doSomthing(int x){ .......
return super;
Don't do it! return (PrvClass)this;
is the proper syntax.
--
^-^-^-@@-^-;-^ http://www.xemu.demon.co.uk/
(..)__u news:alt.smoking.mooses
Technical Details
Message-ID:
<4uc8uyEiV4s6EwVQ@xemu.demon.co.uk>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!news.maxwell.syr.edu!dispose.news.demon.net!news.demon.co.uk!demon!xemu.demon.co.uk!daveReferences:
<3ab26402$1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,a2b6df84216d25a2 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-17 07:46:05 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!news.maxwell.syr.edu!dispose.news.demon.net!news.demon.co.uk!demon!xemu.demon.co.uk!dave From: Dave Bird <dave@xemu.demon.co.uk> Newsgroups: borland.public.jbuilder.java.language Subject: Re: Is "return super;" a valid statement Date: Sat, 17 Mar 2001 15:40:18 +0000 Organization: none Message-ID: <4uc8uyEiV4s6EwVQ@xemu.demon.co.uk> References: <3ab26402$1_1@dnews> NNTP-Posting-Host: xemu.demon.co.uk X-NNTP-Posting-Host: xemu.demon.co.uk:158.152.196.209 X-Trace: news.demon.co.uk 984843838 nnrp-01:13490 NO-IDENT xemu.demon.co.uk:158.152.196.209 X-Complaints-To: abuse@demon.net MIME-Version: 1.0 X-Newsreader: Turnpike Integrated Version 5.00 U <dQumtnY$x4rJ2u5tL5fS$n2vuP> Lines: 44