[
https://issues.apache.org/jira/browse/SIS-566?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martin Desruisseaux closed SIS-566.
-----------------------------------
Assignee: Martin Desruisseaux
Resolution: Fixed
> Remove instantiation of primitive wrappers
> ------------------------------------------
>
> Key: SIS-566
> URL: https://issues.apache.org/jira/browse/SIS-566
> Project: Spatial Information Systems
> Issue Type: Task
> Components: Metadata
> Affects Versions: 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 1.0, 1.1, 1.2, 1.3
> Reporter: Martin Desruisseaux
> Assignee: Martin Desruisseaux
> Priority: Major
> Fix For: 1.4
>
>
> 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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)