Java Code Examples for proguard.classfile.util.ClassUtil#externalClassName()

The following examples show how to use proguard.classfile.util.ClassUtil#externalClassName() . 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: ConfigurationWriter.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
private void writeOption(String  optionName,
                         String  arguments,
                         boolean replaceInternalClassNames)
{
    if (arguments != null)
    {
        if (replaceInternalClassNames)
        {
            arguments = ClassUtil.externalClassName(arguments);
        }

        writer.print(optionName);
        writer.print(' ');
        writer.println(quotedString(arguments));
    }
}
 
Example 2
Source File: ResourceJavaReferenceFixer.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void visitResourceFile(ResourceFile resourceFile)
{
    Set<ResourceJavaReference> references = resourceFile.references;

    if (references != null)
    {
        for (ResourceJavaReference reference : references)
        {
            Clazz referencedClass = reference.referencedClass;

            if (referencedClass != null)
            {
                reference.externalClassName =
                    ClassUtil.externalClassName(referencedClass.getName());
            }
        }
    }
}
 
Example 3
Source File: ClassReferenceFixer.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
public void visitStringConstant(Clazz clazz, StringConstant stringConstant)
{
    // Does the string refer to a class, due to a Class.forName construct?
    Clazz referencedClass  = stringConstant.referencedClass;
    Member referencedMember = stringConstant.referencedMember;
    if (referencedClass  != null &&
        referencedMember == null)
    {
        // Reconstruct the new class name.
        String externalClassName    = stringConstant.getString(clazz);
        String internalClassName    = ClassUtil.internalClassName(externalClassName);
        String newInternalClassName = newClassName(internalClassName,
                                                   referencedClass);

        // Update the String entry if required.
        if (!newInternalClassName.equals(internalClassName))
        {
            String newExternalClassName = ClassUtil.externalClassName(newInternalClassName);

            // Refer to a new Utf8 entry.
            stringConstant.u2stringIndex =
                new ConstantPoolEditor((ProgramClass)clazz).addUtf8Constant(newExternalClassName);
        }
    }
}
 
Example 4
Source File: ConfigurationWriter.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private void writeOption(String  optionName,
                         String  arguments,
                         boolean replaceInternalClassNames)
{
    if (arguments != null)
    {
        if (replaceInternalClassNames)
        {
            arguments = ClassUtil.externalClassName(arguments);
        }

        writer.print(optionName);
        writer.print(' ');
        writer.println(quotedString(arguments));
    }
}
 
Example 5
Source File: ConfigurationWriter.java    From proguard with GNU General Public License v2.0 6 votes vote down vote up
private void writeOption(String  optionName,
                         String  arguments,
                         boolean replaceInternalClassNames)
{
    if (arguments != null)
    {
        if (replaceInternalClassNames)
        {
            arguments = ClassUtil.externalClassName(arguments);
        }

        writer.print(optionName);
        writer.print(' ');
        writer.println(quotedString(arguments));
    }
}
 
Example 6
Source File: ConfigurationWriter.java    From bazel with Apache License 2.0 6 votes vote down vote up
private void writeOption(String  optionName,
                         String  arguments,
                         boolean replaceInternalClassNames)
{
    if (arguments != null)
    {
        if (replaceInternalClassNames)
        {
            arguments = ClassUtil.externalClassName(arguments);
        }

        writer.print(optionName);
        writer.print(' ');
        writer.println(quotedString(arguments));
    }
}
 
Example 7
Source File: ClassSpecificationDialog.java    From proguard with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a suitable label summarizing the given class specification at
 * some given index.
 */
public String label(ClassSpecification classSpecification, int index)
{
    return
        classSpecification                       == null ? msg("none")                                                                                                        :
        classSpecification.comments              != null ? classSpecification.comments.trim()                                                                                 :
        classSpecification.className             != null ? (msg("class") + ' ' + ClassUtil.externalClassName(classSpecification.className))                                   :
        classSpecification.annotationType        != null ? (msg("classesAnnotatedWith") + ' ' + ClassUtil.externalType(classSpecification.annotationType))                    :
        classSpecification.extendsClassName      != null ? (msg("extensionsOf") + ' ' + ClassUtil.externalClassName(classSpecification.extendsClassName))                     :
        classSpecification.extendsAnnotationType != null ? (msg("extensionsOfClassesAnnotatedWith") + ' ' + ClassUtil.externalType(classSpecification.extendsAnnotationType)) :
        index                                    >= 0    ? (msg("specificationNumber") + index)                                                                               :
                                                           msg("specification");
}
 
Example 8
Source File: FramePattern.java    From proguard with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses all frame information from a given line.
 * @param  line a line that represents a stack frame.
 * @return the parsed information, or null if the line doesn't match a
 *         stack frame.
 */
