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

Comparable exception thrown when (zoned-date-time) is invoked in a project built in graal native-image #55

Open
livtanong opened this issue May 14, 2020 · 3 comments

Comments

@livtanong
Copy link

Exception in thread "main" java.lang.ClassCastException: java_time.graph.Types cannot be cast to java.lang.Comparable
	at clojure.lang.Util.compare(Util.java:153)
	at clojure.lang.APersistentVector.compareTo(APersistentVector.java:439)
	at java.util.concurrent.ConcurrentHashMap.compareComparables(ConcurrentHashMap.java:732)
	at java.util.concurrent.ConcurrentHashMap$TreeBin.<init>(ConcurrentHashMap.java:2773)
	at java.util.concurrent.ConcurrentHashMap.treeifyBin(ConcurrentHashMap.java:2630)
	at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1063)
	at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1535)
	at java_time.potemkin.util$fast_memoize$fn__11705.invoke(util.clj:50)
	at java_time.graph$has_source_type_QMARK_$contains_src_types_QMARK___12015$fn__12016.invoke(graph.clj:279)
	at clojure.core$some.invokeStatic(core.clj:2701)
	at java_time.graph$has_source_type_QMARK_$contains_src_types_QMARK___12015.invoke(graph.clj:279)
	at clojure.core$some.invokeStatic(core.clj:2701)
	at java_time.graph$has_source_type_QMARK_.invokeStatic(graph.clj:282)
	at java_time.graph$fn__12042.invokeStatic(graph.clj:301)
	at java_time.graph$fn__12042.invoke(graph.clj:300)
	at java_time.potemkin.util$fast_memoize$fn__11705.invoke(util.clj:52)
	at java_time.graph$conversion_fn.invokeStatic(graph.clj:316)
	at java_time.zone$zoned_date_time.invokeStatic(zone.clj:152)

assignable? might be the problematic line since there is a > in line 72.

@dm3
Copy link
Owner

dm3 commented May 15, 2020

Line 72 is comparing two numbers, why is that a problem? I'm not sure what's going on after looking at the code for 10 minutes. Seems like Types must implement Comparable in order to get inserted into the cache ConcurrentHashMap. Not sure why this is happening under Graal.

Do you have any more ideas?

@livtanong
Copy link
Author

Re: Line 72, it's just what immediately stood out to me as an obvious comparator operation. i didn't put additional thought into understanding that code further.

As for ideas, I don't have much, but I did replace it with an invocation to the actual java.time constructor, ZonedDateTime. That succeeded in compilation.

Sorry I'm not much help on the matter >.< I don't have intimate knowledge of how graal works.

@andreyorst
Copy link

It seems that I've got the same problem when using local-date to construct date from string of given format, e.g. with only this code: (t/local-date "dd-MM-yyyy" "01-01-2000") in the -main function.

stack trace
Exception in thread "main" java.lang.ClassCastException: java_time.graph.Types cannot be cast to java.lang.Comparable
        at clojure.lang.Util.compare(Util.java:153)
        at clojure.lang.APersistentVector.compareTo(APersistentVector.java:439)
        at java.util.concurrent.ConcurrentHashMap.compareComparables(ConcurrentHashMap.java:739)
        at java.util.concurrent.ConcurrentHashMap$TreeBin.<init>(ConcurrentHashMap.java:2819)
        at java.util.concurrent.ConcurrentHashMap.treeifyBin(ConcurrentHashMap.java:2676)
        at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1068)
        at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1541)
        at java_time.potemkin.util$fast_memoize$fn__1361.invoke(util.clj:50)
        at java_time.graph.ConversionGraph$fn__1577.invoke(graph.clj:153)
        at clojure.core$filter$fn__5911.invoke(core.clj:2821)
        at clojure.lang.LazySeq.sval(LazySeq.java:42)
        at clojure.lang.LazySeq.seq(LazySeq.java:58)
        at clojure.lang.RT.seq(RT.java:535)
        at clojure.core$seq__5419.invokeStatic(core.clj:139)
        at clojure.core$reduce1.invokeStatic(core.clj:932)
        at clojure.core$set.invokeStatic(core.clj:4101)
        at clojure.core$set.invoke(core.clj:4093)
        at java_time.graph.ConversionGraph.equivalent_targets(graph.clj:154)
        at java_time.graph$graph_conversion_path.invokeStatic(graph.clj:193)
        at java_time.graph$graph_conversion_path.invoke(graph.clj:188)
        at java_time.graph$fn__1698.invokeStatic(graph.clj:303)
        at java_time.graph$fn__1698.invoke(graph.clj:300)
        at java_time.potemkin.util$fast_memoize$fn__1361.invoke(util.clj:52)
        at java_time.graph$conversion_fn.invokeStatic(graph.clj:316)
        at java_time.graph$conversion_fn.invoke(graph.clj:312)
        at java_time.local$local_date.invokeStatic(local.clj:12)
        at java_time.local$local_date.invoke(local.clj:12)
        at myapp.core$_main.invokeStatic(core.clj:223)
        at myapp.core$_main.doInvoke(core.clj:221)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at myapp.core.main(Unknown Source)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants