bcdev / jpy

A bi-directional Python-Java bridge used to embed Java in CPython or the other way round.
Apache License 2.0
187 stars 37 forks source link

get_type from currentThread.getContextClassLoader().loadClass() #169

Open zokrezyl opened 5 years ago

zokrezyl commented 5 years ago

get_type uses FindClass for finding/loading classes. This will not find however classes loaded by frameworks like spring. Something like below works, but I have to rewrite part of the decoration that is part of jpy I understand:

  Thread = jpy.get_type("java.lang.Thread")                                            
  current_thread = Thread.currentThread()                                              
  class_loader = current_thread.getContextClassLoader() 
class_loader.loadClass("com.some.spring.class")

Would be interesting to have an argument for get_type that would force get_type to try to load classes from the threads class loader, or simply pass the classloader.

Opinion?