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.

12 comments
Comment actions Permalink

Hello Jordan,

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.


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!"


0
Comment actions Permalink

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.

0
Comment actions Permalink

Of course. How would we be able to debug IntelliJ IDEA itself if this wasn't
possible?

IDEA is an application. I don't see how it applies.

0
Comment actions Permalink

Jordan Zimmerman wrote:

Please?

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.

0
Comment actions Permalink

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?

0
Comment actions Permalink

You have to add the sources for this JAR to your project. There's no
possibility to debug without source code.

Jordan Zimmerman wrote:

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 u
se?

---
Original message URL: http://www.jetbrains.net/devnet/message/5231821#5231821


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0
Comment actions Permalink

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.

0
Comment actions Permalink

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.

0
Comment actions Permalink

Hey! That's a good idea. I'll give it a try.

0
Comment actions Permalink

That works. Thanks.

0

Please sign in to leave a comment.