Package javassist

Examples of javassist.ClassPool.insertClassPath()


     * @return the Javassist class gen
     */
    private static CtClass fromByte(final String name, final byte[] bytecode, final ClassLoader loader) {
        try {
            ClassPool cp = new ClassPool(null);
            cp.insertClassPath(new ByteArrayClassPath(name, bytecode));
            cp.appendClassPath(new LoaderClassPath(loader));
            CtClass klass = cp.get(name);
            klass.stopPruning(true);// to allow dump
            return klass;
        } catch (Exception e) {
View Full Code Here


     * @return the Javassist class gen
     */
    public static CtClass fromByte(final String name, final byte[] bytecode, final 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

  }
 
  @Override
  public void execute(Set<File> files) {
    ClassPool cp = ClassPool.getDefault();
    cp.insertClassPath(new ClassClassPath(this.getClass()));
    try {
      for (File file : files) {
        cp.makeClass(new FileInputStream(file));
      }
    } catch (IOException e) {
View Full Code Here

    }
   
    // return a javassist handle for the class
    String javaClassFileName = Descriptor.toJavaName( deobfClassName );
    ClassPool classPool = new ClassPool();
    classPool.insertClassPath( new ByteArrayClassPath( javaClassFileName, data ) );
    try
    {
      return classPool.get( javaClassFileName );
    }
    catch( NotFoundException ex )
View Full Code Here

      buf = data.toByteArray();
     
      // load the javassist handle to the raw class
      String javaClassFileName = Descriptor.toJavaName( classFileName );
      ClassPool classPool = new ClassPool();
      classPool.insertClassPath( new ByteArrayClassPath( javaClassFileName, buf ) );
      CtClass c = classPool.get( javaClassFileName );
     
      c = transformClass( c );
     
      // sanity checking
View Full Code Here

   
    // re-get the javassist handle since we changed class names
    ClassEntry obfClassEntry = new ClassEntry( Descriptor.toJvmName( c.getName() ) );
    String javaClassReconstructedName = Descriptor.toJavaName( obfClassEntry.getName() );
    ClassPool classPool = new ClassPool();
    classPool.insertClassPath( new ByteArrayClassPath( javaClassReconstructedName, c.toBytecode() ) );
    c = classPool.get( javaClassReconstructedName );
   
    // check that the file is correct after inner class reconstruction (ie cause Javassist to fail fast if something is wrong)
    assertClassName( c, obfClassEntry );
   
View Full Code Here

    }
   
    // get a javassist handle for the class
    String className = Descriptor.toJavaName( getClassEntry( entry ).getName() );
    ClassPool classPool = new ClassPool();
    classPool.insertClassPath( new ByteArrayClassPath( className, bos.toByteArray() ) );
    return classPool.get( className );
  }
 
  private static ClassEntry getClassEntry( JarEntry entry )
  {
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.