Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!border3.nntp.ams.giganews.com!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 05:34:58 -0500 From: "Chris Uppal" Newsgroups: comp.lang.java.programmer References: <5172e967$0$32109$14726298@news.sunsite.dk> <517b3461$0$32112$14726298@news.sunsite.dk> <2rWdnWTV7bz8FubMnZ2dnUVZ7qGdnZ2d@bt.com> <517c8241$0$32104$14726298@news.sunsite.dk> Subject: Re: A small exercise Date: Sun, 28 Apr 2013 11:34:49 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 Message-ID: <2fednevwr_TPZuHMnZ2dnUVZ8uCdnZ2d@bt.com> Lines: 59 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-njAR2aQqewmPdYu4rUjTmtCrovhwXVAhU2UkfoSN6r36USxbR7PGR/CJZXMzt1iiJBfXF/rYf0aQCWL!IRkxJ3X8vcoFn8Td6E6aeVHw7Ftd7F0fWH066p7Gq+G6O7V+LNWuhUPd1JXyF0iwEanpj85g+KQ= 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: 3764 Xref: csiph.com comp.lang.java.programmer:23691 Arne Vajhøj wrote: > On 4/27/2013 4:25 AM, lipska the kat wrote: > > This *implies* to me that this.b and Main.this.b are not *logically > > equivalent*, this is what I said, nothing to do with whether > > [obnoxious stuff elided] > > Nope. > > The JVM agrees. > > Try: > > System.out.println(this==Main.this); But that proves nothing, doesn't even indicate anything. It's commonplace for two independent identifiers to refer to the same object. And those two different forms of reference may have different rules (consider using protected access via "this" verses an independent reference to the same object). Lipska is suggesting that this is one of those occasions, and that's a perfectly plausible hypothesis. I don't think it turns out to be true, though -- the JSL3 seems to be in opposition. A trawl through the spec (my first in years) discovers 15.8.4, quoted in toto (with the usual bloody difficulty): 15.8.4 Qualifed this Any lexically enclosing instance can be referred to by explicitly qualifying the keyword this. Let C be the class denoted by . Let n be an integer such that C is the nth lexically enclosing class of the class in which the qualified [this] expression appears.The value of an expression of the form .[this] is the nth lexi cally enclosing instance of [this]. (8.1.3). The type of the expression is C.It is a compile-time error if the current class is not an inner class of class C or C itself. (my <>s and []s) The last three words seem, if not decisive, then at least strongly indicative to me. I'm guessing (and I admit that I can find no other supporting evidence) that this is a bug in the compiler where code that is written on the assumption that "C" above must be a strictly enclosing class. In those case the (equivalent) code would obviously be incorrect (and that goes for the blank-final example too). In particular I suspect that its something going squiffy in the contorted logic that allows nested classes to refer to private fields of the [not actually] "enclosing" class at runtime: that horrible stuff that is added to circumvent the JVMs own checking. But I may as well admit that one piece of evidence against my guess is that both javac and Eclipse "fail" in the same way. -- chris