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

📄 memberdescriptorspecializer.java

📁 ProGuard 是一个免费的 Java类文件的压缩
💻 JAVA
字号:
/* * ProGuard -- shrinking, optimization, obfuscation, and preverification *             of Java bytecode. * * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu) * * This library 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 library 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 Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package proguard.optimize;import proguard.optimize.evaluation.StoringInvocationUnit;import proguard.classfile.util.*;import proguard.classfile.visitor.MemberVisitor;import proguard.classfile.attribute.visitor.AttributeVisitor;import proguard.classfile.attribute.Attribute;import proguard.classfile.attribute.annotation.*;import proguard.classfile.editor.*;import proguard.classfile.*;import proguard.evaluation.value.Value;/** * This MemberVisitor removes unused parameters descriptors of the methods that * it visits. * * @see StoringInvocationUnit * @see ClassReferenceFixer * @author Eric Lafortune */public class MemberDescriptorSpecializerextends      SimplifiedVisitorimplements   MemberVisitor{    private static final boolean DEBUG = true;    private MemberVisitor extraParameterMemberVisitor;    /**     * Creates a new MethodDescriptorShrinker.     */    public MemberDescriptorSpecializer()    {        this(null);    }    /**     * Creates a new MethodDescriptorShrinker with an extra visitor.     * @param extraParameterMemberVisitor an optional extra visitor for all     *                                    class members whose parameters have     *                                    been specialized.     */    public MemberDescriptorSpecializer(MemberVisitor extraParameterMemberVisitor)    {        this.extraParameterMemberVisitor = extraParameterMemberVisitor;    }    // Implementations for MemberVisitor.    public void visitProgramField(ProgramClass programClass, ProgramField programField)    {        Value parameterValue = StoringInvocationUnit.getFieldValue(programField);        if (parameterValue.computationalType() == Value.TYPE_REFERENCE)        {            Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();            if (referencedClass != null)            {                programField.referencedClass = referencedClass;            }        }    }    public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)    {        // All parameters of non-static methods are shifted by one in the local        // variable frame.        int firstParameterIndex =            (programMethod.getAccessFlags() & ClassConstants.INTERNAL_ACC_STATIC) != 0 ?                0 : 1;        int parameterCount =            ClassUtil.internalMethodParameterCount(programMethod.getDescriptor(programClass));        int classIndex = 0;        // Go over the parameters.        for (int parameterIndex = firstParameterIndex; parameterIndex < parameterCount; parameterIndex++)        {            Value parameterValue = StoringInvocationUnit.getMethodParameterValue(programMethod, parameterIndex);             if (parameterValue.computationalType() == Value.TYPE_REFERENCE)             {                 Clazz referencedClass = parameterValue.referenceValue().getReferencedClass();                 if (referencedClass != null)                 {                     if (DEBUG)                     {                         if (!referencedClass.equals(programMethod.referencedClasses[classIndex]))                         {                             System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass));                             System.out.println("  "+programMethod.referencedClasses[classIndex].getName()+" -> "+referencedClass.getName());                         }                     }                     programMethod.referencedClasses[classIndex] = referencedClass;                 }                 classIndex++;             }        }    }}

⌨️ 快捷键说明

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