We get the following error when doing some xml-stuff (having [com.fasterxml.jackson.core/jackson-core "2.12.3"] [org.clojure/data.xml "0.2.0-alpha6"] [clj-xml-validation "1.0.2"] as xml-related libs, WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by clojure.lang.InjectedInvoker/0x00000008401e8040 (file:/home/X/Y/Z/local-m2/org/clojure/clojure/1.11.0-alpha1/clojure-1.11.0-alpha1.jar) to method http://com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(http://com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool) WARNING: Please consider reporting this to the maintainers of clojure.lang.InjectedInvoker/0x00000008401e8040 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release What can it be, what can we do about it?
I am not sure, but I would guess Java version
Try Java 8 or use different versions of libraries
We will keep the JDK version because of alpn-features etc. So far this is a warning, but it would be nice to get it sorted ofc
https://clojure.org/guides/faq#illegal_access gives some background on the issue
What is the access and assoc time complexity of a Clojure vector?
https://www.innoq.com/blog/st/2010/04/clojure-performance-guarantees/
It's O log32 n. Its a shallow tree with 32 element wide nodes. So maximum deepness would be 7. Assoc means creating up to 7 arrays of 32 elements, on huge vectors.
Note that this reports as Clojure because itโs a code generated by Clojure but thatโs probably not the actual source. Use the debug setting talked about there to pinpoint the actual source
Itโs wherever newSchema is being called - adding a type hint to the interface is probably sufficient there
Probably here https://github.com/rkday/clj-xml-validation/blob/69bbe6d7d0f2ec7348fa6ccc801b427ee4849875/src/uk/me/rkd/xml_validation.clj#L14
Can somebody point me to the Clojure source locโs where vectors are implemented?
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/APersistentVector.java
I am looking at clj-http
and I am trying to understand the retry logic; is there anything included about backoffs, retries on specific status codes?
Something on the same line of https://findwork.dev/blog/advanced-usage-python-requests-timeouts-retries-hooks/#retry-on-failure โ which is very very well done
:retry-handler
is what you're after - it doesn't do much but you can plug in your own retry logic there
Yeah I noticed about it. Iโm just lazy to write all that kind of logic that is built in the Python library :trollface:
There might be some repos/gists laying - worth searching, you can turn the problem inside out and use libs like https://github.com/joelittlejohn/clj-http-hystrix (or something simpler)
@ps Its pretty complex code. https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentVector.java (APersistentVector is a abstract) If your goal is to understanding the algorithm I think I made a simpler to understand implementation in F#, lacking some features like e.g. transients. It doesn't use boxing and is hence homogeneously typed. https://github.com/stefanvstein/fsgrit/blob/master/Vector/Vector.fs. Rich has made excellent videos on how it works.
Oh that looks interesting, thank you
https://github.com/joegallo/robert-bruce or https://github.com/BrunoBonacci/safely are also available as generic retry libs
Hi there, how can we get the namespace of a function? Is there any way to achieve this from this context using alter-var-root?
(defn my-wrapping-fn
[function]
(alter-var-root function
(fn [f]
(fn [& n]
(let [f-namespace ??? ;; want to get f's namesapce here
result (apply f n)]
result)))))
@mrivas616 Usually only vars carry the namespace metadata, so you'd have to retain a reference to the var, not the function it holds
But if you have that, then it's (:ns (meta the-var))
e.g.:
user=> (:ns (meta #'inc))
#object[clojure.lang.Namespace 0x75f2099 "clojure.core"]
you can call ns-name
on that to get clojure.core
as a symbol
Gotcha, thanks ๐ :thumbsup:
there is a hack to retrieve the ns symbol from the munged function name, but it's a bit of a low level / possibly unsupported hack. it's used in clojure.spec.alpha
you can call .ns
on the var as well as getting it from the metadata
not really portable across implementations though but maybe that's not a concern
Is there any reason/advantage on using (clojure.lang.Compiler/demunge)
instead of (clojure.main/demunge)
? :thinking_face: taking a look at the code in clojure.spec.alpha
That might possibly be an optimization. That's only a guess. Got a link to the code?
Yeah, I was thinking the same :thinking_face: here is the code for context: https://github.com/clojure/spec.alpha/blob/master/src/main/clojure/clojure/spec/alpha.clj#L135
namespaces are a property of a function
a function is a value, like the number 5
when you (def x 5)
5 doesn't know about about x and doesn't know about the namespace x is in