MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
for (Class<?> clazz : classes) {
originalMetaClasses.add(registry.getMetaClass(clazz));
MetaClass temporaryMetaClass = new ExpandoMetaClass(clazz, true, true);
temporaryMetaClass.initialize();
registry.setMetaClass(clazz, temporaryMetaClass);
}
try {
invocation.proceed();