Of course the second option is more elegant and simple. But if you are concerned about performance you should go for first approach. Second method also fails if a security manager is running.
I would go for the first option if I was in your situation.
Also there is a mistake in your first approach in generating hashCode:
It should be builder.toHashCode()
instead of builder.hashCode()
. The latter returns hashcode builder object’s hash code.