Skip to content

Instantly share code, notes, and snippets.

@Maccimo
Last active September 19, 2019 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maccimo/eafdaa022a2e17ded695d01d2672788c to your computer and use it in GitHub Desktop.
Save Maccimo/eafdaa022a2e17ded695d01d2672788c to your computer and use it in GitHub Desktop.
`var` is a fail!
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