Value types and parameter names
lovro.pandzic at gmail.com
Mon Dec 1 19:02:58 UTC 2014
I've been monitoring the Valhalla project for some time now and I have a
question: will the new parameter names API introduced in Java 8 be
available for value types? If so, is there a possibility for it to be
turned on by default?
One great thing I like about the new parameter names is that it provides a
supported way for eliminating the need of JavaBeans setters. See  for
example. In various libraries and frameworks, setters are often used as a
tool for both discovering component names of an object and for injecting
those components while constructing it because parameter names of
constructors were not available through reflection, at least not until Java
8. This approach goes against simplicity, immutability and only presents
boilerplate in the code. Luckily, value types are planned to be immutable
so setters are impossible.
On the other hand, without setters, the only way for constructing those
value types in those frameworks would be to use those constructor if they
have parameter names available at runtime.
More information about the valhalla-dev