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; }
/** * Constructs a web server. * * @param port port number * @param src the source of classs files. */ public AppletServer(int port, ClassPool src) throws IOException, NotFoundException, CannotCompileException { this(new ClassPool(src), new StubGenerator(), port); }
/** * Constructs a web server. * * @param port port number * @param src the source of classs files. */ public AppletServer(int port, ClassPool src) throws IOException, NotFoundException, CannotCompileException { this(new ClassPool(src), new StubGenerator(), port); }
public static void init() { catchReflectException = false; isLogging = true; isManual = false; patchPackageName = Constants.PATCH_PACKAGENAME; mappingFilePath = DEFAULT_MAPPING_FILE; patchMethodSignatureSet = new HashSet<>(); newlyAddedClassNameList = new ArrayList<String>(); modifiedClassNameList = new ArrayList<String>(); hotfixPackageList = new ArrayList<>(); newlyAddedMethodSet = new HashSet<>(); invokeSuperMethodMap = new HashMap<>(); classPool = new ClassPool(); methodNeedPatchSet = new HashSet(); addedSuperMethodList = new ArrayList<>(); noNeedReflectClassSet = new HashSet<>(); noNeedReflectClassSet.addAll(Constants.NO_NEED_REFLECT_CLASS); supportProGuard=true; }
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; }
defaultPool = new ClassPool(null); defaultPool.appendSystemPath();
int i = name.lastIndexOf('.'); String className = i < 0 ? name : name.substring(i + 1); ClassPool pool = new ClassPool(true); pool.appendClassPath(new LoaderClassPath(ClassHelper.getCallerClassLoader(getClass()))); Matcher matcher = IMPORT_PATTERN.matcher(source);
int i = name.lastIndexOf('.'); String className = i < 0 ? name : name.substring(i + 1); ClassPool pool = new ClassPool(true); pool.appendClassPath(new LoaderClassPath(ClassHelper.getCallerClassLoader(getClass()))); Matcher matcher = IMPORT_PATTERN.matcher(source);
defaultPool = new ClassPool(null); defaultPool.appendSystemPath();
@SneakyThrows public Proxy(Class<I> superClass, String... classPathString) { if (superClass == null) { throw new NullPointerException("superClass can not be null"); } this.superClass = superClass; ClassPool classPool = new ClassPool(true); ClassPath classPath = new ClassClassPath(this.getClass()); classPool.insertClassPath(classPath); if (classPathString != null) { for (String path : classPathString) { classPool.insertClassPath(path); } } className = superClass.getSimpleName() + "FastBeanCopier" + counter.getAndAdd(1); classFullName = superClass.getPackage() + "." + className; ctClass = classPool.makeClass(classFullName); if (superClass != Object.class) { if (superClass.isInterface()) { ctClass.setInterfaces(new CtClass[]{classPool.get(superClass.getName())}); } else { ctClass.setSuperclass(classPool.get(superClass.getName())); } } addConstructor("public " + className + "(){}"); }
@SuppressWarnings({"deprecation"}) protected static Object makeDummyObject (String className) { try { ClassLoader isolation = new ClassLoader() {}; ClassPool cp = new ClassPool(); cp.insertClassPath(new ClassClassPath(Dummy.class)); CtClass clazz = cp.get(Dummy.class.getName()); clazz.setName(className); return clazz.toClass(isolation).newInstance(); } catch ( Exception e ) { e.printStackTrace(); return new byte[0]; } }
int i = name.lastIndexOf('.'); String className = i < 0 ? name : name.substring(i + 1); ClassPool pool = new ClassPool(true); pool.appendClassPath(new LoaderClassPath(ClassHelper.getCallerClassLoader(getClass()))); Matcher matcher = IMPORT_PATTERN.matcher(source);
int i = name.lastIndexOf('.'); String className = i < 0 ? name : name.substring(i + 1); ClassPool pool = new ClassPool(true); pool.appendClassPath(new LoaderClassPath(ClassHelper.getCallerClassLoader(getClass()))); Matcher matcher = IMPORT_PATTERN.matcher(source);
try { ClassPool pool = new ClassPool(true); ArrayList<JarEntry> entries = new ArrayList<JarEntry>(); String[] splits = jars.split(",");
public static void main(String... args) throws Exception { classPool = new ClassPool(); classPool.importPackage("java.sql"); classPool.appendClassPath(new LoaderClassPath(JavassistProxyFactory.class.getClassLoader())); if (args.length > 0) { genDirectory = args[0]; } // Cast is not needed for these String methodBody = "{ try { return delegate.method($$); } catch (SQLException e) { throw checkException(e); } }"; generateProxyClass(Connection.class, ProxyConnection.class.getName(), methodBody); generateProxyClass(Statement.class, ProxyStatement.class.getName(), methodBody); generateProxyClass(ResultSet.class, ProxyResultSet.class.getName(), methodBody); // For these we have to cast the delegate methodBody = "{ try { return ((cast) delegate).method($$); } catch (SQLException e) { throw checkException(e); } }"; generateProxyClass(PreparedStatement.class, ProxyPreparedStatement.class.getName(), methodBody); generateProxyClass(CallableStatement.class, ProxyCallableStatement.class.getName(), methodBody); modifyProxyFactory(); }
private ClassPool getClassPool() { if (classPool == null) { synchronized (this) { classPool = new ClassPool(); ClassLoader[] classLoaders = getConfiguration().getClassLoaders(); if (classLoaders == null) { classLoaders = ClasspathHelper.classLoaders(); } for (ClassLoader classLoader : classLoaders) { classPool.appendClassPath(new LoaderClassPath(classLoader)); } } } return classPool; } }
private ClassPool getClassPool() { if (classPool == null) { synchronized (this) { classPool = new ClassPool(); ClassLoader[] classLoaders = getConfiguration().getClassLoaders(); if (classLoaders == null) { classLoaders = ClasspathHelper.classLoaders(); } for (ClassLoader classLoader : classLoaders) { classPool.appendClassPath(new LoaderClassPath(classLoader)); } } } return classPool; } }
public static List<Method> getDeclaredMethods(Class<?> clazz) { ClassPool cp = new ClassPool(); cp.insertClassPath(new ClassClassPath(clazz)); CtClass cc; try { cc = cp.get(clazz.getName()); } catch (NotFoundException e) { throw U.rte("Cannot find the target class!", e); } List<Method> methods = U.list(); for (CtMethod m : cc.getDeclaredMethods()) { try { methods.add(getMethod(clazz, m.getName(), ctTypes(m.getParameterTypes()))); } catch (Exception e) { throw U.rte(e); } } return methods; }
ClassPool classPool = new ClassPool(); classPool.appendClassPath(new LoaderClassPath(loader)); final CtClass ctClass;