From jon.rafkind at hp.com Thu Nov 7 11:16:14 2013 From: jon.rafkind at hp.com (Rafkind, Jon) Date: Thu, 7 Nov 2013 19:16:14 +0000 Subject: 18.2.3 subtyping constraints Message-ID: I think the following sentence could be made a little clearer. If T is a parameterized class type, C, then let C the parameterization of C that is a supertype of S (or S itself); if no such parameterization exists, the constraint reduces to false. Here is my attempt: If T is a parameterized class type, C then find a supertype of S (or choose S itself) with the same type C whose parameterization is C; if no such parameterization exists the constraint reduces to false. From markus_keller at ch.ibm.com Fri Nov 8 07:37:04 2013 From: markus_keller at ch.ibm.com (Markus Keller) Date: Fri, 8 Nov 2013 16:37:04 +0100 Subject: Lambda expressions keeping a reference to the enclosing instance In-Reply-To: <74AB836A-DD97-4F93-92BD-5A4164EF9E58@oracle.com> References: <74AB836A-DD97-4F93-92BD-5A4164EF9E58@oracle.com> Message-ID: Dan Smith wrote on 2013-10-30 20:36:45: > http://cr.openjdk.java.net/~dlsmith/jsr335-0.7.0/ 15.27.4 defines the value of a lambda expression, but misses to define an important property of the lambda instance: Can/must/will the lambda instance contain a reference to the enclosing instance (if one exists)? 15.27.4 point 4 implicitly makes such a reference to the outer "this" necessary iff the lambda body actually contains such a reference. But it is unclear whether the lambda always contains this reference. For the similar situation with inner classes, JLS7 clearly specifies that the inner class constructor always gets a reference to the enclosing instance (8.1.3, 13.1, 15.9.3). For methods references, the new 15.28.3 also spells out the forms for which a target reference is retained. For lambda expressions, current Java 8 beta implementations seem to avoid the reference by declaring the synthetic lambda$x method declaration as static if possible. Request: Specify that a reference to the enclosing instance of a lambda expression is only retained if necessary. That makes the system behavior well-defined and makes memory leaks (via lambda expressions that leak a reference to the enclosing instance) deterministic like in the rest of the Java language. Markus -- References: jsr335-0.7.0 15.27.4 Point 4: "The method's body has the effect of evaluating the lambda body, if it is an expression, or of executing the lambda body, if it is a block;" JLS7 8.1.3 says about inner classes: "An instance i of a direct inner class C of a class O is associated with an instance of O, known as the immediately enclosing instance of i. The immediately enclosing instance of an object, if any, is determined when the object is created (?15.9.2)." JLS7 13.1 says about inner member classes: "In addition, the constructor of a non-private inner member class must be compiled such that it has as its first parameter, an additional implicit parameter representing the immediately enclosing instance (?8.1.3)." JLS7 15.9.3 says about anonymous classes: "Otherwise, the immediately enclosing instance of i with respect to S is the first argument to the constructor". From markus_keller at ch.ibm.com Wed Nov 20 02:09:43 2013 From: markus_keller at ch.ibm.com (Markus Keller) Date: Wed, 20 Nov 2013 11:09:43 +0100 Subject: Lambda expressions keeping a reference to the enclosing instance Message-ID: Resending; looks like my mail from 2013-11-08 to lambda-spec-comments was lost. __________________ Dan Smith wrote on 2013-10-30 20:36:45: > http://cr.openjdk.java.net/~dlsmith/jsr335-0.7.0/ 15.27.4 defines the value of a lambda expression, but misses to define an important property of the lambda instance: Can/must/will the lambda instance contain a reference to the enclosing instance (if one exists)? 15.27.4 point 4 implicitly makes such a reference to the outer "this" necessary iff the lambda body actually contains such a reference. But it is unclear whether the lambda always contains this reference. For the similar situation with inner classes, JLS7 clearly specifies that the inner class constructor always gets a reference to the enclosing instance (8.1.3, 13.1, 15.9.3). For methods references, the new 15.28.3 also spells out the forms for which a target reference is retained. For lambda expressions, current Java 8 beta implementations seem to avoid the reference by declaring the synthetic lambda$x method declaration as static if possible. Request: Specify that a reference to the enclosing instance of a lambda expression is only retained if necessary. That makes the system behavior well-defined and makes memory leaks (via lambda expressions that leak a reference to the enclosing instance) deterministic like in the rest of the Java language. Markus -- References: jsr335-0.7.0 15.27.4 Point 4: "The method's body has the effect of evaluating the lambda body, if it is an expression, or of executing the lambda body, if it is a block;" JLS7 8.1.3 says about inner classes: "An instance i of a direct inner class C of a class O is associated with an instance of O, known as the immediately enclosing instance of i. The immediately enclosing instance of an object, if any, is determined when the object is created (?15.9.2)." JLS7 13.1 says about inner member classes: "In addition, the constructor of a non-private inner member class must be compiled such that it has as its first parameter, an additional implicit parameter representing the immediately enclosing instance (?8.1.3)." JLS7 15.9.3 says about anonymous classes: "Otherwise, the immediately enclosing instance of i with respect to S is the first argument to the constructor".