Developing Eclipse Plugins – utilities using Reflection to check Classes in other Projects

The main thing in my opinion that the Eclipse Platform has going for it is that it was designed from the ground up to be extensible, and the support for developing plugins to run on the platform really is second to none (although I have yet to look at the plugin support in Netbeans 5.x).

This week however I had a utility that I needed to convert to a plugin to take advantage of the Search functionality in Eclipse to check references to existing code. The code for the utility that I needed to convert also uses Reflection to check for properties of certain type, and then invoke their ‘getters’ to ensure that the properties ave been initialized correctly. Unfortunately, gaining access to the Classpath of other Projects in the Workspace and then using a Class.forName() to load and instantiate the Class is a complete nightmare. I found plenty of posts of other people trying to do the same thing, with no definte answers. I think I found my solution from a chapter in an Eclipse Plugin book that I have, that suggests writing a custom Classloader to load the Classes for you. This seems a bit heavy handed but it looks like it does the job.

I’ll plan on summarizes this approach here in the next week or so.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.