0

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?
Aivar
  • 6,814
  • 5
  • 46
  • 78

1 Answers1

1

See my response at How to find out what optimizations the JVM applied to my code?

Community
  • 1
  • 1
gpeche
  • 21,974
  • 5
  • 38
  • 51
  • 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 Sep 09 '10 at 16:18
  • 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 Sep 09 '10 at 16:55