Re: Java API type hint question

2016-02-04 Thread Gary Verhaegen
The part within brackets does not exist outside the Java compiler, i.e. at the bytecode level, it is really just a Collection, not a Collection. If you're interested, you can google "java type erasure" to learn more about this. On Wednesday, 27 January 2016, Ritchie Cai

Re: Java API type hint question

2016-01-26 Thread Michael Willis
What's not practical about quoting? I thought it was considered more idiomatic than doing (list ...) On Sunday, January 17, 2016 at 2:48:29 PM UTC-6, Ritchie Cai wrote: > > Hi all, > > I'm trying to create a Java ArrayList object from a Clojure collection to > pass to another Java API. I get

Re: Java API type hint question

2016-01-26 Thread Ritchie Cai
Quoting for small example like I mention is not an issue, but in general, I need to pass an vector or list, since that's what I get, in which case I cannot quote. On Tuesday, January 26, 2016 at 3:52:17 PM UTC-6, Michael Willis wrote: > > What's not practical about quoting? I thought it was

Re: Java API type hint question

2016-01-26 Thread Beau Fabry
Tell the compiler that the type you're passing to the constructor is a Collection, so it will know which constructor to use without reflection. (set! *warn-on-reflection* true) => true (import '(java.util ArrayList Collection)) => java.util.Collection (ArrayList. (list 1 2)) Reflection warning,

Re: Java API type hint question

2016-01-26 Thread Gary Trakhman
Just because no else has said it yet, clojure vectors, lists and seqs all implement the read part of the interface java.util.List, and your java API should most likely be refactored to use the List interface instead of ArrayList if it isn't already. If that's the case, and it's not trying to

Re: Java API type hint question

2016-01-26 Thread Ritchie Cai
Ahh, thanks. I was wondering how to specify Collection https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html>>, but looks like just Collection will work. On Tuesday, January 26, 2016 at 4:57:53 PM UTC-6, Beau

Re: Java API type hint question

2016-01-26 Thread Ritchie Cai
Good to know, thanks. On Tuesday, January 26, 2016 at 5:11:48 PM UTC-6, Gary Trakhman wrote: > > Just because no else has said it yet, clojure vectors, lists and seqs all > implement the read part of the interface java.util.List, and your java API > should most likely be refactored to use the

Java API type hint question

2016-01-17 Thread Ritchie Cai
Hi all, I'm trying to create a Java ArrayList object from a Clojure collection to pass to another Java API. I get reflection warnings when the elements are not primitive types, in this case I'm using SparseIndexedVector class from vectorz library. (ArrayList. [c0 c1 c2]) Reflection warning,