Package javassist.bytecode

Examples of javassist.bytecode.ClassFile


    }

    private void addAnnotation(Annotation annotation)
    {
       
        final ClassFile classFile = getClassFile();
       
        AnnotationsAttribute attribute = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleTag);
       
        if (attribute == null)
        {
            attribute = new AnnotationsAttribute(getConstPool(), AnnotationsAttribute.visibleTag);
        }
       
        final javassist.bytecode.annotation.Annotation copy = toJavassistAnnotation(annotation);
       
       
        attribute.addAnnotation(copy);
       
        classFile.addAttribute(attribute);
       
    }
View Full Code Here


   }

   protected void deployElement(InputStream stream, Ejb3HandlerFactory factory, InitialContext ctx) throws Exception
   {
      DataInputStream dstream = new DataInputStream(new BufferedInputStream(stream));
      ClassFile cf = null;
      try
      {
         cf = new ClassFile(dstream);
      }
      finally
      {
         dstream.close();
         stream.close();
View Full Code Here

      }
      DataInputStream dstream = new DataInputStream(stream);

      try
      {
         return new ClassFile(dstream);
      }
      finally
      {
         dstream.close();
         stream.close();
View Full Code Here

   }

   protected void deployElement(InputStream stream, Ejb3HandlerFactory factory, InitialContext ctx) throws Exception
   {
      DataInputStream dstream = new DataInputStream(new BufferedInputStream(stream));
      ClassFile cf = null;
      try
      {
         cf = new ClassFile(dstream);
      }
      finally
      {
         dstream.close();
         stream.close();
View Full Code Here

   }

   protected void deployElement(InputStream stream, Ejb3HandlerFactory factory, InitialContext ctx) throws Exception
   {
      DataInputStream dstream = new DataInputStream(new BufferedInputStream(stream));
      ClassFile cf = null;
      try
      {
         cf = new ClassFile(dstream);
      }
      finally
      {
         dstream.close();
         stream.close();
View Full Code Here

      }
   }

   private void copyAnnotations(CtClass src, CtClass dest) throws NotFoundException
   {
      ClassFile srcFile = src.getClassFile2();
      ClassFile destFile = dest.getClassFile2();
      copyAnnotations(srcFile, destFile, AnnotationsAttribute.invisibleTag);
      copyAnnotations(srcFile, destFile, AnnotationsAttribute.visibleTag);
   }
View Full Code Here

      }
   }
  
   private void copySignature(CtClass src, CtClass dest)
   {
      ClassFile srcFile = src.getClassFile2();
      ClassFile destFile = dest.getClassFile2();
     
      SignatureAttribute sig = (SignatureAttribute)srcFile.getAttribute(SignatureAttribute.tag);
      if (sig != null)
      {
         destFile.addAttribute(sig.copy(destFile.getConstPool(), EMPTY_HASHMAP));
      }
   }
View Full Code Here

      ClassLoader loader,
      String className,
      Class classBeingRedefined,
      ProtectionDomain protectionDomain,
      byte[] classfileBuffer) {
    ClassFile classfile;
    try {
      // WARNING: classfile only
      classfile = new ClassFile( new DataInputStream( new ByteArrayInputStream( classfileBuffer ) ) );
    }
    catch (IOException e) {
      log.error( "Unable to build enhancement metamodel for " + className );
      return classfileBuffer;
    }
    FieldTransformer transformer = getFieldTransformer( classfile );
    if ( transformer != null ) {
      if ( log.isDebugEnabled() ) {
        log.debug( "Enhancing " + className );
      }
      DataOutputStream out = null;
      try {
        transformer.transform( classfile );
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        out = new DataOutputStream( byteStream );
        classfile.write( out );
        return byteStream.toByteArray();
      }
      catch (Exception e) {
        log.error( "Unable to transform class", e );
        throw new HibernateException( "Unable to transform class: " + e.getMessage() );
View Full Code Here

    filter = f;
  }

  public void transform(File file) throws Exception {
    DataInputStream in = new DataInputStream(new FileInputStream(file));
    ClassFile classfile = new ClassFile(in);
    transform(classfile);
    DataOutputStream out = new DataOutputStream(new FileOutputStream(file));
    try {
      classfile.write(out);
    } finally {
      out.close();
    }
  }
View Full Code Here

    private final byte[] bytes;
    private final ClassFile classFile;

    public CustomClassDescriptor(byte[] bytes) throws IOException {
      this.bytes = bytes;
      this.classFile = new ClassFile( new DataInputStream( new ByteArrayInputStream( bytes ) ) );
    }
View Full Code Here

TOP

Related Classes of javassist.bytecode.ClassFile

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.