Reflection: Can you test for InstantiationException before attempting to instantiate?
Hi All.
Is it possible to determine if a class can be instanciated at runtime, or in other words check at runtime to see if using reflection to instanciate it will throw an InstantiationException?
I'm building an XML configurable plugin arcitecture:
I want to allow the user to create a template for instanciating a plugin in one part of the XML and reference it else where to create the actual instances. This directly translates into building a typesafe "PluginFactory" for each template and saving them for later use.
The difficulty is that the user may make a mistake and add a template for an abstract class or interface etc. I want to detect this when the "PluginFactory" is being created, not when it is first used.