You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sis.apache.org by "Martin Desruisseaux (Jira)" <ji...@apache.org> on 2023/01/02 09:41:00 UTC

[jira] [Updated] (SIS-566) Remove instantiation of primitive wrappers

     [ https://issues.apache.org/jira/browse/SIS-566?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Desruisseaux updated SIS-566:
------------------------------------
    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.

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.


  was:
In the {{org.apache.sis.xml.NilReason}} class, the private {{createNilPrimitive(Class)]] method instantiate new {{Boolean}}, {{Byte}}, {{Short}}, {{Integer}}, {{Long}}, {{Float}} or {{Double}} object by invoking directly their constructor. The {{valueOf(…)}} method can not be used in this context, because we really need new instances. They are used for identifying a particular instances as a nil object.

This pattern will soon not work anymore, because those primitive wrappers will become _value object_. The constructors that we are invoking will be removed, and the identity comparison that we rely on will not work anymore.

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.



> 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
>            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.
> 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)