Welcome! Please see the About page for a little more info on how this works.

+3 votes
in data.xml by
retagged by

Is reflection necessary to encode or decode XML namespace names? This reflection is in a "definline", so it might be sailing into undesired headwinds.

This is with clojure.data.xml 0.2.0-alpha6, the latest that I saw on Maven Central; and OpenJDK 11.

Program:

(set! *warn-on-reflection* true)
(require '[clojure.data.xml :as data.xml])

Output:

Reflection warning, clojure/data/xml/jvm/name.clj:35:1 - call to static method decode on java.net.URLDecoder can't be resolved (argument types: unknown, java.lang.String).
Reflection warning, clojure/data/xml/jvm/name.clj:38:1 - call to static method encode on java.net.URLEncoder can't be resolved (argument types: unknown, java.lang.String).

I guess it would be safe and efficient to type-hint the "unknown" first parameter as a String. The URLEncoder/URLDecoder methods in question are overloaded, but the signatures all require a String as the first parameter.

2 Answers

0 votes
by
0 votes
by

You can't actually type-hint in an inline function like this (at inline time you get the lexical values which might be a literal string that can't take metadata), so the only simple fix is really to stop using an inlined function (not sure this is a good need for it anyways).

...