Package javassist

Examples of javassist.ClassPool.appendClassPath()


    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


    @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(Thread.currentThread().getContextClassLoader()));
        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

  private ClassPool buildClassPool(EnhancementContext enhancementContext) {
    final ClassPool classPool = new ClassPool( false );
    final ClassLoader loadingClassLoader = enhancementContext.getLoadingClassLoader();
    if ( loadingClassLoader != null ) {
      classPool.appendClassPath( new LoaderClassPath( loadingClassLoader ) );
    }
    return classPool;
  }

  /**
 
View Full Code Here

      return classfileBuffer;
    }

    final ClassPool cp = new ClassPool();
    cp.appendSystemPath();
    cp.appendClassPath( new ClassClassPath( this.getClass() ) );
    cp.appendClassPath( new ClassClassPath( classfile.getClass() ) );

    try {
      cp.makeClassIfNew( new ByteArrayInputStream( classfileBuffer ) );
    }
View Full Code Here

    }

    final ClassPool cp = new ClassPool();
    cp.appendSystemPath();
    cp.appendClassPath( new ClassClassPath( this.getClass() ) );
    cp.appendClassPath( new ClassClassPath( classfile.getClass() ) );

    try {
      cp.makeClassIfNew( new ByteArrayInputStream( classfileBuffer ) );
    }
    catch (IOException e) {
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

  }

  @Nonnull
  private 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);
  }

  private static boolean isAnnotated( @Nonnull CtMethod method, @Nonnull Class<? extends Annotation> annotationType ) throws ClassNotFoundException {
View Full Code Here

      log.info("jdk14 throwable count: "+throwables14.size());

      String jdk5Jar = args[1];
      JarFile jdk5JarFile = new JarFile(jdk5Jar);
      ClassPool jdk5Pool = new ClassPool();
      jdk5Pool.appendClassPath(jdk5Jar);
      CtClass jdk5Throwable = jdk5Pool.get("java.lang.Throwable");
      HashMap<String, CtClass> throwables5 = new HashMap<String, CtClass>();
      scanJar(jdk5JarFile, jdk5Pool, jdk5Throwable, throwables5);
      log.info("jdk5 throwable count: "+throwables5.size());
View Full Code Here

         throw new IllegalArgumentException("Usage: FindExceptionCtorChanges path-to-jdk14/rt.jar path-to-jdk15/rt.jar");

      String jdk14Jar = args[0];
      JarFile jdk14JarFile = new JarFile(jdk14Jar);
      ClassPool jdk14Pool = new ClassPool();
      jdk14Pool.appendClassPath(jdk14Jar);
      CtClass jdk14Throwable = jdk14Pool.get("java.lang.Throwable");
      HashMap<String, CtClass> throwables14 = new HashMap<String, CtClass>();
      scanJar(jdk14JarFile, jdk14Pool, jdk14Throwable, throwables14);
      log.info("jdk14 throwable count: "+throwables14.size());
View Full Code Here

      }
      urls = paths.toArray(new URL[paths.size()]);
      ClassLoader poolLoader = new URLClassLoader(urls, EmptyClassLoader.EMPTY);
     
      ClassPool pool = new ClassPool(false);
      pool.appendClassPath(new CheckerClassPath(poolLoader));
      pool.appendClassPath(new ClassClassPath(Object.class));
     
      //Add all the classes to compile
      for (File f : files)
      {
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.