Package javassist

Examples of javassist.ClassPool.appendClassPath()


    @Override
    public Class<?> doCompile(String name, String source) throws Throwable {
        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);
        List<String> importPackages = new ArrayList<String>();
        Map<String, String> fullNames = new HashMap<String, String>();
        while (matcher.find()) {
            String pkg = matcher.group(1);
View Full Code Here


    if (clazzProxy == null) {

      ClassPool pool = new ClassPool();
      CtClass ctChieldClass = pool.getOrNull(chieldClassName);

      pool.appendClassPath(new LoaderClassPath(classLoader));
      CtClass ctSuperClass = pool.get(superClassName);

      ctChieldClass = pool.getAndRename(ConfigurationImpl.class.getCanonicalName(), chieldClassName);
      ctChieldClass.setSuperclass(ctSuperClass);
View Full Code Here

  private ClassPool createPool(List<File> classpath) throws NotFoundException {
    final ClassPool pool = new ClassPool(true);

    // set up the classpath for the classpool
    for (File f : this.sources) {
      pool.appendClassPath(f.toString());
    }

    return pool;
  }
View Full Code Here

    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;
  }
View Full Code Here

     */
    public static CtClass fromByte(String name, final byte[] bytecode, ClassLoader loader) {
        try {
            ClassPool cp = new ClassPool(null);
            cp.insertClassPath(new ByteArrayClassPath(name, bytecode));
            cp.appendClassPath(new LoaderClassPath(loader));
            return cp.get(name);
        }
        catch (Exception e) {
            throw new WrappedRuntimeException(e);
        }
View Full Code Here

    public byte[] transform(final ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
        final ClassLoader previous = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(loader);
        try {
            ClassPool pool = new ClassPool();
            pool.appendClassPath(new LoaderClassPath(loader));
            CtClass clazz = pool.makeClass(new ByteArrayInputStream(classfileBuffer));
            if (isAlreadyTransformed(clazz) == false) {
                log.info("Transforming " + className + " with " + getClass().getSimpleName());
                transform(clazz);
            } else {
View Full Code Here

    final ClassPool pool = new ClassPool(true);

    // set up the classpath for the classpool
    if (classpath != null) {
      for (File f : this.classpath) {
        pool.appendClassPath(f.toString());
      }
    }

    // add the files to process
    for (File f : this.sources) {
View Full Code Here

      }
    }

    // add the files to process
    for (File f : this.sources) {
      pool.appendClassPath(f.toString());
    }
    return pool;
  }

  // preloads all class files into the classpool and stores a list of class names
View Full Code Here

  }

  @Nonnull
  protected static CtClass getCtClass( @Nonnull final ClassLoader loader, @Nonnull String className ) throws NotFoundException {
    final ClassPool pool = new ClassPool(true);
    pool.appendClassPath(new LoaderClassPath(loader));

    return pool.get(className);
  }

  protected static void insertAssertedVerificationCodeBefore( @Nonnull CtMethod method, @Nonnull String verificationCode ) throws CannotCompileException {
View Full Code Here

    */
   protected ClassPool createClassPool(VFSDeploymentUnit unit)
   {
      ClassPool pool = new ClassPool();
      ClassPath deploymentPath = new DeploymentUnitClassPath(unit);
      pool.appendClassPath(deploymentPath);
      // fall back to classloader classpath
      ClassPath classPath = new LoaderClassPath(unit.getClassLoader());
      pool.appendClassPath(classPath);
      return pool;
   }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.