Hi
We have encountered an error when using the Java export functionality of Crystal Reports. This error occurs using the latest runtime available for download (crjava-runtime_12.2.219).
The error only occurs when using JRE that implements sorting via TimSort (i.e. JRE version 7 and higher). The stack trace is as follows:
com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Comparison method violates its general contract!---- Error code:-2147467259 Error code name:
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:895)
at java.util.TimSort.mergeAt(TimSort.java:512)
at java.util.TimSort.mergeForceCollapse(TimSort.java:453)
at java.util.TimSort.sort(TimSort.java:250)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1454)
at java.util.Collections.sort(Collections.java:175)
at com.crystaldecisions.reports.formatter.formatter.lightmodel.cellmodel.FCMCellModel.a(SourceFile:1234)
at com.crystaldecisions.reports.formatter.formatter.lightmodel.cellmodel.FCMCellModel.if(SourceFile:498)
at com.crystaldecisions.reports.formatter.formatter.lightmodel.cellmodel.FCMCellModel.<init>(SourceFile:245)
at com.crystaldecisions.reports.formatter.formatter.lightmodel.FCMFormattedContentModeller.getCellModel(SourceFile:157)
at com.crystaldecisions.reports.exporters.excel.Excel97Exporter.processFormattedContent(SourceFile:206)
at com.crystaldecisions.reports.formatter.export2.a.a(SourceFile:104)
at com.crystaldecisions.reports.formatter.export2.a.a(SourceFile:247)
at com.crystaldecisions.reports.formatter.export2.ExportSupervisorEx.if(SourceFile:642)
at com.crystaldecisions.reports.formatter.export2.ExportSupervisorEx.a(SourceFile:586)
at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.a(SourceFile:636)
at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.int(SourceFile:672)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.do(SourceFile:1943)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(SourceFile:660)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(SourceFile:166)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.a(SourceFile:528)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.call(SourceFile:526)
at com.crystaldecisions.reports.common.ThreadGuard.syncExecute(SourceFile:102)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.for(SourceFile:524)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.int(SourceFile:423)
at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(SourceFile:351)
at com.businessobjects.sdk.erom.jrc.a.a(SourceFile:54)
at com.businessobjects.sdk.erom.jrc.a.execute(SourceFile:67)
at com.crystaldecisions.proxy.remoteagent.RemoteAgent$a.execute(SourceFile:716)
at com.crystaldecisions.proxy.remoteagent.CommunicationChannel.a(SourceFile:125)
at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(SourceFile:537)
at com.crystaldecisions.sdk.occa.report.application.ds.a(SourceFile:186)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(SourceFile:1558)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(
This error does not occur when TimSort is disabled via the system property -Djava.util.Arrays.useLegacyMergeSort=true.
The issue is probably caused by a bug in the Crystal Reports engine where the comparator used at "com.crystaldecisions.reports.formatter.formatter.lightmodel.cellmodel.FCMCellModel.a(SourceFile:1234)" is not implemented correctly. We have seen this exception occur when a comparator does not return 0 when comparing two equal objects. This leads to the impossible scenario that a < b and b < a for two equal objects a and b. This bug is exposed by the TimSort algorithm that was introduced in Java 7. The comparator which may be causing the issue is com.crystaldecisions.reports.formatter.formatter.lightmodel.cellmodel.CMCellObject.LessCompComparator.
Is this a bug and is it likely to be fixed in a future release of the Crystal Reports Java runtime?