Load, Modify, Recompile, and Execute Java Classes with Spoon

Spoon is a Java program processor that allows one to analyze and transform Java source code. Spoon assumes that one writes "processors" that act on all occurrences of a particular program element prior to compilation and execution. I required a different approach for one of my research projects. Rather than transforming code prior to compilation, I needed to load classes, modify their source code, recompile the changes, and execute the modified code at runtime.

Spoon provided all of the necessary tools, but I needed to decouple them from Spoon's default processor-based usage. I have posted my solution below in hopes that others find the code useful.