Is it possible to inspect classes without triggering static initialisation?
Posted on 2008-10-23
We're using the chain of command design pattern and are in the process of creating a visualization tool for the commands. This allows us to see the execution path(s) the chain provides. We've got most of it working but there are a couple of classes which is causing headache. These classes have static members which, when we use Class.forClass(className) to load up for use with reflection, are then initialised. Because certain components are not available (transport and config related) these fail with a fatal error and the program stops.
Is there a way to inspect classes without triggering the static initalisation? More specifically, what I need to know is if any of the class' superclasses are the generic in-house created command class.
Both source and class files are available. I could for example create the javadoc and use that but it's a bit convoluted and I'm wondering if there's a better solution out there?