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

Jochen Theodorou blackdrag at gmx.org
Wed Jun 17 13:27:03 UTC 2015


Am 16.06.2015 10:40, schrieb Vladimir Ivanov:
[...]
> Example:
> class TopLevel {
>    static class Nested {}
>    class        Inner  {}
>
>    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 to dump class structure:
>    $ java jdk.internal.org.objectweb.asm.util.ASMifier <class_file>
>
> Nested:
>    javap: static #11= #10 of #5; //Nested=class TopLevel$Nested of class
> TopLevel
>    asm: cw.visitInnerClass("TopLevel$Nested", "TopLevel", "Nested",
> ACC_STATIC);
>
> Inner:
>    javap: #8= #7 of #5; //Inner=class TopLevel$Inner of class TopLevel
>    asm: cw.visitInnerClass("TopLevel$Inner", "TopLevel", "Inner", 0);

that nested and inner differ only by the modifier is ok

> Local:
>    javap: #13= #12; //Local=class TopLevel$1Local
>    asm: cw.visitInnerClass("TopLevel$1Local", null, "Local", 0);
>
> Anonymous:
>    javap: #2; //class TopLevel$1
>    asm: cw.visitInnerClass("TopLevel$1", null, null, 0);

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. That's surprising to me.... but actually there is even code 
for this. And I found the bug as well... So thanks for the help

bye Jochen


-- 
Jochen "blackdrag" Theodorou
blog: http://blackdragsview.blogspot.com/




More information about the core-libs-dev mailing list