Krakatau icon indicating copy to clipboard operation
Krakatau copied to clipboard

Incorrect handling of ldc MethodType

Open samczsun opened this issue 8 years ago • 3 comments

Strangely enough, I can ldc a MethodType, and the JVM will let me print it:

.version 52 0 
.class public super Test
super java/lang/Object 

.method public static main : ([Ljava/lang/String;)V 
    .code stack 10 locals 10 
L0:     getstatic Field java/lang/System out Ljava/io/PrintStream; 
L3:     ldc MethodType "(Ljava/lang/Object;)V" 
L5:     invokevirtual Method java/io/PrintStream println (Ljava/lang/Object;)V 
L8:     return 
L9:     
    .end code 
.end method 
.end class 

Output: (Object)void

Decompiled output:

public class proof {
    public static void main(String[] a)
    {
        System.out.println();
    }
}

samczsun avatar Dec 29 '16 08:12 samczsun

The decompiler doesn't really attempt to handle method handle/type/invoke dynamic stuff, since I'm not sure if there is a good way to represent it in Java.

Storyyeller avatar Dec 29 '16 08:12 Storyyeller

In this case, it seems to just print the simple version of the MethodType. MethodHandles can't be loaded onto the stack. I wonder if this is an oversight in the JVM..?

samczsun avatar Dec 29 '16 08:12 samczsun

It seems that at 3am in the morning I don't function too well. Looking back at that comment I'm not really sure what I was thinking but it obviously isn't correct.

For MethodTypes maybe an artificial MethodType.fromMethodDescriptorString could be inserted? It seems better than not displaying any indication of the value at all

samczsun avatar Dec 29 '16 18:12 samczsun