All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.java.truelicense.maven.plugin.obfuscation.FirstPass Maven / Gradle / Ivy

Go to download

Provides a Maven plugin with goals for the obfuscation of constant string values in Java class and test-class files (byte code).

The newest version!
/*
 * Copyright (C) 2005-2017 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 static org.objectweb.asm.ClassReader.*;
import org.slf4j.Logger;

/**
 * @author Christian Schlichtherle
 */
final class FirstPass extends Pass {

    private static final int
            CLASS_READER_FLAGS = SKIP_DEBUG | SKIP_FRAMES | SKIP_CODE;

    FirstPass(Processor ctx) { super(ctx); }

    @Override
    public void run() {
        final Logger logger = logger();
        if (obfuscateAll()) {
            logger.debug("Skipping first pass because all constant string values should get obfuscated.");
        } else {
            logger.debug("Running first pass.");
            super.run();
        }
    }

    @Override
    void process(final Node node) {
        logger(node).trace("Analyzing class file.");
        try {
            new ClassReader(read(node)).accept(ctx.collector(),
                    CLASS_READER_FLAGS);
        } catch (IOException ex) {
            logger().error(ex.toString(), ex);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy