Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JIT compiler and anonymous inner classes [closed]

The callback functions by anonymous class is a common approach when we use a framework or a library, so it is very useful to know if the JIT performs such kind optimizations.

I am wondering if the JIT compiler is smart enough to understand that them some code is executed every time and compile into native?

like image 645
mspapant Avatar asked Oct 07 '22 08:10

mspapant


1 Answers

Like any other piece of code, it will be compiled and optimized by the JIT compiler once it has been executed enough times (by default, 10000 with the Hotspot server VM, 1500 with the client VM), so the JIT has enough data to base its optimizations on.

Just because it's anonymous does not mean it's treated any different: it's still a class, with a name generated during the compilation (MyClass$1).

like image 174
Frank Pavageau Avatar answered Oct 11 '22 13:10

Frank Pavageau