4 ms·
So for getters and setters a Jit can inline the function call and in the end you have a direct memory access. In your example you have to cast because URLConnec
by pgrulich 7y ago
So for getters and setters a Jit can inline the function call and in the end you have a direct memory access.
In your example you have to cast because URLConnection could be a HttpURLConnection or JarURLConnection.
But again a good Jit would speculate that it is always a HttpURLConnection and deoptimize if not.
- imtringued 7y agoThe JVM also has full information about the class hierarchy at runtime. If you add a class that overrides a function it will deoptimize that overriden function to a virtual function but otherwise the JVM will just treat it as a static function and inline it if necessary.