JabRef version
Latest development branch build (please note build date below)
Operating system
Windows
Details on version and operating system
Windows 11 Home 25H2 26200.8457, Jabref forked and built on 22/05/2026
Checked with the latest development build (copy version output from About dialog)
Steps to reproduce the behaviour
- Add the below JabRefBug2.java file to base "jabref" folder
// Bug 2: SharedBibEntryData violates Comparable/equals consistency
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.SharedBibEntryData;
public class JabRefBug2 {
public static void main(String[] args) {
BibEntry entry1 = new BibEntry();
BibEntry entry2 = new BibEntry("hi!");
SharedBibEntryData data1 = entry1.getSharedBibEntryData();
SharedBibEntryData data2 = entry2.getSharedBibEntryData();
boolean isCompareZero = (data1.compareTo(data2) == 0);
boolean isEqual = data1.equals(data2);
// If compareTo is 0, equals() MUST be true. This prints false, exposing the bug.
System.out.println("Contract upheld? " + (isCompareZero == isEqual));
}
}
- Compile it using below command:
javac -cp "jablib\build\classes\java\main;jablib\build\dependencies\*" JabRefBug2.java
- Run it using below command:
C:\git-repositories\jabref>java -cp ".;jablib\build\classes\java\main;jablib\build\dependencies\*" JabRefBug2
Current output:
Contract upheld? false
Appendix
Found this bug using automated contract testing with Randoop and tested using above Minimal Reproducible Example (MRE). The SharedBibEntryData class implements the Comparable interface. The official Java documentation strictly advises that x.compareTo(y) == 0 should have the exact same boolean result as x.equals(y). Randoop found instances where two SharedBibEntryData objects are considered "equal" by compareTo, but "not equal" by .equals() (or vice versa). This will cause sorting algorithms (like Collections.sort()) to behave unpredictably in the JabRef UI.
JabRef version
Latest development branch build (please note build date below)
Operating system
Windows
Details on version and operating system
Windows 11 Home 25H2 26200.8457, Jabref forked and built on 22/05/2026
Checked with the latest development build (copy version output from About dialog)
Steps to reproduce the behaviour
javac -cp "jablib\build\classes\java\main;jablib\build\dependencies\*" JabRefBug2.javaC:\git-repositories\jabref>java -cp ".;jablib\build\classes\java\main;jablib\build\dependencies\*" JabRefBug2Current output:
Contract upheld? false
Appendix
Found this bug using automated contract testing with Randoop and tested using above Minimal Reproducible Example (MRE). The SharedBibEntryData class implements the Comparable interface. The official Java documentation strictly advises that x.compareTo(y) == 0 should have the exact same boolean result as x.equals(y). Randoop found instances where two SharedBibEntryData objects are considered "equal" by compareTo, but "not equal" by .equals() (or vice versa). This will cause sorting algorithms (like Collections.sort()) to behave unpredictably in the JabRef UI.