Java Code Examples for proguard.classfile.util.ClassUtil#internalClassName()
The following examples show how to use
proguard.classfile.util.ClassUtil#internalClassName() .
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: ClassReferenceFixer.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
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 2
Source File: FilterElement.java From proguard with GNU General Public License v2.0 | 5 votes |
/** * Adds the contents of this element to the given name filter. * @param filter the list of attributes to be extended. * @param internal specifies whether the filter string should be converted * to internal types. */ public void appendTo(List filter, boolean internal) { // Get the referenced element, or else this one. FilterElement filterElement = isReference() ? (FilterElement)getCheckedRef(this.getClass(), this.getClass().getName()) : this; String filterString = filterElement.filter; if (filterString == null) { // Clear the filter to keep all names. filter.clear(); } else { if (internal) { filterString = ClassUtil.internalClassName(filterString); } // Append the filter. filter.addAll(ListUtil.commaSeparatedList(filterString)); } }
Example 3
Source File: ClassSpecificationElement.java From proguard with GNU General Public License v2.0 | 5 votes |
/** * Creates a new class specification corresponding to the contents of this * class specification element. */ protected ClassSpecification createClassSpecification(ClassSpecificationElement classSpecificationElement) { String access = classSpecificationElement.access; String annotation = classSpecificationElement.annotation; String type = classSpecificationElement.type; String name = classSpecificationElement.name; String extendsAnnotation = classSpecificationElement.extendsAnnotation; String extends_ = classSpecificationElement.extends_; // For backward compatibility, allow a single "*" wildcard to match // any class. if (name != null && name.equals(ANY_CLASS_KEYWORD)) { name = null; } ClassSpecification classSpecification = new ClassSpecification(null, requiredAccessFlags(true, access, type), requiredAccessFlags(false, access, type), annotation != null ? ClassUtil.internalType(annotation) : null, name != null ? ClassUtil.internalClassName(name) : null, extendsAnnotation != null ? ClassUtil.internalType(extendsAnnotation) : null, extends_ != null ? ClassUtil.internalClassName(extends_) : null); for (int index = 0; index < fieldSpecifications.size(); index++) { classSpecification.addField((MemberSpecification)fieldSpecifications.get(index)); } for (int index = 0; index < methodSpecifications.size(); index++) { classSpecification.addMethod((MemberSpecification)methodSpecifications.get(index)); } return classSpecification; }
Example 4
Source File: FilterElement.java From bazel with Apache License 2.0 | 5 votes |
/** * Adds the contents of this element to the given name filter. * @param filter the list of attributes to be extended. * @param internal specifies whether the filter string should be converted * to internal types. */ public void appendTo(List filter, boolean internal) { // Get the referenced element, or else this one. FilterElement filterElement = isReference() ? (FilterElement)getCheckedRef(this.getClass(), this.getClass().getName()) : this; String filterString = filterElement.filter; if (filterString == null) { // Clear the filter to keep all names. filter.clear(); } else { if (internal) { filterString = ClassUtil.internalClassName(filterString); } // Append the filter. filter.addAll(ListUtil.commaSeparatedList(filterString)); } }
Example 5
Source File: ClassSpecificationElement.java From proguard with GNU General Public License v2.0 | 5 votes |
/** * Creates a new class specification corresponding to the contents of this * class specification element. */ protected ClassSpecification createClassSpecification(ClassSpecificationElement classSpecificationElement) { String access = classSpecificationElement.access; String annotation = classSpecificationElement.annotation; String type = classSpecificationElement.type; String name = classSpecificationElement.name; String extendsAnnotation = classSpecificationElement.extendsAnnotation; String extends_ = classSpecificationElement.extends_; // For backward compatibility, allow a single "*" wildcard to match // any class. if (name != null && name.equals(ANY_CLASS_KEYWORD)) { name = null; } ClassSpecification classSpecification = new ClassSpecification(null, requiredAccessFlags(true, access, type), requiredAccessFlags(false, access, type), annotation != null ? ClassUtil.internalType(annotation) : null, name != null ? ClassUtil.internalClassName(name) : null, extendsAnnotation != null ? ClassUtil.internalType(extendsAnnotation) : null, extends_ != null ? ClassUtil.internalClassName(extends_) : null); for (int index = 0; index < fieldSpecifications.size(); index++) { classSpecification.addField((MemberSpecification)fieldSpecifications.get(index)); } for (int index = 0; index < methodSpecifications.size(); index++) { classSpecification.addMethod((MemberSpecification)methodSpecifications.get(index)); } return classSpecification; }
Example 6
Source File: ClassSpecificationElement.java From bazel with Apache License 2.0 | 5 votes |
/** * Creates a new class specification corresponding to the contents of this * class specification element. */ protected ClassSpecification createClassSpecification(ClassSpecificationElement classSpecificationElement) { String access = classSpecificationElement.access; String annotation = classSpecificationElement.annotation; String type = classSpecificationElement.type; String name = classSpecificationElement.name; String extendsAnnotation = classSpecificationElement.extendsAnnotation; String extends_ = classSpecificationElement.extends_; // For backward compatibility, allow a single "*" wildcard to match // any class. if (name != null && name.equals(ANY_CLASS_KEYWORD)) { name = null; } ClassSpecification classSpecification = new ClassSpecification(null, requiredAccessFlags(true, access, type), requiredAccessFlags(false, access, type), annotation != null ? ClassUtil.internalType(annotation) : null, name != null ? ClassUtil.internalClassName(name) : null, extendsAnnotation != null ? ClassUtil.internalType(extendsAnnotation) : null, extends_ != null ? ClassUtil.internalClassName(extends_) : null); for (int index = 0; index < fieldSpecifications.size(); index++) { classSpecification.addField((MemberSpecification)fieldSpecifications.get(index)); } for (int index = 0; index < methodSpecifications.size(); index++) { classSpecification.addMethod((MemberSpecification)methodSpecifications.get(index)); } return classSpecification; }
Example 7
Source File: ClassSpecificationDialog.java From proguard with GNU General Public License v2.0 | 5 votes |
/** * Returns the ClassSpecification currently represented in this dialog. */ public ClassSpecification getClassSpecification() { String comments = commentsTextArea.getText(); String annotationType = annotationTypeTextField.getText(); String className = classNameTextField.getText(); String extendsAnnotationType = extendsAnnotationTypeTextField.getText(); String extendsClassName = extendsClassNameTextField.getText(); ClassSpecification classSpecification = new ClassSpecification(comments.equals("") ? null : comments, 0, 0, annotationType.equals("") ? null : ClassUtil.internalType(annotationType), className.equals("") || className.equals("*") ? null : ClassUtil.internalClassName(className), extendsAnnotationType.equals("") ? null : ClassUtil.internalType(extendsAnnotationType), extendsClassName.equals("") ? null : ClassUtil.internalClassName(extendsClassName)); // Also get the access radio button settings. getClassSpecificationRadioButtons(classSpecification, AccessConstants.PUBLIC, publicRadioButtons); getClassSpecificationRadioButtons(classSpecification, AccessConstants.FINAL, finalRadioButtons); getClassSpecificationRadioButtons(classSpecification, AccessConstants.ABSTRACT, abstractRadioButtons); getClassSpecificationRadioButtons(classSpecification, AccessConstants.INTERFACE, interfaceRadioButtons); getClassSpecificationRadioButtons(classSpecification, AccessConstants.ANNOTATION, annotationRadioButtons); getClassSpecificationRadioButtons(classSpecification, AccessConstants.ENUM, enumRadioButtons); getClassSpecificationRadioButtons(classSpecification, AccessConstants.SYNTHETIC, syntheticRadioButtons); // Get the keep class member option lists. classSpecification.fieldSpecifications = memberSpecificationsPanel.getMemberSpecifications(true); classSpecification.methodSpecifications = memberSpecificationsPanel.getMemberSpecifications(false); return classSpecification; }
Example 8
Source File: FilterElement.java From proguard with GNU General Public License v2.0 | 5 votes |
/** * Adds the contents of this element to the given name filter. * @param filter the list of attributes to be extended. * @param internal specifies whether the filter string should be converted * to internal types. */ public void appendTo(List filter, boolean internal) { // Get the referenced element, or else this one. FilterElement filterElement = isReference() ? (FilterElement)getCheckedRef(this.getClass(), this.getClass().getName()) : this; String filterString = filterElement.filter; if (filterString == null) { // Clear the filter to keep all names. filter.clear(); } else { if (internal) { filterString = ClassUtil.internalClassName(filterString); } // Append the filter. filter.addAll(ListUtil.commaSeparatedList(filterString)); } }
Example 9
Source File: MappingKeeper.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public boolean processClassMapping(String className, String newClassName) { // Find the class. String name = ClassUtil.internalClassName(className); clazz = classPool.getClass(name); if (clazz != null) { String newName = ClassUtil.internalClassName(newClassName); // Print out a warning if the mapping conflicts with a name that // was set before. if (warningPrinter != null) { String currentNewName = ClassObfuscator.newClassName(clazz); if (currentNewName != null && !currentNewName.equals(newName)) { warningPrinter.print(name, currentNewName, "Warning: " + className + " is not being kept as '" + ClassUtil.externalClassName(currentNewName) + "', but remapped to '" + newClassName + "'"); } } ClassObfuscator.setNewClassName(clazz, newName); // The class members have to be kept as well. return true; } return false; }
Example 10
Source File: ProGuardTask.java From bazel with Apache License 2.0 | 4 votes |
/** * @deprecated Use the repackageclasses attribute instead. */ public void setDefaultpackage(String defaultPackage) { configuration.repackageClasses = ClassUtil.internalClassName(defaultPackage); }
Example 11
Source File: ProGuardTask.java From proguard with GNU General Public License v2.0 | 4 votes |
public void setFlattenpackagehierarchy(String flattenPackageHierarchy) { configuration.flattenPackageHierarchy = ClassUtil.internalClassName(flattenPackageHierarchy); }
Example 12
Source File: ConfigurationParser.java From proguard with GNU General Public License v2.0 | 4 votes |
/** * Parses and returns the configuration. * @param configuration the configuration that is updated as a side-effect. * @throws ParseException if the any of the configuration settings contains * a syntax error. * @throws IOException if an IO error occurs while reading a configuration. */ public void parse(Configuration configuration) throws ParseException, IOException { while (nextWord != null) { lastComments = reader.lastComments(); // First include directives. if (ConfigurationConstants.AT_DIRECTIVE .startsWith(nextWord) || ConfigurationConstants.INCLUDE_DIRECTIVE .startsWith(nextWord)) configuration.lastModified = parseIncludeArgument(configuration.lastModified); else if (ConfigurationConstants.BASE_DIRECTORY_DIRECTIVE .startsWith(nextWord)) parseBaseDirectoryArgument(); // Then configuration options with or without arguments. else if (ConfigurationConstants.INJARS_OPTION .startsWith(nextWord)) configuration.programJars = parseClassPathArgument(configuration.programJars, false); else if (ConfigurationConstants.OUTJARS_OPTION .startsWith(nextWord)) configuration.programJars = parseClassPathArgument(configuration.programJars, true); else if (ConfigurationConstants.LIBRARYJARS_OPTION .startsWith(nextWord)) configuration.libraryJars = parseClassPathArgument(configuration.libraryJars, false); else if (ConfigurationConstants.RESOURCEJARS_OPTION .startsWith(nextWord)) throw new ParseException("The '-resourcejars' option is no longer supported. Please use the '-injars' option for all input"); else if (ConfigurationConstants.SKIP_NON_PUBLIC_LIBRARY_CLASSES_OPTION .startsWith(nextWord)) configuration.skipNonPublicLibraryClasses = parseNoArgument(true); else if (ConfigurationConstants.DONT_SKIP_NON_PUBLIC_LIBRARY_CLASSES_OPTION .startsWith(nextWord)) configuration.skipNonPublicLibraryClasses = parseNoArgument(false); else if (ConfigurationConstants.DONT_SKIP_NON_PUBLIC_LIBRARY_CLASS_MEMBERS_OPTION.startsWith(nextWord)) configuration.skipNonPublicLibraryClassMembers = parseNoArgument(false); else if (ConfigurationConstants.TARGET_OPTION .startsWith(nextWord)) configuration.targetClassVersion = parseClassVersion(); else if (ConfigurationConstants.FORCE_PROCESSING_OPTION .startsWith(nextWord)) configuration.lastModified = parseNoArgument(Long.MAX_VALUE); else if (ConfigurationConstants.KEEP_OPTION .startsWith(nextWord)) configuration.keep = parseKeepClassSpecificationArguments(configuration.keep, true, false, false); else if (ConfigurationConstants.KEEP_CLASS_MEMBERS_OPTION .startsWith(nextWord)) configuration.keep = parseKeepClassSpecificationArguments(configuration.keep, false, false, false); else if (ConfigurationConstants.KEEP_CLASSES_WITH_MEMBERS_OPTION .startsWith(nextWord)) configuration.keep = parseKeepClassSpecificationArguments(configuration.keep, false, true, false); else if (ConfigurationConstants.KEEP_NAMES_OPTION .startsWith(nextWord)) configuration.keep = parseKeepClassSpecificationArguments(configuration.keep, true, false, true); else if (ConfigurationConstants.KEEP_CLASS_MEMBER_NAMES_OPTION .startsWith(nextWord)) configuration.keep = parseKeepClassSpecificationArguments(configuration.keep, false, false, true); else if (ConfigurationConstants.KEEP_CLASSES_WITH_MEMBER_NAMES_OPTION .startsWith(nextWord)) configuration.keep = parseKeepClassSpecificationArguments(configuration.keep, false, true, true); else if (ConfigurationConstants.PRINT_SEEDS_OPTION .startsWith(nextWord)) configuration.printSeeds = parseOptionalFile(); // After '-keep'. else if (ConfigurationConstants.KEEP_DIRECTORIES_OPTION .startsWith(nextWord)) configuration.keepDirectories = parseCommaSeparatedList("directory name", true, true, false, true, false, true, false, false, configuration.keepDirectories); else if (ConfigurationConstants.DONT_SHRINK_OPTION .startsWith(nextWord)) configuration.shrink = parseNoArgument(false); else if (ConfigurationConstants.PRINT_USAGE_OPTION .startsWith(nextWord)) configuration.printUsage = parseOptionalFile(); else if (ConfigurationConstants.WHY_ARE_YOU_KEEPING_OPTION .startsWith(nextWord)) configuration.whyAreYouKeeping = parseClassSpecificationArguments(configuration.whyAreYouKeeping); else if (ConfigurationConstants.DONT_OPTIMIZE_OPTION .startsWith(nextWord)) configuration.optimize = parseNoArgument(false); else if (ConfigurationConstants.OPTIMIZATION_PASSES .startsWith(nextWord)) configuration.optimizationPasses = parseIntegerArgument(); else if (ConfigurationConstants.OPTIMIZATIONS .startsWith(nextWord)) configuration.optimizations = parseCommaSeparatedList("optimization name", true, false, false, false, false, false, false, false, configuration.optimizations); else if (ConfigurationConstants.ASSUME_NO_SIDE_EFFECTS_OPTION .startsWith(nextWord)) configuration.assumeNoSideEffects = parseClassSpecificationArguments(configuration.assumeNoSideEffects); else if (ConfigurationConstants.ALLOW_ACCESS_MODIFICATION_OPTION .startsWith(nextWord)) configuration.allowAccessModification = parseNoArgument(true); else if (ConfigurationConstants.MERGE_INTERFACES_AGGRESSIVELY_OPTION .startsWith(nextWord)) configuration.mergeInterfacesAggressively = parseNoArgument(true); else if (ConfigurationConstants.DONT_OBFUSCATE_OPTION .startsWith(nextWord)) configuration.obfuscate = parseNoArgument(false); else if (ConfigurationConstants.PRINT_MAPPING_OPTION .startsWith(nextWord)) configuration.printMapping = parseOptionalFile(); else if (ConfigurationConstants.APPLY_MAPPING_OPTION .startsWith(nextWord)) configuration.applyMapping = parseFile(); else if (ConfigurationConstants.OBFUSCATION_DICTIONARY_OPTION .startsWith(nextWord)) configuration.obfuscationDictionary = parseFile(); else if (ConfigurationConstants.CLASS_OBFUSCATION_DICTIONARY_OPTION .startsWith(nextWord)) configuration.classObfuscationDictionary = parseFile(); else if (ConfigurationConstants.PACKAGE_OBFUSCATION_DICTIONARY_OPTION .startsWith(nextWord)) configuration.packageObfuscationDictionary = parseFile(); else if (ConfigurationConstants.OVERLOAD_AGGRESSIVELY_OPTION .startsWith(nextWord)) configuration.overloadAggressively = parseNoArgument(true); else if (ConfigurationConstants.USE_UNIQUE_CLASS_MEMBER_NAMES_OPTION .startsWith(nextWord)) configuration.useUniqueClassMemberNames = parseNoArgument(true); else if (ConfigurationConstants.DONT_USE_MIXED_CASE_CLASS_NAMES_OPTION .startsWith(nextWord)) configuration.useMixedCaseClassNames = parseNoArgument(false); else if (ConfigurationConstants.KEEP_PACKAGE_NAMES_OPTION .startsWith(nextWord)) configuration.keepPackageNames = parseCommaSeparatedList("package name", true, true, false, false, true, false, true, false, configuration.keepPackageNames); else if (ConfigurationConstants.FLATTEN_PACKAGE_HIERARCHY_OPTION .startsWith(nextWord)) configuration.flattenPackageHierarchy = ClassUtil.internalClassName(parseOptionalArgument()); else if (ConfigurationConstants.REPACKAGE_CLASSES_OPTION .startsWith(nextWord)) configuration.repackageClasses = ClassUtil.internalClassName(parseOptionalArgument()); else if (ConfigurationConstants.DEFAULT_PACKAGE_OPTION .startsWith(nextWord)) configuration.repackageClasses = ClassUtil.internalClassName(parseOptionalArgument()); else if (ConfigurationConstants.KEEP_ATTRIBUTES_OPTION .startsWith(nextWord)) configuration.keepAttributes = parseCommaSeparatedList("attribute name", true, true, false, false, true, false, false, false, configuration.keepAttributes); else if (ConfigurationConstants.KEEP_PARAMETER_NAMES_OPTION .startsWith(nextWord)) configuration.keepParameterNames = parseNoArgument(true); else if (ConfigurationConstants.RENAME_SOURCE_FILE_ATTRIBUTE_OPTION .startsWith(nextWord)) configuration.newSourceFileAttribute = parseOptionalArgument(); else if (ConfigurationConstants.ADAPT_CLASS_STRINGS_OPTION .startsWith(nextWord)) configuration.adaptClassStrings = parseCommaSeparatedList("class name", true, true, false, false, true, false, true, false, configuration.adaptClassStrings); else if (ConfigurationConstants.ADAPT_RESOURCE_FILE_NAMES_OPTION .startsWith(nextWord)) configuration.adaptResourceFileNames = parseCommaSeparatedList("resource file name", true, true, false, true, false, false, false, false, configuration.adaptResourceFileNames); else if (ConfigurationConstants.ADAPT_RESOURCE_FILE_CONTENTS_OPTION .startsWith(nextWord)) configuration.adaptResourceFileContents = parseCommaSeparatedList("resource file name", true, true, false, true, false, false, false, false, configuration.adaptResourceFileContents); else if (ConfigurationConstants.DONT_PREVERIFY_OPTION .startsWith(nextWord)) configuration.preverify = parseNoArgument(false); else if (ConfigurationConstants.MICRO_EDITION_OPTION .startsWith(nextWord)) configuration.microEdition = parseNoArgument(true); else if (ConfigurationConstants.VERBOSE_OPTION .startsWith(nextWord)) configuration.verbose = parseNoArgument(true); else if (ConfigurationConstants.DONT_NOTE_OPTION .startsWith(nextWord)) configuration.note = parseCommaSeparatedList("class name", true, true, false, false, true, false, true, false, configuration.note); else if (ConfigurationConstants.DONT_WARN_OPTION .startsWith(nextWord)) configuration.warn = parseCommaSeparatedList("class name", true, true, false, false, true, false, true, false, configuration.warn); else if (ConfigurationConstants.IGNORE_WARNINGS_OPTION .startsWith(nextWord)) configuration.ignoreWarnings = parseNoArgument(true); else if (ConfigurationConstants.PRINT_CONFIGURATION_OPTION .startsWith(nextWord)) configuration.printConfiguration = parseOptionalFile(); else if (ConfigurationConstants.DUMP_OPTION .startsWith(nextWord)) configuration.dump = parseOptionalFile(); else { throw new ParseException("Unknown option " + reader.locationDescription()); } } }
Example 13
Source File: ProGuardTask.java From proguard with GNU General Public License v2.0 | 4 votes |
public void setFlattenpackagehierarchy(String flattenPackageHierarchy) { configuration.flattenPackageHierarchy = ClassUtil.internalClassName(flattenPackageHierarchy); }
Example 14
Source File: ProGuardTask.java From proguard with GNU General Public License v2.0 | 4 votes |
public void flattenpackagehierarchy(String flattenPackageHierarchy) { configuration.flattenPackageHierarchy = ClassUtil.internalClassName(flattenPackageHierarchy); }
Example 15
Source File: ProGuardTask.java From bazel with Apache License 2.0 | 4 votes |
public void setRepackageclasses(String repackageClasses) { configuration.repackageClasses = ClassUtil.internalClassName(repackageClasses); }
Example 16
Source File: ProGuardTask.java From bazel with Apache License 2.0 | 4 votes |
public void flattenpackagehierarchy(String flattenPackageHierarchy) { configuration.flattenPackageHierarchy = ClassUtil.internalClassName(flattenPackageHierarchy); }
Example 17
Source File: ProGuardTask.java From proguard with GNU General Public License v2.0 | 4 votes |
public void repackageclasses(String repackageClasses) { configuration.repackageClasses = ClassUtil.internalClassName(repackageClasses); }
Example 18
Source File: ProGuardTask.java From proguard with GNU General Public License v2.0 | 4 votes |
public void flattenpackagehierarchy(String flattenPackageHierarchy) { configuration.flattenPackageHierarchy = ClassUtil.internalClassName(flattenPackageHierarchy); }
Example 19
Source File: ProGuardTask.java From proguard with GNU General Public License v2.0 | 4 votes |
/** * @deprecated Use the repackageclasses attribute instead. */ public void setDefaultpackage(String defaultPackage) { configuration.repackageClasses = ClassUtil.internalClassName(defaultPackage); }
Example 20
Source File: ProGuardTask.java From proguard with GNU General Public License v2.0 | 4 votes |
public void setRepackageclasses(String repackageClasses) { configuration.repackageClasses = ClassUtil.internalClassName(repackageClasses); }