Is JVM smart enough?

I know that JVM will be smarter as the time goes on (optimize code, etc …). But how smarter can it be? Let’s consider some real scenario, that I often see. public static String toJson(final Object …