I've been using java.util.Optional
extensively in my code for better null handling. I even went as far as creating new "safe" datastructures with stuff like:
public Optional<Integer> indexOf(E elem) {...}
I'm curious to know if (not necessarily how much) this might impact my application's performance. Specifically, I have two main concerns:
- Does the usage of
java.util.Optional
affect memory consumption or execution speed at all? - How does the JIT Compiler treat the Optional wrapping - is it efficient and throws out the wrapping and unwrapping, or could this conversion end up being a performance cost?
Any insights would be much appreciated.