tags:

views:

23

answers:

1

Do java compilers (javac or eclipse) try to compile method calls as static when the target method is known statically (even if it's not a static method). Eg.

class A { 
    void foo() { doStuff(); }
}
...
A a = new A();
a.foo(); // is this compiled as virtual call or static call?
A: 

See my response at http://stackoverflow.com/questions/3669071/how-to-find-out-what-optimizations-the-jvm-applied-to-my-code/3669222#3669222

gpeche
Thanks! From this i understand that compiler can create a static call even when it only hopes that it will be static, and JIT patches up things when compiler's dreams didn't come true.
Aivar
Note that source code compilers typically generate quite straightforward, not really optimized bytecode, to help JIT compilers do a better job. The optimizations are usually JVM-dependent, not compiler-dependent.
gpeche