Package javassist

Examples of javassist.ClassPool


    catch (IOException e) {
      LOG.unableToBuildEnhancementMetamodel( className );
      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 ) );
    }
    catch (IOException e) {
      throw new RuntimeException( e.getMessage(), e );
    }
View Full Code Here


  private ClassLoader parent;
  private ClassPool classPool;

  TransformingClassLoader(ClassLoader parent, String[] classpaths) {
    this.parent = parent;
    this.classPool = new ClassPool( true );
    for ( String classpath : classpaths ) {
      try {
        classPool.appendClassPath( classpath );
      }
      catch (NotFoundException e) {
View Full Code Here

  private ClassLoader parent;
  private ClassPool classPool;

  /*package*/ TransformingClassLoader(ClassLoader parent, String[] classpath) {
    this.parent = parent;
    classPool = new ClassPool( true );
    for ( int i = 0; i < classpath.length; i++ ) {
      try {
        classPool.appendClassPath( classpath[i] );
      }
      catch ( NotFoundException e ) {
View Full Code Here

  private ClassLoader parent;
  private ClassPool classPool;

  /*package*/ TransformingClassLoader(ClassLoader parent, String[] classpath) {
    this.parent = parent;
    classPool = new ClassPool( true );
    for ( int i = 0; i < classpath.length; i++ ) {
      try {
        classPool.appendClassPath( classpath[i] );
      }
      catch ( NotFoundException e ) {
View Full Code Here

  
   CtClass getCtClass(Class<?> clazz)
   {
      try
      {
         ClassPool pool = repository.findClassPool(clazz.getClassLoader());
         return pool.get(clazz.getName());
      }
      catch (NotFoundException e)
      {
         throw new RuntimeException("Unable to load CtClass for " + clazz, e);
      }
View Full Code Here

    * and returns true if it either does not exist in the parent or if
    * the parent has a different URL for the resource
    */
   protected boolean isSameInParent(String classResourceName, URL foundURL)
   {
      ClassPool  parent = pool.getParent();
      if (parent != null)
      {
         ClassLoader parentLoader = parent.getClassLoader();
         URL parentURL = parentLoader.getResource(classResourceName);
         if (parentURL == null)
         {
            return false;
         }
View Full Code Here

      throw new EnhancementException( "Could not prepare Javassist ClassPool", e );
    }
  }

  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

  }

  ClassPool pool;
 
  public Javassist () {
    pool = new ClassPool(null);
  }
View Full Code Here

    } catch (ClassNotFoundException e1) {
      // ok, continue
    }

    final Set<CtMethod> used = new HashSet<>();
    ClassPool pool = ClassPool.getDefault();
    CtClass inter = pool.makeInterface(interfaceName);
   
    try {
      CtClass returnType = pool.get(String.class.getName());
      CtClass objectType = pool.get(Object.class.getName());

      for (Method m : getMethods(controller)) {
        String name = m.getName();

        CtClass[] params = createParameters(objectType, m.getParameterTypes().length);
View Full Code Here

     }
  }
 
  @PreDestroy
  public void removeGeneratedClasses() {
    ClassPool pool = ClassPool.getDefault();
    for (Class<?> clazz : interfaces.values()) {
      CtClass ctClass = pool.getOrNull(clazz.getName());
      if (ctClass != null) {
        ctClass.detach();
        logger.debug("class {} is detached", clazz.getName());
      }
    }
View Full Code Here

TOP

Related Classes of javassist.ClassPool

Copyright © 2018 www.massapicom. 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.