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

📄 constantpooleditor.java

📁 j2me 混淆包,用于混淆j2me的原代码用的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            if (cpInfo != null &&                cpInfo.getTag() == ClassConstants.CONSTANT_Methodref)            {                MethodrefCpInfo methodrefCpInfo = (MethodrefCpInfo)cpInfo;                if (methodrefCpInfo.u2classIndex       == classIndex &&                    methodrefCpInfo.u2nameAndTypeIndex == nameAndTypeIndex)                {                    return index;                }            }        }        return addCpInfo(programClassFile,                         new MethodrefCpInfo(classIndex,                                             nameAndTypeIndex,                                             referencedClassFile,                                             referencedMemberInfo));    }    /**     * Finds or creates a InterfaceMethodrefCpInfo constant pool entry with the     * given class name, method name, and descriptor, in the given class file.     * @return the constant pool index of the InterfaceMethodrefCpInfo.     */    public int addInterfaceMethodrefCpInfo(ProgramClassFile programClassFile,                                           String           className,                                           String           name,                                           String           descriptor,                                           ClassFile        referencedClassFile,                                           MemberInfo       referencedMemberInfo,                                           ClassFile[]      referencedClassFiles)    {        return addInterfaceMethodrefCpInfo(programClassFile,                                           className,                                           addNameAndTypeCpInfo(programClassFile,                                                                name,                                                                descriptor,                                                                referencedClassFiles),                                                                referencedClassFile,                                                                referencedMemberInfo);    }    /**     * Finds or creates a InterfaceMethodrefCpInfo constant pool entry with the     * given class name, method name, and descriptor, in the given class file.     * @return the constant pool index of the InterfaceMethodrefCpInfo.     */    public int addInterfaceMethodrefCpInfo(ProgramClassFile programClassFile,                                           String           className,                                           int              nameAndTypeIndex,                                           ClassFile        referencedClassFile,                                           MemberInfo       referencedMemberInfo)    {        return addInterfaceMethodrefCpInfo(programClassFile,                                           addClassCpInfo(programClassFile,                                                          className,                                                          referencedClassFile),                                                          nameAndTypeIndex,                                                          referencedClassFile,                                                          referencedMemberInfo);    }    /**     * Finds or creates a InterfaceMethodrefCpInfo constant pool entry with the     * given class constant pool entry index, method name, and descriptor, in     * the given class file.     * @return the constant pool index of the InterfaceMethodrefCpInfo.     */    public int addInterfaceMethodrefCpInfo(ProgramClassFile programClassFile,                                           int              classIndex,                                           String           name,                                           String           descriptor,                                           ClassFile        referencedClassFile,                                           MemberInfo       referencedMemberInfo,                                           ClassFile[]      referencedClassFiles)    {        return addInterfaceMethodrefCpInfo(programClassFile,                                           classIndex,                                           addNameAndTypeCpInfo(programClassFile,                                                                name,                                                                descriptor,                                                                referencedClassFiles),                                                                referencedClassFile,                                                                referencedMemberInfo);    }    /**     * Finds or creates a InterfaceMethodrefCpInfo constant pool entry with the     * given class constant pool entry index and name and type constant pool     * entry index the given class file.     * @return the constant pool index of the InterfaceMethodrefCpInfo.     */    public int addInterfaceMethodrefCpInfo(ProgramClassFile programClassFile,                                           int              classIndex,                                           int              nameAndTypeIndex,                                           ClassFile        referencedClassFile,                                           MemberInfo       referencedMemberInfo)    {        CpInfo[] constantPool      = programClassFile.constantPool;        int      constantPoolCount = programClassFile.u2constantPoolCount;        // Check if the entry already exists.        for (int index = 1; index < constantPoolCount; index++)        {            CpInfo cpInfo = constantPool[index];            if (cpInfo != null &&                            cpInfo.getTag() == ClassConstants.CONSTANT_InterfaceMethodref)            {                InterfaceMethodrefCpInfo methodrefCpInfo = (InterfaceMethodrefCpInfo)cpInfo;                if (methodrefCpInfo.u2classIndex       == classIndex &&                                methodrefCpInfo.u2nameAndTypeIndex == nameAndTypeIndex)                {                    return index;                }            }        }        return addCpInfo(programClassFile,                         new InterfaceMethodrefCpInfo(classIndex,                                                      nameAndTypeIndex,                                                      referencedClassFile,                                                      referencedMemberInfo));    }    /**     * Finds or creates a ClassCpInfo constant pool entry with the given name,     * in the given class file.     * @return the constant pool index of the ClassCpInfo.     */    public int addClassCpInfo(ProgramClassFile programClassFile,                              String           name,                              ClassFile        referencedClassFile)    {        CpInfo[] constantPool        = programClassFile.constantPool;        int      constantPoolCount = programClassFile.u2constantPoolCount;        // Check if the entry already exists.        for (int index = 1; index < constantPoolCount; index++)        {            CpInfo cpInfo = constantPool[index];            if (cpInfo != null &&                cpInfo.getTag() == ClassConstants.CONSTANT_Class)            {                ClassCpInfo classCpInfo = (ClassCpInfo)cpInfo;                if (classCpInfo.getName(programClassFile).equals(name))                {                    return index;                }            }        }        int nameIndex = addUtf8CpInfo(programClassFile, name);        return addCpInfo(programClassFile,                         new ClassCpInfo(nameIndex,                                         referencedClassFile));    }    /**     * Finds or creates a NameAndTypeCpInfo constant pool entry with the given     * name and type, in the given class file.     * @return the constant pool index of the NameAndTypeCpInfo.     */    public int addNameAndTypeCpInfo(ProgramClassFile programClassFile,                                    String           name,                                    String           type,                                    ClassFile[]      referencedClassFiles)    {        CpInfo[] constantPool        = programClassFile.constantPool;        int      constantPoolCount = programClassFile.u2constantPoolCount;        // Check if the entry already exists.        for (int index = 1; index < constantPoolCount; index++)        {            CpInfo cpInfo = constantPool[index];            if (cpInfo != null &&                cpInfo.getTag() == ClassConstants.CONSTANT_NameAndType)            {                NameAndTypeCpInfo nameAndTypeCpInfo = (NameAndTypeCpInfo)cpInfo;                if (nameAndTypeCpInfo.getName(programClassFile).equals(name) &&                    nameAndTypeCpInfo.getType(programClassFile).equals(type))                {                    return index;                }            }        }        int nameIndex       = addUtf8CpInfo(programClassFile, name);        int descriptorIndex = addUtf8CpInfo(programClassFile, type);        return addCpInfo(programClassFile,                         new NameAndTypeCpInfo(nameIndex,                                               descriptorIndex,                                               referencedClassFiles));    }    /**     * Finds or creates an Utf8CpInfo constant pool entry for the given string,     * in the given class file.     * @return the constant pool index of the Utf8CpInfo.     */    public int addUtf8CpInfo(ProgramClassFile programClassFile,                             String           string)    {        CpInfo[] constantPool        = programClassFile.constantPool;        int      constantPoolCount = programClassFile.u2constantPoolCount;        // Check if the entry already exists.        for (int index = 1; index < constantPoolCount; index++)        {            CpInfo cpInfo = constantPool[index];            if (cpInfo != null &&                cpInfo.getTag() == ClassConstants.CONSTANT_Utf8)            {                Utf8CpInfo utf8CpInfo = (Utf8CpInfo)cpInfo;                if (utf8CpInfo.getString().equals(string))                {                    return index;                }            }        }        return addCpInfo(programClassFile, new Utf8CpInfo(string));    }    /**     * Adds a given constant pool entry to the end of the constant pool     * in the given class file.     * @return the constant pool index for the added entry.     */    private int addCpInfo(ProgramClassFile programClassFile,                          CpInfo           cpInfo)    {        CpInfo[] constantPool        = programClassFile.constantPool;        int      constantPoolCount = programClassFile.u2constantPoolCount;        // Make sure there is enough space for another constant pool entry.        if (constantPoolCount == constantPool.length)        {            programClassFile.constantPool = new CpInfo[constantPoolCount+1];            System.arraycopy(constantPool, 0,                             programClassFile.constantPool, 0,                             constantPoolCount);            constantPool = programClassFile.constantPool;        }        // Create a new Utf8CpInfo for the given string.        constantPool[programClassFile.u2constantPoolCount++] = cpInfo;        return constantPoolCount;    }}

⌨️ 快捷键说明

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