Java Code Examples for proguard.classfile.Clazz#getName()

The following examples show how to use proguard.classfile.Clazz#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiFilePartIntegrity.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
@Override
    public void visitKotlinMultiFilePartMetadata(Clazz clazz,
                                                 KotlinMultiFilePartKindMetadata kotlinMultiFilePartKindMetadata)
    {
        AssertUtil util = new AssertUtil("Multi-file part " + clazz.getName(), reporter);
        util.reportIfNullReference("referenced facade class", kotlinMultiFilePartKindMetadata.referencedFacadeClass);
/*        new AssertUtil("Multi-file part " + clazz.getName(), reporter).
            reportIfNullReference("referenced module", kotlinMultiFilePartKindMetadata.referencedModule);*/
    }
 
Example 2
Source File: KotlinMultiFileFacadeFixer.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitKotlinMultiFileFacadeMetadata(Clazz                             clazz,
                                               KotlinMultiFileFacadeKindMetadata kotlinMultiFileFacadeKindMetadata)
{
    String packagePrefix = internalPackagePrefix(hasOriginalClassName(clazz) ? clazz.getName() : newClassName(clazz));

    for (Clazz referencedPartClass : kotlinMultiFileFacadeKindMetadata.referencedPartClasses)
    {
        if (dontObfuscate(referencedPartClass))
        {
            packagePrefix = internalPackagePrefix(referencedPartClass.getName());
            break;
        }
    }

    for (Clazz ref : kotlinMultiFileFacadeKindMetadata.referencedPartClasses)
    {
        setNewClassName(ref, packagePrefix +
                             (internalSimpleClassName(hasOriginalClassName(ref) ? ref.getName() : newClassName(ref))));
    }

    String className = newClassName(clazz);
    if (className == null)
    {
        className = clazz.getName();
    }

    setNewClassName(clazz, packagePrefix + internalSimpleClassName(className));
}
 
Example 3
Source File: ClassReferenceInitializer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitClassConstant(Clazz clazz, ClassConstant classConstant)
{
    String className = clazz.getName();

    // Fill out the referenced class.
    classConstant.referencedClass =
        findClass(className, ClassUtil.internalClassNameFromClassType(classConstant.getName(clazz)));

    // Fill out the Class class.
    classConstant.javaLangClassClass =
        findClass(className, ClassConstants.INTERNAL_NAME_JAVA_LANG_CLASS);
}
 
Example 4
Source File: StringSharer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitClassConstant(Clazz clazz, ClassConstant classConstant)
{
    Clazz referencedClass = classConstant.referencedClass;
    if (referencedClass != null)
    {
        // Put the actual class's name string in the class pool.
        name = referencedClass.getName();
        clazz.constantPoolEntryAccept(classConstant.u2nameIndex, this);
    }
}
 
Example 5
Source File: ClassObfuscator.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public void visitEnclosingMethodAttribute(Clazz clazz, EnclosingMethodAttribute enclosingMethodAttribute)
{
    // Make sure the enclosing class has a name.
    enclosingMethodAttribute.referencedClassAccept(this);

    String innerClassName = clazz.getName();
    String outerClassName = clazz.getClassName(enclosingMethodAttribute.u2classIndex);

    numericClassName = isNumericClassName(innerClassName,
                                          outerClassName);
}
 
Example 6
Source File: DataEntryRewriter.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the given word to the given writer, after having adapted it,
 * based on the renamed class names.
 */
private void writeUpdatedWord(Writer writer, String word)
throws IOException
{
    if (word.length() > 0)
    {
        String newWord = word;

        boolean containsDots = word.indexOf('.') >= 0;

        // Replace dots by forward slashes.
        String className = containsDots ?
            word.replace('.', ClassConstants.INTERNAL_PACKAGE_SEPARATOR) :
            word;

        // Find the class corrsponding to the word.
        Clazz clazz = classPool.getClass(className);
        if (clazz != null)
        {
            // Update the word if necessary.
            String newClassName = clazz.getName();
            if (!className.equals(newClassName))
            {
                // Replace forward slashes by dots.
                newWord = containsDots ?
                    newClassName.replace(ClassConstants.INTERNAL_PACKAGE_SEPARATOR, '.') :
                    newClassName;
            }
        }

        writer.write(newWord);
    }
}
 
Example 7
Source File: RefConstant.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the method/field name.
 */
public String getName(Clazz clazz)
{
    return clazz.getName(u2nameAndTypeIndex);
}
 
Example 8
Source File: EnclosingMethodAttribute.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the method/field name.
 */
public String getName(Clazz clazz)
{
    return clazz.getName(u2nameAndTypeIndex);
}
 
Example 9
Source File: ClassReferenceInitializer.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public void visitEnclosingMethodAttribute(Clazz clazz, EnclosingMethodAttribute enclosingMethodAttribute)
{
    String className          = clazz.getName();
    String enclosingClassName = enclosingMethodAttribute.getClassName(clazz);

    // See if we can find the referenced class.
    Clazz referencedClass = findClass(className, enclosingClassName);

    if (referencedClass == null)
    {
        // We couldn't find the enclosing class.
        missingClassWarningPrinter.print(className,
                                         enclosingClassName,
                                         "Warning: " +
                                         ClassUtil.externalClassName(className) +
                                         ": can't find enclosing class " +
                                         ClassUtil.externalClassName(enclosingClassName));
        return;
    }

    // Make sure there is actually an enclosed method.
    if (enclosingMethodAttribute.u2nameAndTypeIndex == 0)
    {
        return;
    }

    String name = enclosingMethodAttribute.getName(clazz);
    String type = enclosingMethodAttribute.getType(clazz);

    // See if we can find the method in the referenced class.
    Method referencedMethod = referencedClass.findMethod(name, type);

    if (referencedMethod == null)
    {
        // We couldn't find the enclosing method.
        missingMemberWarningPrinter.print(className,
                                          enclosingClassName,
                                          "Warning: " +
                                          ClassUtil.externalClassName(className) +
                                          ": can't find enclosing method '" +
                                          ClassUtil.externalFullMethodDescription(enclosingClassName, 0, name, type) +
                                          "' in class " +
                                          ClassUtil.externalClassName(enclosingClassName));
        return;
    }

    // Save the references.
    enclosingMethodAttribute.referencedClass  = referencedClass;
    enclosingMethodAttribute.referencedMethod = referencedMethod;
}