Is there any way to get the calling classloader in...
# announcements
c
Is there any way to get the calling classloader in an package level util function?
g
Copy code
this::class.java.classLoader
c
Oh wait, sorry I meant in a util package level function
Yikerz
@gcx11 Any ideas?
d
Thread.currentThread.contextClassLoader is usually what you want.
c
Would creating an empty object instead create overhead @diesieben07?
d
You mean
object : Any() {}::class.java.classLoader
?
c
Yeah
d
The JVM will most likely optimize the instance creation away, yes
c
So that's a good way of doing it?
d
Not really. It obscures what you are doing
c
Oh alright