private static Type lookupType(String name) { try { return new Type(ClassPool.getDefault().get(name)); } catch (NotFoundException e) { throw new RuntimeException(e); } }
public ByteCodeReflectFactory() { try { ClassPool.doPruning = true; pool = ClassPool.getDefault(); objectConstructorInterface = pool.get(ObjectConstructor.class.getName()); } catch (NotFoundException e) { throw new RuntimeException("Error establishing reflection factory", e); } }
/** * Constructs a web server. * * @param port port number */ public AppletServer(int port) throws IOException, NotFoundException, CannotCompileException { this(ClassPool.getDefault(), new StubGenerator(), port); }
private ClassPool getClassPool(Type rootComponent) { ClassPool pool = rootComponent.clazz.getClassPool(); return pool != null ? pool : ClassPool.getDefault(); }
/** * Main method. * * @param args <code>args[0]</code> is the class file name. */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Usage: java javassist.tools.framedump <fully-qualified class name>"); return; } ClassPool pool = ClassPool.getDefault(); CtClass clazz = pool.get(args[0]); System.out.println("Frame Dump of " + clazz.getName() + ":"); FramePrinter.print(clazz, System.out); } }
public static ClassPool getClassPool(ClassLoader loader) { if (loader == null) { return ClassPool.getDefault(); } ClassPool pool = POOL_MAP.get(loader); if (pool == null) { pool = new ClassPool(true); pool.appendClassPath(new LoaderClassPath(loader)); POOL_MAP.put(loader, pool); } return pool; }
public static ClassPool getClassPool(ClassLoader loader) { if (loader == null) { return ClassPool.getDefault(); } ClassPool pool = POOL_MAP.get(loader); if (pool == null) { pool = new ClassPool(true); pool.appendClassPath(new LoaderClassPath(loader)); POOL_MAP.put(loader, pool); } return pool; }
/** * Singleton. */ private ScopedClassPoolRepositoryImpl() { classpool = ClassPool.getDefault(); // FIXME This doesn't look correct ClassLoader cl = Thread.currentThread().getContextClassLoader(); classpool.insertClassPath(new LoaderClassPath(cl)); }
public static CtClass type(Class<?> clazz) { try { return ClassPool.getDefault().get(clazz.getName()); } catch (NotFoundException e) { e.printStackTrace(); return voidType; } }
public static CtClass listType(String className) { try { return ClassPool.getDefault().get(className+"[]"); } catch (NotFoundException e) { e.printStackTrace(); return voidType; } } }
/** * Constructs a web server. * * @param port port number */ public AppletServer(int port) throws IOException, NotFoundException, CannotCompileException { this(ClassPool.getDefault(), new StubGenerator(), port); }
private static Type lookupType(String name) { try { return new Type(ClassPool.getDefault().get(name)); } catch (NotFoundException e) { throw new RuntimeException(e); } }
private ClassPool getClassPool(Type rootComponent) { ClassPool pool = rootComponent.clazz.getClassPool(); return pool != null ? pool : ClassPool.getDefault(); }
public CtClass getCtClass() { CtClass clazz = component.getCtClass(); if (clazz == null) return null; ClassPool pool = clazz.getClassPool(); if (pool == null) pool = ClassPool.getDefault(); String name = arrayName(clazz.getName(), dims); try { return pool.get(name); } catch (NotFoundException e) { throw new RuntimeException(e); } }
/** * Singleton. */ private ScopedClassPoolRepositoryImpl() { classpool = ClassPool.getDefault(); // FIXME This doesn't look correct ClassLoader cl = Thread.currentThread().getContextClassLoader(); classpool.insertClassPath(new LoaderClassPath(cl)); }
public static ClassPool getClassPool(ClassLoader loader) { if (loader == null) return ClassPool.getDefault(); ClassPool pool = POOL_MAP.get(loader); if (pool == null) { pool = new ClassPool(true); pool.appendClassPath(new LoaderClassPath(loader)); POOL_MAP.put(loader, pool); } return pool; }
@Override public CtClass getCtClass() { CtClass clazz = component.getCtClass(); if (clazz == null) return null; ClassPool pool = clazz.getClassPool(); if (pool == null) pool = ClassPool.getDefault(); String name = arrayName(clazz.getName(), dims); try { return pool.get(name); } catch (NotFoundException e) { throw new RuntimeException(e); } }
/** * Constructs a new class loader. */ public Loader() throws CannotCompileException, NotFoundException { super(); delegateLoadingOf("javassist.tools.reflect.Loader"); reflection = new Reflection(); ClassPool pool = ClassPool.getDefault(); addTranslator(pool, reflection); }
@Override public ResourceConfig register(final Object component) { final Object object = requireNonNull(component); Class<?> clazz = object.getClass(); // If a class gets passed through as an object, cast to Class and register directly if (component instanceof Class<?>) { return super.register((Class<?>) component); } else if (Providers.isProvider(clazz) || Binder.class.isAssignableFrom(clazz)) { // If jersey supports this component's class (including hk2 Binders), register directly return super.register(object); } else { // Else register a binder that binds the instance to its class type try { // Need to create a new subclass dynamically here because hk2/jersey // doesn't add new bindings for the same class ClassPool pool = ClassPool.getDefault(); CtClass cc = pool.makeClass(SpecificBinder.class.getName() + UUID.randomUUID()); cc.setSuperclass(pool.get(SpecificBinder.class.getName())); Object binderProxy = cc.toClass().getConstructor(Object.class, Class.class).newInstance(object, clazz); super.register(binderProxy); return super.register(clazz); } catch (Exception e) { throw new RuntimeException(e); } } }
/** * Constructs a new class loader. */ public Loader() throws CannotCompileException, NotFoundException { super(); delegateLoadingOf("javassist.tools.reflect.Loader"); reflection = new Reflection(); ClassPool pool = ClassPool.getDefault(); addTranslator(pool, reflection); }