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

📄 memberreferencefixer.java

📁 ProGuard 是一个免费的 Java类文件的压缩
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            isInterfaceMethod = false;            clazz.constantPoolEntryAccept(methodrefConstant.u2classIndex, this);            // Has the method become an interface method?            if (isInterfaceMethod)            {                if (DEBUG)                {                    System.out.println("MemberReferenceFixer:");                    System.out.println("  Class file     = "+clazz.getName());                    System.out.println("  Ref class      = "+referencedClass.getName());                    System.out.println("  Ref method     = "+methodrefConstant.getName(clazz)+methodrefConstant.getType(clazz));                    System.out.println("    -> interface method");                }                // Replace the method reference by an interface method reference.                ((ProgramClass)clazz).constantPool[this.constantIndex] =                    new InterfaceMethodrefConstant(methodrefConstant.u2classIndex,                                                   methodrefConstant.u2nameAndTypeIndex,                                                   referencedClass,                                                   referencedMember);            }        }    }    public void visitClassConstant(Clazz clazz, ClassConstant classConstant)    {        // Check if this class entry is an array type.        if (ClassUtil.isInternalArrayType(classConstant.getName(clazz)))        {            isInterfaceMethod = false;        }        else        {            // Check if this class entry refers to an interface class.            Clazz referencedClass = classConstant.referencedClass;            if (referencedClass != null)            {                isInterfaceMethod = (referencedClass.getAccessFlags() & ClassConstants.INTERNAL_ACC_INTERFACE) != 0;            }        }    }    // Implementations for MemberVisitor.    public void visitProgramMember(ProgramClass programClass, ProgramMember programMember)    {        // Fix the attributes.        programMember.attributesAccept(programClass, this);    }    // Implementations for AttributeVisitor.    public void visitAnyAttribute(Clazz clazz, Attribute attribute) {}    public void visitEnclosingMethodAttribute(Clazz clazz, EnclosingMethodAttribute enclosingMethodAttribute)    {        Member referencedMember = enclosingMethodAttribute.referencedMethod;        if (referencedMember != null)        {            Clazz referencedClass = enclosingMethodAttribute.referencedClass;            // Does it have a new class?            if (!enclosingMethodAttribute.getClassName(clazz).equals(referencedClass.getName()))            {                // Update the class index.                enclosingMethodAttribute.u2classIndex =                    constantPoolEditor.addClassConstant((ProgramClass)clazz,                                                        referencedClass);            }            // Does it have a new name or type?            if (!enclosingMethodAttribute.getName(clazz).equals(referencedMember.getName(referencedClass)) ||                !enclosingMethodAttribute.getType(clazz).equals(referencedMember.getDescriptor(referencedClass)))            {                // Update the name and type index.                enclosingMethodAttribute.u2nameAndTypeIndex =                    constantPoolEditor.addNameAndTypeConstant((ProgramClass)clazz,                                                              referencedMember.getName(referencedClass),                                                              referencedMember.getDescriptor(referencedClass));            }        }    }    public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)    {        // Recompute the maximum stack size if necessary.        if (stackSizesMayHaveChanged)        {            stackSizeUpdater.visitCodeAttribute(clazz, method, codeAttribute);        }        // Fix the nested attributes.        codeAttribute.attributesAccept(clazz, method, this);    }    public void visitAnyAnnotationsAttribute(Clazz clazz, AnnotationsAttribute annotationsAttribute)    {        // Fix the annotations.        annotationsAttribute.annotationsAccept(clazz, this);    }    public void visitAnyParameterAnnotationsAttribute(Clazz clazz, Method method, ParameterAnnotationsAttribute parameterAnnotationsAttribute)    {        // Fix the annotations.        parameterAnnotationsAttribute.annotationsAccept(clazz, method, this);    }    public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute)    {        // Fix the annotation.        annotationDefaultAttribute.defaultValueAccept(clazz, this);    }    // Implementations for AnnotationVisitor.    public void visitAnnotation(Clazz clazz, Annotation annotation)    {        // Fix the element values.        annotation.elementValuesAccept(clazz, this);    }    // Implementations for ElementValueVisitor.    public void visitConstantElementValue(Clazz clazz, Annotation annotation, ConstantElementValue constantElementValue)    {        fixElementValue(clazz, annotation, constantElementValue);    }    public void visitEnumConstantElementValue(Clazz clazz, Annotation annotation, EnumConstantElementValue enumConstantElementValue)    {        fixElementValue(clazz, annotation, enumConstantElementValue);    }    public void visitClassElementValue(Clazz clazz, Annotation annotation, ClassElementValue classElementValue)    {        fixElementValue(clazz, annotation, classElementValue);    }    public void visitAnnotationElementValue(Clazz clazz, Annotation annotation, AnnotationElementValue annotationElementValue)    {        fixElementValue(clazz, annotation, annotationElementValue);        // Fix the annotation.        annotationElementValue.annotationAccept(clazz, this);    }    public void visitArrayElementValue(Clazz clazz, Annotation annotation, ArrayElementValue arrayElementValue)    {        fixElementValue(clazz, annotation, arrayElementValue);        // Fix the element values.        arrayElementValue.elementValuesAccept(clazz, annotation, this);    }    // Small utility methods.    /**     * Fixes the method reference of the element value, if any.     */    private void fixElementValue(Clazz        clazz,                                 Annotation   annotation,                                 ElementValue elementValue)    {        // Do we know the referenced method?        Member referencedMember = elementValue.referencedMethod;        if (referencedMember != null)        {            // Does it have a new name or type?            String methodName    = elementValue.getMethodName(clazz);            String newMethodName = referencedMember.getName(elementValue.referencedClass);            if (!methodName.equals(newMethodName))            {                // Update the element name index.                elementValue.u2elementNameIndex =                    constantPoolEditor.addUtf8Constant((ProgramClass)clazz,                                                       newMethodName);            }        }    }    private void debug(Clazz       clazz,                       RefConstant refConstant,                       Clazz       referencedClass,                       Member      referencedMember)    {        System.out.println("MemberReferenceFixer:");        System.out.println("  Class file      = "+clazz.getName());        System.out.println("  Ref class       = "+referencedClass.getName());        System.out.println("  Ref member name = "+refConstant.getName(clazz));        System.out.println("                 -> "+referencedMember.getName(referencedClass));        System.out.println("  Ref descriptor  = "+refConstant.getType(clazz));        System.out.println("                 -> "+referencedMember.getDescriptor(referencedClass));    }}

⌨️ 快捷键说明

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