Package javassist.bytecode

Examples of javassist.bytecode.ClassFile


    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


      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

    Method[] setters = new Method[setterNames.length];
    findAccessors( targetBean, getterNames, setterNames, types, getters, setters );

    Class beanClass;
    try {
      ClassFile classfile = make( getters, setters );
      ClassLoader loader = this.getClassLoader();
      if ( writeDirectory != null ) {
        FactoryHelper.writeFile( classfile, writeDirectory );
      }
View Full Code Here

    className = className + "_$$_bulkaccess_" + counter++;
    if ( className.startsWith( "java." ) ) {
      className = "org.javassist.tmp." + className;
    }

    ClassFile classfile = new ClassFile( false, className, BULKACESSOR_CLASS_NAME );
    classfile.setAccessFlags( AccessFlag.PUBLIC );
    addDefaultConstructor( classfile );
    addGetter( classfile, getters );
    addSetter( classfile, setters );
    return classfile;
  }
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

      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

    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

    if ( filter.getAnnotations().length == 0 ) {
      is.close();
      return true;
    }
    DataInputStream dstream = new DataInputStream( is );
    ClassFile cf = null;

    try {
      cf = new ClassFile( dstream );
    }
    finally {
      dstream.close();
      is.close();
    }
    boolean match = false;
    AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
    if ( visible != null ) {
      for ( Class annotation : filter.getAnnotations() ) {
        match = visible.getAnnotation( annotation.getName() ) != null;
        if ( match ) break;
      }
View Full Code Here

    if ( filter.getAnnotations().length == 0 ) {
      is.close();
      return true;
    }
    DataInputStream dstream = new DataInputStream( is );
    ClassFile cf = null;

    try {
      cf = new ClassFile( dstream );
    }
    finally {
      dstream.close();
      is.close();
    }
    boolean match = false;
    AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute( AnnotationsAttribute.visibleTag );
    if ( visible != null ) {
      for ( Class annotation : filter.getAnnotations() ) {
        match = visible.getAnnotation( annotation.getName() ) != null;
        if ( match ) break;
      }
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.unableToBuildEnhancementMetamodel( className );
      return classfileBuffer;
    }
    FieldTransformer transformer = getFieldTransformer( classfile );
    if ( transformer != null ) {
      LOG.debugf( "Enhancing %s", 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.unableToTransformClass( e.getMessage() );
        throw new HibernateException( "Unable to transform class: " + e.getMessage() );
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.