Java Code Examples for proguard.classfile.ProgramClass#attributesAccept()
The following examples show how to use
proguard.classfile.ProgramClass#attributesAccept() .
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: ClassObfuscator.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitProgramClass(ProgramClass programClass) { // Does this class still need a new name? newClassName = newClassName(programClass); if (newClassName == null) { // Make sure the outer class has a name, if it exists. The name will // be stored as the new class name, as a side effect, so we'll be // able to use it as a prefix. programClass.attributesAccept(this); // Figure out a package prefix. The package prefix may actually be // the an outer class prefix, if any, or it may be the fixed base // package, if classes are to be repackaged. String newPackagePrefix = newClassName != null ? newClassName + ClassConstants.INTERNAL_INNER_CLASS_SEPARATOR : newPackagePrefix(ClassUtil.internalPackagePrefix(programClass.getName())); // Come up with a new class name, numeric or ordinary. newClassName = newClassName != null && numericClassName ? generateUniqueNumericClassName(newPackagePrefix) : generateUniqueClassName(newPackagePrefix); setNewClassName(programClass, newClassName); } }
Example 2
Source File: MemberReferenceFixer.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitProgramClass(ProgramClass programClass) { stackSizesMayHaveChanged = false; // Fix the constant pool entries. for (int index = 1; index < programClass.u2constantPoolCount; index++) { Constant constant = programClass.constantPool[index]; if (constant != null) { // Fix the entry, replacing it entirely if needed. this.constantIndex = index; constant.accept(programClass, this); } } // Fix the class members. programClass.fieldsAccept(this); programClass.methodsAccept(this); // Fix the attributes. programClass.attributesAccept(this); }
Example 3
Source File: ConstantPoolRemapper.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitProgramClass(ProgramClass programClass) { // Remap the local constant pool references. programClass.u2thisClass = remapConstantIndex(programClass.u2thisClass); programClass.u2superClass = remapConstantIndex(programClass.u2superClass); remapConstantIndexArray(programClass.u2interfaces, programClass.u2interfacesCount); // Remap the references of the contant pool entries themselves. programClass.constantPoolEntriesAccept(this); // Remap the references in all fields, methods, and attributes. programClass.fieldsAccept(this); programClass.methodsAccept(this); programClass.attributesAccept(this); }
Example 4
Source File: NameMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { keepClassName(programClass); // Make sure any outer class names are kept as well. programClass.attributesAccept(this); }
Example 5
Source File: UsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
protected void markProgramClassBody(ProgramClass programClass) { // Mark this class's name. markConstant(programClass, programClass.u2thisClass); // Mark the superclass. if (programClass.u2superClass != 0) { markConstant(programClass, programClass.u2superClass); } // Give the interfaces preliminary marks. programClass.hierarchyAccept(false, false, true, false, interfaceUsageMarker); // Explicitly mark the <clinit> method. programClass.methodAccept(ClassConstants.INTERNAL_METHOD_NAME_CLINIT, ClassConstants.INTERNAL_METHOD_TYPE_CLINIT, this); // Explicitly mark the parameterless <init> method. programClass.methodAccept(ClassConstants.INTERNAL_METHOD_NAME_INIT, ClassConstants.INTERNAL_METHOD_TYPE_INIT, this); // Process all class members that have already been marked as possibly used. programClass.fieldsAccept(possiblyUsedMemberUsageMarker); programClass.methodsAccept(possiblyUsedMemberUsageMarker); // Mark the attributes. programClass.attributesAccept(this); }
Example 6
Source File: NameAndTypeUsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { // Mark the NameAndType entries referenced by all other constant pool // entries. programClass.constantPoolEntriesAccept(this); // Mark the NameAndType entries referenced by all EnclosingMethod // attributes. programClass.attributesAccept(this); }
Example 7
Source File: AttributeShrinker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { // Compact the array for class attributes. programClass.u2attributesCount = shrinkArray(programClass.attributes, programClass.u2attributesCount); // Compact the attributes in fields, methods, and class attributes, programClass.fieldsAccept(this); programClass.methodsAccept(this); programClass.attributesAccept(this); }
Example 8
Source File: Utf8UsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { // Mark the UTF-8 entries referenced by the other constant pool entries. programClass.constantPoolEntriesAccept(this); // Mark the UTF-8 entries referenced by the fields and methods. programClass.fieldsAccept(this); programClass.methodsAccept(this); // Mark the UTF-8 entries referenced by the attributes. programClass.attributesAccept(this); }
Example 9
Source File: ClassReferenceFixer.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { // Fix the constant pool. programClass.constantPoolEntriesAccept(this); // Fix class members. programClass.fieldsAccept(this); programClass.methodsAccept(this); // Fix the attributes. programClass.attributesAccept(this); }
Example 10
Source File: StringSharer.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { // Replace name strings in the constant pool by shared strings. programClass.constantPoolEntriesAccept(this); // Replace attribute name strings in the constant pool by internalized // strings. programClass.attributesAccept(this); }
Example 11
Source File: ClassReferenceInitializer.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { // Initialize the constant pool entries. programClass.constantPoolEntriesAccept(this); // Initialize all fields and methods. programClass.fieldsAccept(this); programClass.methodsAccept(this); // Initialize the attributes. programClass.attributesAccept(this); }
Example 12
Source File: ClassCleaner.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { clean(programClass); programClass.constantPoolEntriesAccept(this); programClass.fieldsAccept(this); programClass.methodsAccept(this); programClass.attributesAccept(this); }
Example 13
Source File: ReferencedClassVisitor.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { // Visit the constant pool entries. programClass.constantPoolEntriesAccept(this); // Visit the fields and methods. programClass.fieldsAccept(this); programClass.methodsAccept(this); // Visit the attributes. programClass.attributesAccept(this); }
Example 14
Source File: AllAttributeVisitor.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramClass(ProgramClass programClass) { programClass.attributesAccept(attributeVisitor); // Visit the attributes further down the class structure, if required. if (deep) { programClass.fieldsAccept(this); programClass.methodsAccept(this); programClass.attributesAccept(this); } }
Example 15
Source File: ProgramClassWriter.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitProgramClass(ProgramClass programClass) { // Write the magic number. dataOutput.writeInt(programClass.u4magic); // Write the version numbers. dataOutput.writeShort(ClassUtil.internalMinorClassVersion(programClass.u4version)); dataOutput.writeShort(ClassUtil.internalMajorClassVersion(programClass.u4version)); // Write the constant pool. dataOutput.writeShort(programClass.u2constantPoolCount); programClass.constantPoolEntriesAccept(this); // Write the general class information. dataOutput.writeShort(programClass.u2accessFlags); dataOutput.writeShort(programClass.u2thisClass); dataOutput.writeShort(programClass.u2superClass); // Write the interfaces. dataOutput.writeShort(programClass.u2interfacesCount); for (int index = 0; index < programClass.u2interfacesCount; index++) { dataOutput.writeShort(programClass.u2interfaces[index]); } // Write the fields. dataOutput.writeShort(programClass.u2fieldsCount); programClass.fieldsAccept(this); // Write the methods. dataOutput.writeShort(programClass.u2methodsCount); programClass.methodsAccept(this); // Write the class attributes. dataOutput.writeShort(programClass.u2attributesCount); programClass.attributesAccept(this); }
Example 16
Source File: TargetClassChanger.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitProgramClass(ProgramClass programClass) { // Change the references of the constant pool. programClass.constantPoolEntriesAccept(this); // Change the references of the class members. programClass.fieldsAccept(this); programClass.methodsAccept(this); // Change the references of the attributes. programClass.attributesAccept(this); // Is the class itself being retargeted? Clazz targetClass = ClassMerger.getTargetClass(programClass); if (targetClass != null) { // Restore the class name. We have to add a new class entry // to avoid an existing entry with the same name being reused. The // names have to be fixed later, based on their referenced classes. programClass.u2thisClass = addNewClassConstant(programClass, programClass.getName(), programClass); // This class will loose all its interfaces. programClass.u2interfacesCount = 0; // This class will loose all its subclasses. programClass.subClasses = null; } else { // Remove interface classes that are pointing to this class. int newInterfacesCount = 0; for (int index = 0; index < programClass.u2interfacesCount; index++) { Clazz interfaceClass = programClass.getInterface(index); if (!programClass.equals(interfaceClass)) { programClass.u2interfaces[newInterfacesCount++] = programClass.u2interfaces[index]; } } programClass.u2interfacesCount = newInterfacesCount; // Update the subclasses of the superclass and interfaces of the // target class. ConstantVisitor subclassAdder = new ReferencedClassVisitor( new SubclassFilter(programClass, new SubclassAdder(programClass))); programClass.superClassConstantAccept(subclassAdder); programClass.interfaceConstantsAccept(subclassAdder); // TODO: Maybe restore private method references. } }
Example 17
Source File: ClassPrinter.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitProgramClass(ProgramClass programClass) { println("_____________________________________________________________________"); println(visitorInfo(programClass) + " " + "Program class: " + programClass.getName()); indent(); println("Superclass: " + programClass.getSuperName()); println("Major version: 0x" + Integer.toHexString(ClassUtil.internalMajorClassVersion(programClass.u4version))); println("Minor version: 0x" + Integer.toHexString(ClassUtil.internalMinorClassVersion(programClass.u4version))); println("Access flags: 0x" + Integer.toHexString(programClass.u2accessFlags)); println(" = " + ((programClass.u2accessFlags & ClassConstants.INTERNAL_ACC_ANNOTATTION) != 0 ? "@ " : "") + ClassUtil.externalClassAccessFlags(programClass.u2accessFlags) + ((programClass.u2accessFlags & ClassConstants.INTERNAL_ACC_ENUM) != 0 ? "enum " : (programClass.u2accessFlags & ClassConstants.INTERNAL_ACC_INTERFACE) == 0 ? "class " : "") + ClassUtil.externalClassName(programClass.getName()) + (programClass.u2superClass == 0 ? "" : " extends " + ClassUtil.externalClassName(programClass.getSuperName()))); outdent(); println(); println("Interfaces (count = " + programClass.u2interfacesCount + "):"); indent(); programClass.interfaceConstantsAccept(this); outdent(); println(); println("Constant Pool (count = " + programClass.u2constantPoolCount + "):"); indent(); programClass.constantPoolEntriesAccept(this); outdent(); println(); println("Fields (count = " + programClass.u2fieldsCount + "):"); indent(); programClass.fieldsAccept(this); outdent(); println(); println("Methods (count = " + programClass.u2methodsCount + "):"); indent(); programClass.methodsAccept(this); outdent(); println(); println("Class file attributes (count = " + programClass.u2attributesCount + "):"); indent(); programClass.attributesAccept(this); outdent(); println(); }
Example 18
Source File: SourceFileRenamer.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitProgramClass(ProgramClass programClass) { // Only visit the class attributes. programClass.attributesAccept(this); }
Example 19
Source File: ClassShrinker.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitProgramClass(ProgramClass programClass) { // Shrink the arrays for constant pool, interfaces, fields, methods, // and class attributes. programClass.u2interfacesCount = shrinkConstantIndexArray(programClass.constantPool, programClass.u2interfaces, programClass.u2interfacesCount); // Shrinking the constant pool also sets up an index map. programClass.u2constantPoolCount = shrinkConstantPool(programClass.constantPool, programClass.u2constantPoolCount); programClass.u2fieldsCount = shrinkArray(programClass.fields, programClass.u2fieldsCount); programClass.u2methodsCount = shrinkArray(programClass.methods, programClass.u2methodsCount); programClass.u2attributesCount = shrinkArray(programClass.attributes, programClass.u2attributesCount); // Compact the remaining fields, methods, and attributes, // and remap their references to the constant pool. programClass.fieldsAccept(this); programClass.methodsAccept(this); programClass.attributesAccept(this); // Remap all constant pool references. constantPoolRemapper.setConstantIndexMap(constantIndexMap); constantPoolRemapper.visitProgramClass(programClass); // Remove the unused interfaces from the class signature. programClass.attributesAccept(new SignatureShrinker()); // Compact the extra field pointing to the subclasses of this class. programClass.subClasses = shrinkToNewArray(programClass.subClasses); }