File: gcc/libjava/java/util/LinkedHashMap.java CVS Version: 1.6 When using "accessOrder"-based sorting in LinkedHashMap, the linked list appears to become broken after calling get(). I believe that this is due to a missing line in the access() function. I believe that the following line needs to be added after line 188: root.pred = this; This will relink "root.pred" to the "this" object which has been moved to the "tail" of the linked list. Otherwise, root.pred will point to the 2nd-from-the-tail element which breaks the semantics of the linked list used in the class. I will post some test code that exposes this problem shortly.
Do you have a testcase?
Created attachment 8309 [details] Java test case for LinkedHashMapEntry.access() bug Simply compile and run the class with gcj. The expected output should be: Key: 1 Key: 2 Key: 3 but the output I am getting is: Key: 1 Key: 2
Confirmed.
Created attachment 8310 [details] Fix for PR 20273 The attached patch fixes the problem. I verified with classpath/jamvm. No mauve testcase written yet.
Subject: Bug 20273 CVSROOT: /cvs/gcc Module name: gcc Changes by: tromey@gcc.gnu.org 2005-05-30 02:01:15 Modified files: libjava : ChangeLog libjava/java/util: LinkedHashMap.java Log message: 2005-05-29 Michael Koch <konqueror@gmx.de> PR libgcj/20273: * java/util/LinkedHashMap.java (access): Set 'root.pred'. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3638&r2=1.3639 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/util/LinkedHashMap.java.diff?cvsroot=gcc&r1=1.6&r2=1.7
Subject: Bug 20273 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: tromey@gcc.gnu.org 2005-05-30 02:02:03 Modified files: libjava : ChangeLog libjava/java/util: LinkedHashMap.java Log message: 2005-05-29 Michael Koch <konqueror@gmx.de> PR libgcj/20273: * java/util/LinkedHashMap.java (access): Set 'root.pred'. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.3391.2.79&r2=1.3391.2.80 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/java/util/LinkedHashMap.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.6&r2=1.6.2.1
I checked this in to 4.0, the trunk, and Classpath. I put the test case in Mauve. I'm not planning to put the fix into 3.4.x, but someone could if they wanted to.