Hey, initially I posted a question here https://clojurians.slack.com/archives/C03S1KBA2/p1734978232607819 (Clojure channel). The solution works for visitMethod on org.objectweb.asm.ClassWriter but trying to apply the same approach for method visitVarInsn on org.objectweb.asm.MethodWriter does not work. Here is my current reflection.json file
[
{
"name": "org.objectweb.asm.MethodWriter",
"methods": [
{
"name": "visitVarInsn"
}
]
"allDeclaredMethods": true
},
{
"name": "org.objectweb.asm.ClassWriter",
"methods": [
{
"name": "visitMethod"
}
]
}
]
The error is still:
> No matching method visitVarInsn found taking 2 args for class org.objectweb.asm.MethodWriter
Any advice here?
ThanksWhy do you have:
"allDeclaredMethods": true
?the method visitVarInsn isn't a declared class on that class, FWIW
but it seems like this is unrelated and it should work nonetheless. Do you know where the reflection is being made in the codde?
just try things from chatGPT 🙂
let me try find it
the reference method on asm is here: https://github.com/consulo/objectweb-asm/blob/master/asm/src/main/java/org/objectweb/asm/MethodWriter.java#L909
that's not what I was asking for
I meant the callsite, sorry for not being clear
yes, I know, I just point to the method
If you control the code, you could try to avoid the reflection in the first place
you mean, the code where I call the visitVarInsn ?
yes
I call it inside a multimethod
Are you familiar with type hints and *warn-on-reflection* ?
I know about it, but never used,
I can try
That should be your first tool, if you fix all the warnings, then you won't need a reflect config at all probably
looks perfect, I will try it
e.g. here:
(.visit cw Opcodes/V1_8 Opcodes/ACC_PUBLIC class-name nil "java/lang/Object" nil)
you should hint the cw binding with a type hint, e.g.:
(defn foo [^ClassWriter cw])
and also put (set! *warn-on-reflection* true) at the top of your namespace
if you then evaluate the code, you'll get warnings
I will try and let you know, thanks a lot for now
also check out https://github.com/clj-easy/graal-docs
Thanks @borkdude using the type hint it works as expected without the reflection.json