Article View: borland.public.jbuilder.java.language
Article #8521Re: Is "return super;" a valid statement
From: Torsten Welches
Date: Sun, 18 Mar 2001 09:58
Date: Sun, 18 Mar 2001 09:58
64 lines
2133 bytes
2133 bytes
Ralph,
there is no such thing as a "super instance", that's what your code implies.
Super is only supposed to allow access to super*class* members (fields,
methods and constructors). Unlike this, super does *not* denote a reference
value, hence it shouldn't compile.
Torsten
Ralph Quapp <-> schrieb in Nachricht <3ab26402$1_1@dnews>...
>Hello,
>
>I encountered a compile error in one of my classes when using the statement
>"return super;" and compiling it with javac or jikes. JBuilder does not
>complain. In my example doSomething() in class B contains this statement.
>
>The error reported is:
>
>Error in file ReturnType.java at line 31, column 37: '.' expected
>
>I am wondering now whether the statement is valid or not? And of course
why?
>
>regards Ralph
>
>
>public class ReturnType
>{
>
> public class A
> {
> public String a = "A";
>
> public A doSomething()
> {
> return this;
> }
> }
>
> public class B extends A
> {
> public String b = "B";
>
> public A doSomething()
> {
> return super; <---- error
> }
> }
>
>
> public ReturnType()
> {
> B b = new B();
>
> A a = b.doSomething();
> }
>
> public static void main(String[] args)
> {
> ReturnType r = new ReturnType();
> }
>}
>
>
Technical Details
Message-ID:
<3ab487e7_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!213.168.73.239References:
<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-18 02:18:03 PST From: "Torsten Welches" <torsten.welches@who.cares.netcologne.de> Newsgroups: borland.public.jbuilder.java.language References: <3ab26402$1_1@dnews> Subject: Re: Is "return super;" a valid statement Date: Sun, 18 Mar 2001 10:58:43 +0100 Lines: 66 X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 NNTP-Posting-Host: 213.168.73.239 Message-ID: <3ab487e7_2@dnews> X-Trace: 18 Mar 2001 02:03:19 -0800, 213.168.73.239 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!213.168.73.239