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

Alex Herbert commented on COLLECTIONS-842:
------------------------------------------

Note: The NodeCachingLinkedList may be obsolete. This caches nodes for reuse to 
avoid garbage collection. There is a method to compare performance against 
LinkedList (NodeCachingLinkedListTest.compareSpeed). On my machine the output 
is consistently faster with LinkedList:
{noformat}
Time with LinkedList: 205 ms
Time with NodeCachingLinkedList: 363 ms
Time with LinkedList: 204 ms
Time with NodeCachingLinkedList: 327 ms
Time with LinkedList: 146 ms
Time with NodeCachingLinkedList: 394 ms
Time with LinkedList: 60 ms
Time with NodeCachingLinkedList: 472 ms
Time with LinkedList: 160 ms
Time with NodeCachingLinkedList: 321 ms
{noformat}
Changing to use AbstractLinkedList in place of LinkedList (requires 
modification of the {{ll}} list in the code):
{code:java}
final AbstractLinkedList<Object> ll = new AbstractLinkedList() {};
ll.init();
{code}
{noformat}
Time with LinkedList: 447 ms
Time with NodeCachingLinkedList: 429 ms
Time with LinkedList: 428 ms
Time with NodeCachingLinkedList: 492 ms
Time with LinkedList: 317 ms
Time with NodeCachingLinkedList: 523 ms
Time with LinkedList: 483 ms
Time with NodeCachingLinkedList: 516 ms
Time with LinkedList: 314 ms
Time with NodeCachingLinkedList: 517 ms
{noformat}
This shows the NodeCachingLinkedList is worse than the JDK default LinkedList 
and typically has worse performance than the collections AbstractLinkedList on 
which it is based.

This suggests that duplication of classes to be compatible with JDK 21 should 
ignore the NodeCachingLinkedList. Subject to further performance benchmarks on 
a spectrum of machines and JDKs, this class could be marked as deprecated.

 

> AbstractLinkedList apparently incompatible with JDK 21's java.util.List
> -----------------------------------------------------------------------
>
>                 Key: COLLECTIONS-842
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-842
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: List
>            Reporter: Julian Reschke
>            Priority: Major
>
> ...it returns "boolean" in commons-collections4, but is void in JDK 21 (see 
> https://download.java.net/java/early_access/jdk21/docs/api/java.base/java/util/List.html#addLast(E))



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

Reply via email to