public FrameInfo parse(String line)
{
    // Try to match it against the regular expression.
    Matcher matcher = pattern.matcher(line);

    if (!matcher.matches())
    {
        return null;
    }

    // The line matched the regular expression.
    String className  = null;
    String sourceFile = null;
    int    lineNumber = 0;
    String type       = null;
    String fieldName  = null;
    String methodName = null;
    String arguments  = null;

    // Extract a class name, a line number, a type, and
    // arguments.
    for (int expressionTypeIndex = 0; expressionTypeIndex < expressionTypeCount; expressionTypeIndex++)
    {
        int startIndex = matcher.start(expressionTypeIndex + 1);
        if (startIndex >= 0)
        {
            String match = matcher.group(expressionTypeIndex + 1);

            char expressionType = expressionTypes[expressionTypeIndex];
            switch (expressionType)
            {
                case 'c':
                    className = match;
                    break;

                case 'C':
                    className = ClassUtil.externalClassName(match);
                    break;

                case 's':
                    sourceFile = match;
                    break;

                case 'l':
                    lineNumber = Integer.parseInt(match);
                    break;

                case 't':
                    type = match;
                    break;

                case 'f':
                    fieldName = match;
                    break;

                case 'm':
                    methodName = match;
                    break;

                case 'a':
                    arguments = match;
                    break;
            }
        }
    }

    return new FrameInfo(className,
                         sourceFile,
                         lineNumber,
                         type,
                         fieldName,
                         methodName,
                         arguments);
}
 
Example 9
Source File: FramePattern.java    From proguard with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses all frame information from a given line.
 * @param  line a line that represents a stack frame.
 * @return the parsed information, or null if the line doesn't match a
 *         stack frame.
 */
public FrameInfo parse(String line)
{
    // Try to match it against the regular expression.
    Matcher matcher = pattern.matcher(line);

    if (!matcher.matches())
    {
        return null;
    }

    // The line matched the regular expression.
    String className  = null;
    String sourceFile = null;
    int    lineNumber = 0;
    String type       = null;
    String fieldName  = null;
    String methodName = null;
    String arguments  = null;

    // Extract a class name, a line number, a type, and
    // arguments.
    for (int expressionTypeIndex = 0; expressionTypeIndex < expressionTypeCount; expressionTypeIndex++)
    {
        int startIndex = matcher.start(expressionTypeIndex + 1);
        if (startIndex >= 0)
        {
            String match = matcher.group(expressionTypeIndex + 1);

            char expressionType = expressionTypes[expressionTypeIndex];
            switch (expressionType)
            {
                case 'c':
                    className = match;
                    break;

                case 'C':
                    className = ClassUtil.externalClassName(match);
                    break;

                case 's':
                    sourceFile = match;
                    break;

                case 'l':
                    lineNumber = Integer.parseInt(match);
                    break;

                case 't':
                    type = match;
                    break;

                case 'f':
                    fieldName = match;
                    break;

                case 'm':
                    methodName = match;
                    break;

                case 'a':
                    arguments = match;
                    break;
            }
        }
    }

    return new FrameInfo(className,
                         sourceFile,
                         lineNumber,
                         type,
                         fieldName,
                         methodName,
                         arguments);
}
 
Example 10
Source File: FramePattern.java    From bazel with Apache License 2.0 4 votes vote down vote up
/**
 * Parses all frame information from a given line.
 * @param  line a line that represents a stack frame.
 * @return the parsed information, or null if the line doesn't match a
 *         stack frame.
 */
public FrameInfo parse(String line)
{
    // Try to match it against the regular expression.
    Matcher matcher = pattern.matcher(line);

    if (!matcher.matches())
    {
        return null;
    }

    // The line matched the regular expression.
    String className  = null;
    String sourceFile = null;
    int    lineNumber = 0;
    String type       = null;
    String fieldName  = null;
    String methodName = null;
    String arguments  = null;

    // Extract a class name, a line number, a type, and
    // arguments.
    for (int expressionTypeIndex = 0; expressionTypeIndex < expressionTypeCount; expressionTypeIndex++)
    {
        int startIndex = matcher.start(expressionTypeIndex + 1);
        if (startIndex >= 0)
        {
            String match = matcher.group(expressionTypeIndex + 1);

            char expressionType = expressionTypes[expressionTypeIndex];
            switch (expressionType)
            {
                case 'c':
                    className = match;
                    break;

                case 'C':
                    className = ClassUtil.externalClassName(match);
                    break;

                case 's':
                    sourceFile = match;
                    break;

                case 'l':
                    lineNumber = Integer.parseInt(match);
                    break;

                case 't':
                    type = match;
                    break;

                case 'f':
                    fieldName = match;
                    break;

                case 'm':
                    methodName = match;
                    break;

                case 'a':
                    arguments = match;
                    break;
            }
        }
    }

    return new FrameInfo(className,
                         sourceFile,
                         lineNumber,
                         type,
                         fieldName,
                         methodName,
                         arguments);
}