Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace Newsgroups: comp.lang.java.programmer Subject: Re: Design Patterns Date: Tue, 05 Feb 2013 14:30:58 -0800 Organization: A noiseless patient Spider Lines: 47 Message-ID: References: <3c0d69c3-591d-4d99-8c13-30a0fd1684b3@googlegroups.com> <68pyk4ua9x9m.1nm4lckdwgp86.dlg@40tude.net> <51106eff$0$293$14726298@news.sunsite.dk> <1g6plnhx9njxt$.bx5mrpbwc6mi$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 5 Feb 2013 22:30:36 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="fba3415ba68d85d643935af2f52f0b4b"; logging-data="21806"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ZaJ4DwdyZlMx/apdRcAvhn+DtGVzYAH4=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 In-Reply-To: Cancel-Lock: sha1:mj03Aq+qaT6CVLigWo1bk97jMck= Xref: csiph.com comp.lang.java.programmer:22133 On 2/5/2013 2:06 PM, Stefan Ram wrote: > markspace writes: >> A real static class is a nested class > >> that has > > whose instances have > >> no (implied) reference to > >> its enclosing instance. > > their enclosing instances. > > BTW: A static class has a reference to its enclosing class. "Class object." It's splitting hairs a bit, but that is how the JLS refers to them. Example: "In the Java virtual machine, every object belongs to some particular class: the class that was mentioned in the creation expression that produced the object (§15.9), or the class whose Class object was used to invoke a reflective method to produce the object..." > > public class Main > { static class C {} > public static void main( final java.lang.String args[] ) > { java.lang.System.out.println( C.class.getEnclosingClass() ); }} > C.class is a class object. "Class" as I use it above (usually with a lower case 'c') is more the concept of a class, rather than its Java implementation of the class. (Rather the same way that the JLS uses 'class' to refer to the general concept of a class in OOD, for example that section of the JLS I quoted above.) That said, you're not really wrong to point out it's really the instances that have references to their enclosing class.