[ 
https://issues.apache.org/jira/browse/LANG-1704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17748915#comment-17748915
 ] 

Gilles Sadowski commented on LANG-1704:
---------------------------------------

bq. That's never going to be true ...

IIUC, the OP said that the change broke his use-case.  Maybe we need more 
details on this but I can imagine that subverting the (strong) typing system is 
not a good idea (passing an "ImmutablePair<A,B>" that could not be immutable 
also breaks the caller's expectation).
That functionality may have been broken, independently of the change being 
binary and/or source compatible.
Immutable data-structures much simplify usage, with some trade-off (like no 
support for inheritance).

What was the intended functionality?
Why the class was previously "final"?
Depending on the answer, removing "final" was wrong, or name of the class was 
ill-chosen.

{quote}
 * Allow typed subclasses, for example, MyCustomPair extends ImmutablePair<Foo, 
Bar>
 * Allow inline subclasses, for example, new ImmutablePair(foo, bar) \{ some 
overrides } (handy when writing tests).
{quote}

AFAIK, this can be achieved through composition (more lines of code, sure) 
increasing encapsulation, and thus safety.  The latter is reduced when 
increasing visibility; doing so for the sake of unit tests is not good.


> ImmutablePair and ImmutableTriple implementation don't match final in Javadoc
> -----------------------------------------------------------------------------
>
>                 Key: LANG-1704
>                 URL: https://issues.apache.org/jira/browse/LANG-1704
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.tuple.*
>    Affects Versions: 3.13.0
>            Reporter: Dan Ziemba
>            Priority: Minor
>             Fix For: 3.13.1
>
>
> As of commons-lang3 3.13.0, the ImmutablePair and ImmutableTriple classes are 
> no longer final, even though their javadocs claim that they are. This is a 
> problem because you can now subclass those and, for example, make an 
> effectively mutable object that could be passed to a method with a parameter 
> of type ImmutablePair.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to