[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/80688] New: gnu.java.util.LRUCache is not LRU
From: |
guillerodriguez.dev at gmail dot com |
Subject: |
[Bug classpath/80688] New: gnu.java.util.LRUCache is not LRU |
Date: |
Tue, 09 May 2017 08:19:38 +0000 |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80688
Bug ID: 80688
Summary: gnu.java.util.LRUCache is not LRU
Product: classpath
Version: 0.99
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: classpath
Assignee: unassigned at gcc dot gnu.org
Reporter: guillerodriguez.dev at gmail dot com
Target Milestone: ---
According to the documentation, class gnu.java.util.LRUCache is "A least
recently used cache, based on LinkedHashMap".
However the only constructor of the class calls the no-arg constructor of the
superclass, LinkedHashMap, which by default creates an insertion-ordered
(instead of access-ordered) LinkedHashMap.
Thus when the LRUCache is full it will not discard the least recently used
items. Instead it will discard the first items that were inserted.
In order to behave as a LRU cache, an access-ordered LinkedHashMap must be
created:
public LRUCache(int cap)
{
- super();
+ super(11, 0.75f, true);
capacity = cap;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug classpath/80688] New: gnu.java.util.LRUCache is not LRU,
guillerodriguez.dev at gmail dot com <=