net.java.truelicense.maven.plugin.obfuscation.SecondPass Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truelicense-maven-plugin Show documentation
Show all versions of truelicense-maven-plugin Show documentation
Provides a Maven plugin with goals for the obfuscation of constant
string values in Java class and test-class files (byte code).
/*
* Copyright (C) 2005-2013 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package net.java.truelicense.maven.plugin.obfuscation;
import java.io.IOException;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import static org.objectweb.asm.ClassWriter.*;
/**
* @author Christian Schlichtherle
*/
final class SecondPass extends Pass {
/**
* This (virtually) unique prefix is required to make the processor
* idempotent.
*/
private final String prefix = "clinit@" + System.currentTimeMillis();
SecondPass(Processor ctx) { super(ctx); }
@Override
public void run() {
logger().debug("Running second pass.");
super.run();
}
@Override
void process(final Node node) {
logger(node).trace("Transforming class file.");
try {
final ClassReader cr = new ClassReader(read(node));
final ClassWriter cw = new ClassWriter(COMPUTE_MAXS);
cr.accept(ctx.obfuscator(ctx.merger(cw, prefix)), 0);
write(node, cw.toByteArray());
} catch (final IOException ex) {
logger().error(ex.getLocalizedMessage(), ex);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy