digama0 / mmj2

mmj2 GUI Proof Assistant for the Metamath project
GNU General Public License v2.0
72 stars 25 forks source link

IllegalArgumentException on starting mmj2 #71

Open avekens opened 1 year ago

avekens commented 1 year ago

Since recently, an IllegalArgumentException is thrown on starting mmj2. The start of the application is aborted afterwards:

Here is the stack trace from the cmd console:

I-UT-0015 **** Processing RunParmFile Command #20 = RunProofAsstGUI
I-PA-0412 Excluded these assertions from Unification search list as requested on input RunParm: [dummylink]
Comparison method violates its general contract!
java.lang.IllegalArgumentException: Comparison method violates its general contract!
        at java.util.ComparableTimSort.mergeHi(Unknown Source)
        at java.util.ComparableTimSort.mergeAt(Unknown Source)
        at java.util.ComparableTimSort.mergeCollapse(Unknown Source)
        at java.util.ComparableTimSort.sort(Unknown Source)
        at java.util.Arrays.sort(Unknown Source)
        at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
        at sun.awt.shell.ShellFolder.get(Unknown Source)
        at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.addItem(Unknown Source)
        at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.access$800(Unknown Source)
        at javax.swing.plaf.metal.MetalFileChooserUI.doDirectoryChanged(Unknown Source)
        at javax.swing.plaf.metal.MetalFileChooserUI.access$1100(Unknown Source)
        at javax.swing.plaf.metal.MetalFileChooserUI$5.propertyChange(Unknown Source)
        at java.beans.PropertyChangeSupport.fire(Unknown Source)
        at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
        at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
        at java.awt.Component.firePropertyChange(Unknown Source)
        at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source)
        at javax.swing.JFileChooser.setSelectedFile(Unknown Source)
        at mmj.pa.ProofAsstGUI.buildMMTFolderChooser(ProofAsstGUI.java:538)
        at mmj.pa.ProofAsstGUI.<init>(ProofAsstGUI.java:257)
        at mmj.pa.ProofAsst.doGUI(ProofAsst.java:200)
        at mmj.util.ProofAsstBoss.doRunProofAsstGUI(ProofAsstBoss.java:1031)
        at mmj.util.Boss.lambda$putCommand$0(Boss.java:107)
        at mmj.util.Boss.doRunParmCommand(Boss.java:121)
        at mmj.util.BatchFramework.executeRunParmCommand(BatchFramework.java:281)
        at mmj.util.BatchFramework.runIt(BatchFramework.java:223)
        at mmj.util.BatchMMJ2.main(BatchMMJ2.java:53)
Comparison method violates its general contract!

I still use mmj2 v2.4.1 as of 26-Jan-2016, currently with Java version 1.8.0_371 (there was an update on 15-Sep-2023!). Is it possible that the Java update causes this problem? Or did any change within my file system caused it (root cause for the exception within mmj2 is at mmj.pa.ProofAsstGUI.buildMMTFolderChooser(ProofAsstGUI.java:538)).

There are many hints on stackoverflow (https://stackoverflow.com/questions/11441666/java-error-comparison-method-violates-its-general-contract), even remarks on Java versions.

avekens commented 1 year ago

Updating java again to version 1.8.0_381 and cleaning the directory myproofs did not help...

avekens commented 1 year ago

I have copied everything to another computer with Java version 1.8.0_311, and here everything works fine. Therefore, I assume it's the Java version which causes the problem.

avekens commented 11 months ago

Yesterday, another Java update was performed (java version 1.8.0_391), and now mmj2 is working again. Maybe there was something wrong with versions 1.8.0_371 and 1.8.0_381...

avekens commented 11 months ago

I was too quick to close this issue. Unfortunately, the problem is still existing, even with java version 1.8.0_391

tirix commented 11 months ago

Googling the issue, here is the issue tracked in JDK: https://bugs.openjdk.org/browse/JDK-8305072 Until it is fixed, it looks like there is a workaround:

System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");

I'd say we try that!

avekens commented 11 months ago

@tirix thank you very much for this hint. I added the corresponding JVM parameter (-Djava.util.Arrays.useLegacyMergeSort=true), and now it works (again):

java -Xincgc -Xms512M -Xmx1024M -Djava.util.Arrays.useLegacyMergeSort=true -jar mmj2.jar RunParms.txt Y "" c:\Users\Alexander\Documents\metamath ""

tirix commented 11 months ago

That's great! Ideally this should be added to the repository's mmj2\mmj2jar\mmj2.bat file. I suggest keeping this PR opened until done.