use of soot.plugins.SootPhasePlugin in project soot by Sable.
the class PluginLoader method handlePhasePlugin.
/**
* Loads the phase plugin and adds it to PackManager.
* @param pluginDescription the plugin description instance read from configuration file.
*/
private static void handlePhasePlugin(final PhasePluginDescription pluginDescription) {
try {
final Object instance = PluginLoader.loadStrategy.create(pluginDescription.getClassName());
if (!(instance instanceof SootPhasePlugin)) {
throw new RuntimeException("The plugin class '" + pluginDescription.getClassName() + "' does not implement SootPhasePlugin.");
}
final SootPhasePlugin phasePlugin = (SootPhasePlugin) instance;
phasePlugin.setDescription(pluginDescription);
final String packName = getPackName(pluginDescription.getPhaseName());
Transform transform = new Transform(pluginDescription.getPhaseName(), phasePlugin.getTransformer());
transform.setDeclaredOptions(concat(appendEnabled(phasePlugin.getDeclaredOptions())));
transform.setDefaultOptions(concat(phasePlugin.getDefaultOptions()));
PackManager.v().getPack(packName).add(transform);
} catch (final ClassNotFoundException e) {
throw new RuntimeException("Failed to load plugin class for " + pluginDescription + ".", e);
} catch (final InstantiationException e) {
throw new RuntimeException("Failed to instanciate plugin class for " + pluginDescription + ".", e);
}
}
Aggregations