Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalArgumentException thrown when serializing to RDF/XML using JDK 7 #7

Closed
ignazio1977 opened this issue May 26, 2013 · 0 comments
Closed
Assignees
Labels

Comments

@ignazio1977
Copy link
Contributor

With JDK 7 an exception is thrown when serializing to RDF/XML.

java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:868)
at java.util.TimSort.mergeAt(TimSort.java:485)
at java.util.TimSort.mergeForceCollapse(TimSort.java:426)
at java.util.TimSort.sort(TimSort.java:223)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at org.coode.owlapi.rdf.model.RDFGraph.getSortedTriplesForSubject(RDFGraph.java:123)
at org.coode.owlapi.rdf.rdfxml.RDFXMLRenderer.render(RDFXMLRenderer.java:193)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderEntity(RDFRendererBase.java:302)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderEntities(RDFRendererBase.java:294)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderClasses(RDFRendererBase.java:258)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderInOntologySignatureEntities(RDFRendererBase.java:242)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderOntologyComponents(RDFRendererBase.java:230)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.render(RDFRendererBase.java:215)
at org.coode.owlapi.rdf.rdfxml.RDFXMLOntologyStorer.storeOntology(RDFXMLOntologyStorer.java:86)
at org.semanticweb.owlapi.util.AbstractOWLOntologyStorer.storeOntology(AbstractOWLOntologyStorer.java:94)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.saveOntology(

It occurred with a version of CHEBI.

I think the issue is at the end of the compareTo() method:

if (diff == 0) {
diff = 1;
}
return diff;

This means that 0 will never be returned, so suppose there are two elements which are equal, i.e., in a distance you'd expect to get 0: a.compareTo(b) returns 1, and b.compareTo(a) returns 1 as well. If this is extended to three elements, then it's clear this is not transitive if the elements are close enough that diff is 0 at the end of the method, because it'd look like:
a<b b<c c<a.

The exception depends on JDK 7, as in this version a check for this condition was introduced, while the previous JDKs would ignore the condition and accept the wrong sorting obtained as a result.

@ghost ghost assigned ignazio1977 May 26, 2013
ignazio1977 added a commit that referenced this issue Aug 23, 2013
Java7 and #7 IllegalArgumentException thrown when serializing to RDF/XML
using JDK 7

The compare method needs revisiting still.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant