I was wondering what the performance penalty is for generic type inference in Java 7. Is the "generics method type inference" cost (i.e., this) different from the "generics assignment type inference" cost (i.e., this)? I suppose the cost is negligible since type inference on generics is done in compile time?
Also, as far as "improved type inference" (i.e., this) in Java 8 (due to lambda's), does this also levy a performance hit? How is the performance cost for type inference in Java 8 different from that in Java 7?
I realize these are difficult (and possibly, ill informed) questions, and hence, welcome any input.
Is the "generics method type inference" cost (i.e., this) different from the "generics assignment type inference" cost (i.e., this)?
No.
I suppose the cost is negligible since type inference on generics is done in compile time?
The cost is zero for that reason, unless you count compile time.
Also, as far as "improved type inference" (i.e., this) in Java 8 (due to lambda's), does this also levy a performance hit?
This is zero as well. There is no 'also levy a performance hit' about it.
As you supposed, generics are removed during compilation, and after that there are only pure (non-generic) classes.
The type inference in Java 7 is pretty simple to perform (of course still during compilation) so it won't impact on performance at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With