Example usage for org.apache.commons.javaflow.bytecode.transformation.asm AsmClassTransformer AsmClassTransformer

List of usage examples for org.apache.commons.javaflow.bytecode.transformation.asm AsmClassTransformer AsmClassTransformer

Introduction

In this page you can find the example usage for org.apache.commons.javaflow.bytecode.transformation.asm AsmClassTransformer AsmClassTransformer.

Prototype

AsmClassTransformer

Source Link

Usage

From source file:meme.singularsyntax.mojo.JavaflowEnhanceMojo.java

private void enhanceClassFiles(String outputDir, File backupDir, List<String> classFileNames)
        throws MojoExecutionException {

    Log log = getLog();//from   w w  w.  ja  va  2s  .c  o  m
    ResourceTransformer transformer = new AsmClassTransformer();

    for (String classFileName : classFileNames) {
        try {
            File source = new File(outputDir, classFileName);
            File destination = new File(String.format(CLASSFILE_REWRITE_TEMPLATE, source.getAbsolutePath()));
            File backupClassFile = new File(backupDir, classFileName);

            if (backupClassFile.exists() && (source.lastModified() <= backupClassFile.lastModified())) {
                log.info(source + " is up to date");
                continue;
            }

            log.info(String.format("Enhancing class file bytecode for Javaflow: %s", source));
            RewritingUtils.rewriteClassFile(source, transformer, destination);

            if (backupClassFile.exists()) {
                log.debug(String.format("Backup for original class file %s already exists - removing it",
                        backupClassFile));
                backupClassFile.delete();
            }

            log.debug(String.format("Renaming original class file from %s to %s", source, backupClassFile));
            FileUtils.moveFile(source, backupClassFile);

            log.debug(String.format("Renaming rewritten class file from %s to %s", destination, source));
            FileUtils.moveFile(destination, source);

            backupClassFile.setLastModified(source.lastModified());

        } catch (IOException e) {
            throw new MojoExecutionException(e.getMessage());
        }
    }
}

From source file:org.eclectic.idc.jvm.runtime.IdcClassLoader.java

public IdcClassLoader(final BytecodeClass[] dynamicClasses, final Class<?>[] pInstrument,
        final Class<?>[] pLoad) {

    this(new AsmClassTransformer(), pInstrument, pLoad);

    for (int i = 0; i < dynamicClasses.length; i++)
        this.byteCodeClasses.put(dynamicClasses[i].className, dynamicClasses[i]);
}

From source file:org.shelloid.netverif.ClassTransformerClassLoader.java

public ClassTransformerClassLoader(ClassLoader parent) {
    super(parent);
    transformer = new AsmClassTransformer();
}