I wonder if JVM/javac is smart enough to turn
// This line...
string a = foo();
string foo()
{
return bar();
}
string bar()
{
return some-complicated-s
A "highly optimizing" JIT compiler will inline both cases (and, @Mysticial, it might even inline some polymorphic cases, by employing various forms of trickery).
You can increase the chances of inlining by making methods final, and a few other tricks.
javac does some primitive inlining, mostly of final/private methods, primarily intended to help out some conditional compilation paradigms.