Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-17 Thread David Holmes
On 18/06/2015 7:56 AM, John Rose wrote: On Jun 17, 2015, at 6:27 AM, Jochen Theodorou wrote: I did not expect that the outer class is not set for Local and Anonymous classes. I would have thought that the enclosing method is the only difference. A bit of history (which can be found in the J

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-17 Thread John Rose
On Jun 17, 2015, at 6:27 AM, Jochen Theodorou wrote: > > I did not expect that the outer class is not set for Local and Anonymous > classes. I would have thought that the enclosing method is the only > difference. A bit of history (which can be found in the JVMS itself): The EnclosingMethod

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-17 Thread John Rose
On Jun 16, 2015, at 8:36 PM, David Holmes wrote: > > On 17/06/2015 8:39 AM, John Rose wrote: >> What I'm suggesting is that a BC generator might emit a zero length name for >> a non-anon class, leading to confusion when C.isAnon is called. > > Is a zero-length "name" for a non-anonymous class v

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-17 Thread Jochen Theodorou
Am 16.06.2015 10:40, schrieb Vladimir Ivanov: [...] Example: class TopLevel { static class Nested {} classInner {} void f() { class Local {} } Object o = new TopLevel() {}; // anonymous } And here's how they look like on bytecode level. I'll use both javap and ASM

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-16 Thread David Holmes
On 17/06/2015 8:39 AM, John Rose wrote: What I'm suggesting is that a BC generator might emit a zero length name for a non-anon class, leading to confusion when C.isAnon is called. Is a zero-length "name" for a non-anonymous class valid? getSimpleName() is specified to return "" for anonymous

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-16 Thread John Rose
What I'm suggesting is that a BC generator might emit a zero length name for a non-anon class, leading to confusion when C.isAnon is called. – John > On Jun 16, 2015, at 5:09 AM, Vladimir Ivanov > wrote: > > John, > >> >> That might be an issue here. Just as (String)null and (String)"" ar

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-16 Thread joe darcy
FYI, "Nested, Inner, Member, and Top-Level Classes" https://blogs.oracle.com/darcy/entry/nested_inner_member_and_top -Joe On 6/16/2015 1:40 AM, Vladimir Ivanov wrote: Jochen, Let me elaborate on that topic a bit. There are 5 types of classes mentioned in JVMS: - top-level - neste

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-16 Thread Vladimir Ivanov
John, That might be an issue here. Just as (String)null and (String)"" are distinct values in Java, in the class file a CP ref of zero differs from a CP ref to a CONSTANT_Utf8 of the empty string "". But the method Class.isAnonymousClass does not make a distinction between those two cases,

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-16 Thread Vladimir Ivanov
Jochen, Let me elaborate on that topic a bit. There are 5 types of classes mentioned in JVMS: - top-level - nested - inner - local - anonymous Example: class TopLevel { static class Nested {} classInner {} void f() { class Local {} } Object o = new TopLevel() {

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-15 Thread John Rose
On Jun 14, 2015, at 7:25 PM, David Holmes wrote: > > > Which reflection method are you referring to? Class.isAnonymousClass is > defined in terms of getSimpleName(): > > public boolean isAnonymousClass() { >return "".equals(getSimpleName()); > } That might be an issue here. Just as (Stri

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-15 Thread Jochen Theodorou
Am 15.06.2015 18:04, schrieb Vladimir Ivanov: [...] In order to make the class non-anonymous again, you have to specify inner_name_index and, optionally, outer_class_info_index. ok... let me try to understand this better... taking this Java source public class Test { public static void main(S

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-15 Thread Vladimir Ivanov
Jochen, plus... it would be really really nice if someone could tell me how a non-anonymous class in a method has to look like with javap, so that I can know from there if it is no anonymous and finally fix he flags for Groovy's class generation. Every entry in InnerClass attribute contains 4 f

Re: JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-14 Thread David Holmes
Hi Jochen, On 15/06/2015 3:20 AM, Jochen Theodorou wrote: Hi all, this mail is refering to http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-April/032733.html and JDK-8057919 In a groovy program def cl = { -> '' } assert cl.class.anonymousClass == false the open block {->''} is compi

JDK-8057919 Class.getSimpleName() should work for non-JLS compliant class names

2015-06-14 Thread Jochen Theodorou
Hi all, this mail is refering to http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-April/032733.html and JDK-8057919 In a groovy program def cl = { -> '' } assert cl.class.anonymousClass == false the open block {->''} is compiled into an inner class. We had problems with this in th