private void cleanMetaClassOfClass(MetaClassRegistryImpl registry) { Set<Class> classes = new HashSet<Class>(alteredClasses.keySet()); for (Class aClass : classes) { Object alteredMetaClass = alteredClasses.get(aClass); if (alteredMetaClass == NO_CUSTOM_METACLASS) { registry.removeMetaClass(aClass); } else { registry.setMetaClass(aClass, (MetaClass) alteredMetaClass); } } alteredClasses.clear(); }
private void cleanMetaClassOfInstance(MetaClassRegistryImpl registry) { List<IdentityWeakReference> keys = new ArrayList<IdentityWeakReference>(alteredInstances.keySet()); for (IdentityWeakReference key : keys) { Object instance = key.get(); if (instance != null) { Object alteredMetaClass = alteredInstances.get(key); if (alteredMetaClass == NO_CUSTOM_METACLASS) { alteredMetaClass = null; } registry.setMetaClass(instance, (MetaClass) alteredMetaClass); } } alteredInstances.clear(); }