Announcement Announcement Module
No announcement yet.
LTW for multiple classloaders Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • LTW for multiple classloaders


    A few days ago I found out one specific problem. I use LTW in my project, everything was fine till I started using two classloaders (one more classloader is created to load new classes dynamically). So new classes are not woven. I tried to patch parent classloader to load new classes into it, but at the moment I haven't found the solution. It's possible to invoke defineClass() via reflection, but still that approach will fail if a loaded class extends another one from loaded classes. And I don't think it's a good solution to patch the classloader).

    My question is how can I add one more classloader for Spring to apply class transformers and use LTW? I know I can invoke .setClassLoader() for ApplicationContext, but it will lose all the classes from the main classloader.

    Another solution is to create a patched classloader with overriden loadClass() and findClass() and load it with -Djava.system.class.loader property, but it looks ugly a bit..

    Yes, I know, that loading classes dynamically by-hand is not a good choice, don't ask me why, I'm looking forward to rewriting it using osgi, but still I'd like to solve that problem.