/** * Create a ClassInjector for defining one class. The parent ClassLoader * used is the one which loaded the ClassInjector class. */ public static ClassInjector create() { return create(null, null); }
mInjector = ClassInjector.createExplicit(className, loader); } else { mInjector = ClassInjector.create(className, loader);
/** * Create a ClassInjector for defining one class. The prefix is optional, * which is used as the start of the auto-generated class name. If the * parent ClassLoader is not specified, it will default to the ClassLoader of * the ClassInjector class. * <p> * If the parent loader was used for loading injected classes, the new * class will be loaded by it. This allows auto-generated classes access to * package accessible members, as long as they are defined in the same * package. * * @param prefix optional class name prefix * @param parent optional parent ClassLoader */ public static ClassInjector create(String prefix, ClassLoader parent) { return create(prefix, parent, false); }
mInjector = ClassInjector.createExplicit(className, loader); } else { mInjector = ClassInjector.create(className, loader);
/** * Create a ClassInjector for defining one class with an explicit name. If * the parent ClassLoader is not specified, it will default to the * ClassLoader of the ClassInjector class. * <p> * If the parent loader was used for loading injected classes, the new * class will be loaded by it. This allows auto-generated classes access to * package accessible members, as long as they are defined in the same * package. * * @param name required class name * @param parent optional parent ClassLoader * @throws IllegalArgumentException if name is null */ public static ClassInjector createExplicit(String name, ClassLoader parent) { if (name == null) { throw new IllegalArgumentException("Explicit class name not provided"); } return create(name, parent, true); }
/** * Create a ClassInjector for defining one class. The parent ClassLoader * used is the one which loaded the ClassInjector class. */ public static ClassInjector create() { return create(null, null); }
/** * Create a ClassInjector for defining one class. The prefix is optional, * which is used as the start of the auto-generated class name. If the * parent ClassLoader is not specified, it will default to the ClassLoader of * the ClassInjector class. * <p> * If the parent loader was used for loading injected classes, the new * class will be loaded by it. This allows auto-generated classes access to * package accessible members, as long as they are defined in the same * package. * * @param prefix optional class name prefix * @param parent optional parent ClassLoader */ public static ClassInjector create(String prefix, ClassLoader parent) { return create(prefix, parent, false); }
/** * Create a ClassInjector for defining one class with an explicit name. If * the parent ClassLoader is not specified, it will default to the * ClassLoader of the ClassInjector class. * <p> * If the parent loader was used for loading injected classes, the new * class will be loaded by it. This allows auto-generated classes access to * package accessible members, as long as they are defined in the same * package. * * @param name required class name * @param parent optional parent ClassLoader * @throws IllegalArgumentException if name is null */ public static ClassInjector createExplicit(String name, ClassLoader parent) { if (name == null) { throw new IllegalArgumentException("Explicit class name not provided"); } return create(name, parent, true); }
Wrapper(Class<W> wrapper, Class<D> delegate) { mWrapperInfo = StorableIntrospector.examine(wrapper); mDelegateInfo = StorableIntrospector.examine(delegate); ClassLoader loader = wrapper.getClassLoader(); try { loader.loadClass(delegate.getName()); } catch (ClassNotFoundException e) { loader = delegate.getClassLoader(); try { loader.loadClass(wrapper.getName()); } catch (ClassNotFoundException e2) { // This could be fixed by creating an intermediate class loader, but // other issues might crop up. throw new IllegalStateException ("Unable for find common class loader for source and target types: " + wrapper.getClass() + ", " + delegate.getClass()); } } mClassInjector = ClassInjector.create(wrapper.getName(), loader); mClassFile = CodeBuilderUtil.createStorableClassFile (mClassInjector, mWrapperInfo.getStorableType(), false, StorableCopier.class.getName()); }
private StorableGenerator(Class<S> storableType) { mStorableType = storableType; mSupportType = TypeDesc.forClass(TriggerSupport.class); mInfo = StorableIntrospector.examine(storableType); mAllProperties = mInfo.getAllProperties(); mClassInjector = ClassInjector.create (storableType.getName(), storableType.getClassLoader()); mClassFile = CodeBuilderUtil.createStorableClassFile (mClassInjector, storableType, true, StorableGenerator.class.getName()); }
private StorableGenerator(Class<S> storableType) { mStorableType = storableType; mSupportType = TypeDesc.forClass(TriggerSupport.class); mInfo = StorableIntrospector.examine(storableType); mAllProperties = mInfo.getAllProperties(); mClassInjector = ClassInjector.create (storableType.getName(), storableType.getClassLoader()); mClassFile = CodeBuilderUtil.createStorableClassFile (mClassInjector, storableType, true, StorableGenerator.class.getName()); }
Wrapper(Class<W> wrapper, Class<D> delegate) { mWrapperInfo = StorableIntrospector.examine(wrapper); mDelegateInfo = StorableIntrospector.examine(delegate); ClassLoader loader = wrapper.getClassLoader(); try { loader.loadClass(delegate.getName()); } catch (ClassNotFoundException e) { loader = delegate.getClassLoader(); try { loader.loadClass(wrapper.getName()); } catch (ClassNotFoundException e2) { // This could be fixed by creating an intermediate class loader, but // other issues might crop up. throw new IllegalStateException ("Unable for find common class loader for source and target types: " + wrapper.getClass() + ", " + delegate.getClass()); } } mClassInjector = ClassInjector.create(wrapper.getName(), loader); mClassFile = CodeBuilderUtil.createStorableClassFile (mClassInjector, mWrapperInfo.getStorableType(), false, StorableCopier.class.getName()); }
private DelegateStorableGenerator(Class<S> type, EnumSet<MasterFeature> features) throws SupportException { mStorableType = type; final Class<? extends S> abstractClass = MasterStorableGenerator.getAbstractClass(mStorableType, features); mClassInjector = ClassInjector.create(mStorableType.getName(), abstractClass.getClassLoader()); mClassFile = new ClassFile(mClassInjector.getClassName(), abstractClass); mClassFile.markSynthetic(); mClassFile.setSourceFile(DelegateStorableGenerator.class.getName()); mClassFile.setTarget("1.5"); }
private DelegateStorableGenerator(Class<S> type, EnumSet<MasterFeature> features) throws SupportException { mStorableType = type; final Class<? extends S> abstractClass = MasterStorableGenerator.getAbstractClass(mStorableType, features); mClassInjector = ClassInjector.create(mStorableType.getName(), abstractClass.getClassLoader()); mClassFile = new ClassFile(mClassInjector.getClassName(), abstractClass); mClassFile.markSynthetic(); mClassFile.setSourceFile(DelegateStorableGenerator.class.getName()); mClassFile.setTarget("1.5"); }
private MasterStorableGenerator(Class<S> storableType, EnumSet<MasterFeature> features) { mFeatures = features; mInfo = StorableIntrospector.examine(storableType); mAllProperties = mInfo.getAllProperties(); final Class<? extends S> abstractClass = StorableGenerator.getAbstractClass(storableType); mClassInjector = ClassInjector.create (storableType.getName(), abstractClass.getClassLoader()); mClassFile = new ClassFile(mClassInjector.getClassName(), abstractClass); mClassFile.setModifiers(mClassFile.getModifiers().toAbstract(true)); mClassFile.markSynthetic(); mClassFile.setSourceFile(MasterStorableGenerator.class.getName()); mClassFile.setTarget("1.5"); }
private MasterStorableGenerator(Class<S> storableType, EnumSet<MasterFeature> features) { mFeatures = features; mInfo = StorableIntrospector.examine(storableType); mAllProperties = mInfo.getAllProperties(); final Class<? extends S> abstractClass = StorableGenerator.getAbstractClass(storableType); mClassInjector = ClassInjector.create (storableType.getName(), abstractClass.getClassLoader()); mClassFile = new ClassFile(mClassInjector.getClassName(), abstractClass); mClassFile.setModifiers(mClassFile.getModifiers().toAbstract(true)); mClassFile.markSynthetic(); mClassFile.setSourceFile(MasterStorableGenerator.class.getName()); mClassFile.setTarget("1.5"); }
private Class<T> createWrapper() { ClassInjector ci = ClassInjector.create(); ClassFile cf = new ClassFile(ci.getClassName()); cf.addInterface(mType);
private Class<T> createWrapper() { ClassInjector ci = ClassInjector.create(); ClassFile cf = new ClassFile(ci.getClassName()); cf.addInterface(mType);
Class<? extends C> buildClass() { ClassInjector ci = ClassInjector .create(mConverterType.getName(), mConverterType.getClassLoader());
Class<? extends C> buildClass() { ClassInjector ci = ClassInjector .create(mConverterType.getName(), mConverterType.getClassLoader());