Last active
September 19, 2019 02:15
-
-
Save Maccimo/eafdaa022a2e17ded695d01d2672788c to your computer and use it in GitHub Desktop.
`var` is a fail!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.invoke.MethodHandle; | |
import java.lang.invoke.MethodHandles; | |
import java.lang.invoke.MethodType; | |
import java.io.PrintStream; | |
public class VarFail { | |
public static void main(String... args) throws Throwable { | |
MethodHandles.Lookup lookup = MethodHandles.lookup(); | |
MethodHandle mh = lookup.findVirtual( | |
PrintStream.class, "println", | |
MethodType.methodType(void.class, Object.class) | |
); | |
//Object message = "Hello, bug!"; | |
var message = "Hello, bug!"; | |
mh.invokeExact(System.out, message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment