/** * Create an interface using the current set of method signatures. */ public Class create() { setUseCache(false); return (Class)super.create(this); }
protected Object create(Object key) { try { ClassLoader loader = getClassLoader(); Map<ClassLoader, ClassLoaderData> cache = CACHE; ClassLoaderData data = cache.get(loader); Object obj = data.get(this, getUseCache()); if (obj instanceof Class) { return firstInstance((Class) obj); return nextInstance(obj); } catch (RuntimeException e) { throw e;
public CreateInfo(Class c1, Class c2) { this.c1 = c1; this.c2 = c2; AbstractClassGenerator fromEnhancer = AbstractClassGenerator.getCurrent(); if (fromEnhancer != null) { namingPolicy = fromEnhancer.getNamingPolicy(); strategy = fromEnhancer.getStrategy(); attemptLoad = fromEnhancer.getAttemptLoad(); } } }
if (classLoader == null) { throw new IllegalStateException("ClassLoader is null while trying to define class " + getClassName() + ". It seems that the loader has been expired from a weak reference somehow. " + "Please file an issue at cglib's issue tracker."); String name = generateClassName(data.getUniqueNamePredicate()); data.reserveName(name); this.setClassName(name); gen = classLoader.loadClass(getClassName()); return gen; } catch (ClassNotFoundException e) { ProtectionDomain protectionDomain = getProtectionDomain(); synchronized (classLoader) { // just in case if (protectionDomain == null) {
ClassLoader loader = getClassLoader(); Map cache2 = null; cache2 = (Map)source.cache.get(loader); gen = loader.loadClass(getClassName()); } catch (ClassNotFoundException e) { byte[] b = strategy.generate(this); String className = ClassNameReader.getClassName(new ClassReader(b)); getClassNameCache(loader).add(className); gen = ReflectUtils.defineClass(className, b, loader); cache2.put(key, new WeakReference(gen)); return firstInstance(gen); } finally { CURRENT.set(save); return firstInstance(gen); } catch (RuntimeException e) { throw e;
final protected String getClassName() { if (className == null) className = getClassName(getClassLoader()); return className; }
public ClassLoader getClassLoader() { ClassLoader t = classLoader; if (t == null) { t = getDefaultClassLoader(); } if (t == null) { t = getClass().getClassLoader(); } if (t == null) { t = Thread.currentThread().getContextClassLoader(); } if (t == null) { throw new IllegalStateException("Cannot determine classloader"); } return t; }
private String getClassName(final ClassLoader loader) { final Set nameCache = getClassNameCache(loader); return namingPolicy.getClassName(namePrefix, source.name, key, new Predicate() { public boolean evaluate(Object arg) { return nameCache.contains(arg); } }); }
ClassLoader loader = getClassLoader(); Map cache2 = null; cache2 = (Map)source.cache.get(loader); gen = loader.loadClass(getClassName()); } catch (ClassNotFoundException e) { byte[] b = strategy.generate(this); String className = ClassNameReader.getClassName(new ClassReader(b)); getClassNameCache(loader).add(className); gen = ReflectUtils.defineClass(className, b, loader); cache2.put(key, new WeakReference(gen)); return firstInstance(gen); } finally { CURRENT.set(save); return firstInstance(gen); } catch (RuntimeException e) { throw e;
final protected String getClassName() { if (className == null) className = getClassName(getClassLoader()); return className; }
if (classLoader == null) { throw new IllegalStateException("ClassLoader is null while trying to define class " + getClassName() + ". It seems that the loader has been expired from a weak reference somehow. " + "Please file an issue at cglib's issue tracker."); String name = generateClassName(data.getUniqueNamePredicate()); data.reserveName(name); this.setClassName(name); gen = classLoader.loadClass(getClassName()); return gen; } catch (ClassNotFoundException e) { ProtectionDomain protectionDomain = getProtectionDomain(); synchronized (classLoader) { // just in case if (protectionDomain == null) {
public ClassLoader getClassLoader() { ClassLoader t = classLoader; if (t == null) { t = getDefaultClassLoader(); } if (t == null) { t = getClass().getClassLoader(); } if (t == null) { t = Thread.currentThread().getContextClassLoader(); } if (t == null) { throw new IllegalStateException("Cannot determine classloader"); } return t; }
private String getClassName(final ClassLoader loader) { final Set nameCache = getClassNameCache(loader); return namingPolicy.getClassName(namePrefix, source.name, key, new Predicate() { public boolean evaluate(Object arg) { return nameCache.contains(arg); } }); }
public CreateInfo(Class c1, Class c2) { this.c1 = c1; this.c2 = c2; AbstractClassGenerator fromEnhancer = AbstractClassGenerator.getCurrent(); if (fromEnhancer != null) { namingPolicy = fromEnhancer.getNamingPolicy(); strategy = fromEnhancer.getStrategy(); attemptLoad = fromEnhancer.getAttemptLoad(); } } }
public Object create() { String name = target.getName(); setNamePrefix(name); return super.create(name); }
ClassLoader loader = getClassLoader(); Map cache2 = null; cache2 = (Map)source.cache.get(loader); gen = loader.loadClass(getClassName()); } catch (ClassNotFoundException e) { byte[] b = strategy.generate(this); String className = ClassNameReader.getClassName(new ClassReader(b)); getClassNameCache(loader).add(className); gen = ReflectUtils.defineClass(className, b, loader); cache2.put(key, new WeakReference(gen)); return firstInstance(gen); } finally { CURRENT.set(save); return firstInstance(gen); } catch (RuntimeException e) { throw e;
protected Object create(Object key) { try { ClassLoader loader = getClassLoader(); Map<ClassLoader, ClassLoaderData> cache = CACHE; ClassLoaderData data = cache.get(loader); Object obj = data.get(this, getUseCache()); if (obj instanceof Class) { return firstInstance((Class) obj); return nextInstance(obj); } catch (RuntimeException e) { throw e;
final protected String getClassName() { if (className == null) className = getClassName(getClassLoader()); return className; }
public ClassLoader getClassLoader() { ClassLoader t = classLoader; if (t == null) { t = getDefaultClassLoader(); } if (t == null) { t = getClass().getClassLoader(); } if (t == null) { t = Thread.currentThread().getContextClassLoader(); } if (t == null) { throw new IllegalStateException("Cannot determine classloader"); } return t; }
private String getClassName(final ClassLoader loader) { final Set nameCache = getClassNameCache(loader); return namingPolicy.getClassName(namePrefix, source.name, key, new Predicate() { public boolean evaluate(Object arg) { return nameCache.contains(arg); } }); }