⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 optimizer.java

📁 proguard 3.5 java 混淆器 最新 免费 好用的 大家用用试一下吧 天行健-君子以自强不息 地势坤-君子以厚德载物
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* $Id: Optimizer.java,v 1.9.2.3 2006/01/16 22:57:56 eric Exp $ * * ProGuard -- shrinking, optimization, and obfuscation of Java class files. * * Copyright (c) 2002-2006 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package proguard.optimize;import proguard.*;import proguard.classfile.*;import proguard.classfile.attribute.*;import proguard.classfile.editor.*;import proguard.classfile.instruction.*;import proguard.classfile.util.MethodInfoLinker;import proguard.classfile.visitor.*;import proguard.optimize.evaluation.EvaluationSimplifier;import proguard.optimize.peephole.*;import java.io.IOException;/** * This class optimizes class pools according to a given configuration. * * @author Eric Lafortune */public class Optimizer{    private Configuration configuration;    /**     * Creates a new Optimizer.     */    public Optimizer(Configuration configuration)    {        this.configuration = configuration;    }    /**     * Performs optimization of the given program class pool.     */    public void execute(ClassPool programClassPool,                        ClassPool libraryClassPool) throws IOException    {        // Create counters to count the numbers of optimizations, if required.        ClassCounter       singleImplementationCounter = null;        ClassCounter       finalClassCounter           = null;        MemberCounter      writeOnlyFieldCounter       = null;        MemberCounter      finalMethodCounter          = null;        MemberCounter      privateMethodCounter        = null;        MemberCounter      staticMethodCounter         = null;        MemberCounter      parameterShrinkCounter      = null;        InstructionCounter getterSetterCounter         = null;        InstructionCounter commonCodeCounter           = null;        InstructionCounter pushCounter                 = null;        InstructionCounter branchCounter               = null;        InstructionCounter deletedCounter              = null;//      InstructionCounter nopCounter                  = null;        InstructionCounter pushPopCounter              = null;        InstructionCounter loadStoreCounter            = null;        InstructionCounter storeLoadCounter            = null;        InstructionCounter gotoGotoCounter             = null;        InstructionCounter gotoReturnCounter           = null;        if (configuration.verbose)        {            singleImplementationCounter = new ClassCounter();            finalClassCounter           = new ClassCounter();            writeOnlyFieldCounter       = new MemberCounter();            finalMethodCounter          = new MemberCounter();            privateMethodCounter        = new MemberCounter();            staticMethodCounter         = new MemberCounter();            parameterShrinkCounter      = new MemberCounter();            getterSetterCounter         = new InstructionCounter();            commonCodeCounter           = new InstructionCounter();            pushCounter                 = new InstructionCounter();            branchCounter               = new InstructionCounter();            deletedCounter              = new InstructionCounter();//          nopCounter                  = new InstructionCounter();            pushPopCounter              = new InstructionCounter();            loadStoreCounter            = new InstructionCounter();            storeLoadCounter            = new InstructionCounter();            gotoGotoCounter             = new InstructionCounter();            gotoReturnCounter           = new InstructionCounter();        }        // Clean up any old visitor info.        programClassPool.classFilesAccept(new ClassFileCleaner());        libraryClassPool.classFilesAccept(new ClassFileCleaner());        // Link all methods that should get the same optimization info.        programClassPool.classFilesAccept(new BottomClassFileFilter(                                          new MethodInfoLinker()));        // Create a visitor for marking the seeds.        KeepMarker keepMarker = new KeepMarker();        ClassPoolVisitor classPoolvisitor =            new MultiClassPoolVisitor(new ClassPoolVisitor[]            {                ClassSpecificationVisitorFactory.createClassPoolVisitor(configuration.keep,                                                                        keepMarker,                                                                        keepMarker),                ClassSpecificationVisitorFactory.createClassPoolVisitor(configuration.keepNames,                                                                        keepMarker,                                                                        keepMarker)            });        // Mark the seeds.        programClassPool.accept(classPoolvisitor);        libraryClassPool.accept(classPoolvisitor);        // All library classes and library class members remain unchanged.        libraryClassPool.classFilesAccept(keepMarker);        libraryClassPool.classFilesAccept(new AllMemberInfoVisitor(keepMarker));        // Attach some optimization info to all methods, so it can be filled        // out later.        programClassPool.classFilesAccept(new AllMethodVisitor(                                          new MethodOptimizationInfoSetter()));        libraryClassPool.classFilesAccept(new AllMethodVisitor(                                          new MethodOptimizationInfoSetter()));        // Mark all interfaces that have single implementations.        programClassPool.classFilesAccept(new SingleImplementationMarker(configuration.allowAccessModification, singleImplementationCounter));        // Make class files and methods final, as far as possible.        programClassPool.classFilesAccept(new ClassFileFinalizer(finalClassCounter, finalMethodCounter));        // Mark all fields that are write-only, and mark the used local variables.        programClassPool.classFilesAccept(new AllMethodVisitor(                                          new AllAttrInfoVisitor(                                          new AllInstructionVisitor(                                          new MultiInstructionVisitor(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -