Can I debug a plugin that uses a custom classloader?
I have a plugin architecture for my app and it uses a custom classloader for each plugin. Is it possible to debug these plugins? The plugins are executed by calling loadClass() on the custom classloader.
Please sign in to leave a comment.
Hello Jordan,
Of course. How would we be able to debug IntelliJ IDEA itself if this wasn't
possible? :)
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
How do I do it then? Is there an IDEA API I can use? I don't see anyway in the UI to set the source path for a non-classpath JAR.
IDEA is an application. I don't see how it applies.
* bump *
Please?
Jordan Zimmerman wrote:
If you were to explain the problem you are trying to solve a bit more
fully maybe you'd get some help? What you've asked so far hasn't made
too much sense to me... What exactly are you trying to do? What are the
actual issues you're seeing?
N.
I have a JAR file on disk. I've written a custom ClassLoader that loads the JAR. Using that custom ClassLoader I call loadClass() to get a Class instance and then, using reflection, run code from the JAR. My question is can I debug the code in that JAR? Is there an IDEA API or config setting I can use?
You have to add the sources for this JAR to your project. There's no
possibility to debug without source code.
Jordan Zimmerman wrote:
--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com
Where do I attach the source? What you're suggesting requires me to compile the classes which would then include them in the CLASSPATH which defeats the purpose of having a separate JAR.
You can add an additional module to your project, where you place your plugin sources inside a source directory. As long as you don't specify a dependency to this module the sources won't get compiled and the module isn't added to your classpath. But they are recognized as sources and you can debug them, no matter from where the classes are loaded.
Hey! That's a good idea. I'll give it a try.
That works. Thanks.