Details
Description
In the org.apache.sis.xml.NilReason class, the private createNilPrimitive(Class) method instantiates new Boolean, Byte, Short, Integer, Long, Float or Double objects by invoking directly their constructor. The valueOf(…) methods cannot be used in this context, because we really need new instances. They are used for identifying a particular instance as a nil object.
This pattern will soon not work anymore, because those primitive wrappers will become value objects. The constructors that we are invoking will be removed, and the identity comparisons that we rely on will not work anymore. As a consequence, all SIS versions before we resolve this issue may fail with NoSuchMethodError in future Java versions (when primitive wrappers will become value objects). However this error will occur only if "nil values" are used on primitive wrappers, which should be rare.
I'm not aware of a complete substitute for the functionality. We may loose the capability to flag some Integer values as "nil value". Possible alternatives may be:
- For values that are supposed to be measurements, use javax.measure.Quantity instead.
- For other kind of values, use Number instead. A good side effect is to allow the use of BigInteger or BigDecimal if the implementation wants to do so.