sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Desruisseaux (JIRA)" <>
Subject [jira] [Created] (SIS-156) @ThreadSafe and @Immutable annotation usages are misleading
Date Mon, 23 Dec 2013 17:17:52 GMT
Martin Desruisseaux created SIS-156:

             Summary: @ThreadSafe and @Immutable annotation usages are misleading
                 Key: SIS-156
             Project: Spatial Information Systems
          Issue Type: Bug
          Components: Metadata, Referencing, Utilities
    Affects Versions: 0.3
            Reporter: Martin Desruisseaux
            Assignee: Martin Desruisseaux
            Priority: Minor
             Fix For: 0.4

Many SIS classes having {{@ThreadSafe}} or {{@Immutable}} annotation are only tainted: the
annotation applies only in a shallow sense. For example {{ImmutableIdentifier}} is truly immutable
only if the {{Citation}} given to the constructor is also immutable - this citation is not
cloned, since doing so would be potentially very costly (metadata tree can be depth). Furthermore,
we can not force subclasses to honour the immutability contract.

The {{@ThreadSafe}} and {{@Immutable}} annotations are strongly inspired from the _Java concurrency
in practice_ book, which uses a stricter interpretation of immutability: an immutable class
can reference only immutable objects (or primitive types), or clone them. A search on internet
suggests that most other libraries having such annotations interpret them in the stricter

The majority of SIS classes do not conform to the strict interpretation of immutability. This
is because many objects are aggregations of other objects for which the type is an interface.
We can not impose immutability or thread-safety constraints on implementations of interfaces.
Consequently for the majority of SIS classes, the thread-safety behaviour is more complicated
than a binary "thread-safe / not thread safe" or "immutable / mutable" binary choice.

The proposal is to simply drop the {{@ThreadSafe}} and {{@Immutable}} annotations from SIS,
and replace them by a paragraph in class javadoc.

This message was sent by Atlassian JIRA

View raw message