Fork me on GitHub
#clojure
<
2021-06-11
>
Linus Ericsson09:06:59

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?

kwladyka09:06:10

I am not sure, but I would guess Java version

kwladyka09:06:27

Try Java 8 or use different versions of libraries

Linus Ericsson10:06:27

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

Alex Miller (Clojure team)12:06:34

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

Alex Miller (Clojure team)12:06:10

It’s wherever newSchema is being called - adding a type hint to the interface is probably sufficient there

zendevil.eth10:06:48

What is the access and assoc time complexity of a Clojure vector?

stefanvstein10:06:11

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.

zendevil.eth15:06:45

Can somebody point me to the Clojure source loc’s where vectors are implemented?

stefanvstein16:06:25

@U01F1TM2FD5 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.

vncz16:06:13

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?

lukasz16:06:28

:retry-handler is what you're after - it doesn't do much but you can plug in your own retry logic there

vncz16:06:21

Yeah I noticed about it. I’m just lazy to write all that kind of logic that is built in the Python library trollface

lukasz16:06:19

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)

vncz16:06:02

Oh that looks interesting, thank you

Miguel Rivas18:06:43

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)))))

hiredman20:06:48

namespaces are a property of a function

hiredman20:06:08

a function is a value, like the number 5

hiredman20:06:52

when you (def x 5) 5 doesn't know about about x and doesn't know about the namespace x is in

borkdude18:06:18

@mrivas616 Usually only vars carry the namespace metadata, so you'd have to retain a reference to the var, not the function it holds

borkdude18:06:53

But if you have that, then it's (:ns (meta the-var))

borkdude18:06:29

e.g.:

user=> (:ns (meta #'inc))
#object[clojure.lang.Namespace 0x75f2099 "clojure.core"]

borkdude18:06:11

you can call ns-name on that to get clojure.core as a symbol

Miguel Rivas18:06:37

Gotcha, thanks 😄 :thumbsup:

borkdude18:06:23

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

😮 2
👀 2
Miguel Rivas19:06:17

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

blak3mill3r19:06:32

That might possibly be an optimization. That's only a guess. Got a link to the code?

Miguel Rivas19:06:34

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

Alex Miller (Clojure team)02:06:50

I don't actually remember, but probably just avoiding the clojure.main require

Alex Miller (Clojure team)02:06:58

this is no longer needed in spec 2

Alex Miller (Clojure team)02:06:45

(because things stay symbolic without being eval'ed to a function object)

❤️ 3
Ed18:06:19

you can call .ns on the var as well as getting it from the metadata

👋 2
borkdude18:06:27

not really portable across implementations though but maybe that's not a concern

👍 2