Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 28 Apr 2013 04:37:27 -0500 Date: Sun, 28 Apr 2013 10:37:24 +0100 From: lipska the kat <"nospam at neversurrender dot co dot uk"> Organization: Trollbusters 3 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: A small exercise References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 62 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-ayA6rAOfHNRQrszgq9SvwdQHY9e2rV0f3iI2/wdcokJQ4PGtwTMV59fqkQyINvFEHms9Z86BxREYGC0!/kwOa1bzV86hrbcVLH0pVcLxhr4eZEk295gmgDNI1YsNkGvF0X6xKeDssWhRj1hoLFohMNNUVIo= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3096 Xref: csiph.com comp.lang.java.programmer:23690 On 27/04/13 20:28, Sven Köhler wrote: > Am 20.04.2013 19:02, schrieb lipska the kat: >> I think that logically, Main.this.b refers to the enclosing *instance* >> which implies that the class has been instantiated > > "this" also refers to an instance - doesn't it? > And following your argument, I should not be able to use "this" in the > constructor. > > I'm not saying, that the JLS makes a different between a mere "this" and > a construct of the form "Classname.this" and that this is essentially > the cause for the code not compiling. But I don't see the point of your > argument. java-7-openjdk, Eclipse Juno this compiles final int a; int b; public Main(){ this.a = 0; Main.this.b = 0; } this doesn't final int a; *final* int b; public Main(){ this.a = 0; Main.this.b = 0; } The only difference is the final modifier applied to the second b I suppose I agree that at first site this and Main.this refer to the same instance, however we are still left with the fact the second snippet doesn't compile. So, I'm saying that *logically* this and Main.this are not equivalent. If they were then we wouldn't be having this problem would we? Or maybe you know better, in which case can you tell me 'cause this is starting to bug me. Now I'm trying to figure out *why* they are different and one theory is that as far as the complier is concerned the construct Main.this.b in some way *implies* that Main has already been instantiated so attempting to initialize a final variable after instantiation is illegal. Does that make more sense? No!, well do you have a better idea? Interesting discussion lipska -- Lipska the KatŠ: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun