Object key = keyFactory.newInstance(cls, interfaces, wreplace, delegating);  Class result = (Class) map.get(key);
Class result = null;  synchronized( cls ){
    private static Object enhanceHelper(boolean delegating,                                        Object obj,                                        Class cls,                                        Class[] interfaces,                                        MethodInterceptor ih,                                        ClassLoader loader,                                        Method wreplace) {        if (ih == null) {            throw new IllegalArgumentException("MethodInterceptor is null");        }        if (cls != null && obj != null && !cls.isAssignableFrom(obj.getClass())) {            throw new IllegalArgumentException("Class must be same class or superclass of delegate");        }        if (cls == null) {            if (obj == null) {                cls = Object.class;            } else {                cls = obj.getClass();            }        }        if (loader == null) {            loader = Enhancer.class.getClassLoader();        }        Map map = (Map)cache.get(loader);        if (map == null) {            map = new Hashtable();            cache.put(loader, map);        }        Object key = keyFactory.newInstance(cls, interfaces, wreplace, delegating);                Class result = (Class) map.get(key);        if ( result == null ) {            String class_name = cls.getName() + CLASS_SUFFIX;            if (class_name.startsWith("java")) {                class_name = CLASS_PREFIX + class_name;            }            class_name += index++;            result = new EnhancerGenerator(class_name, cls, interfaces, ih, loader, wreplace, delegating).define();            map.put(key, result);        }                Factory factory = (Factory)factories.get(result);        if (factory == null) {            try {                Class mi = Class.forName(MethodInterceptor.class.getName(), true, loader);                if (delegating) {                    factory = (Factory)result.getConstructor(new Class[]{ mi, Object.class })                        .newInstance(new Object[] { null, null });                } else {                    factory = (Factory)result.getConstructor(new Class[]{ mi })                        .newInstance(new Object[] { null });                }                factories.put(result,factory);            } catch (RuntimeException e) {                throw e;            } catch (Exception e) {                throw new CodeGenerationException(e);            }        }        if (delegating) {            return factory.newInstance(ih, obj);        } else {            return factory.newInstance(ih);        }    }