proguard.classfile.Clazz Java Examples
The following examples show how to use
proguard.classfile.Clazz.
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: MethodDescriptorShrinker.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitSignatureAttribute(Clazz clazz, Method method, SignatureAttribute signatureAttribute) { // Compute the new signature. String signature = clazz.getString(signatureAttribute.u2signatureIndex); String newSignature = shrinkDescriptor(method, signature); // Update the signature. signatureAttribute.u2signatureIndex = new ConstantPoolEditor((ProgramClass)clazz).addUtf8Constant(newSignature); // Update the referenced classes. signatureAttribute.referencedClasses = shrinkReferencedClasses(method, signature, signatureAttribute.referencedClasses); }
Example #2
Source File: MemberDescriptorSpecializer.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitProgramField(ProgramClass programClass, ProgramField programField) { Value parameterValue = StoringInvocationUnit.getFieldValue(programField); if (parameterValue.computationalType() == Value.TYPE_REFERENCE) { Clazz referencedClass = parameterValue.referenceValue().getReferencedClass(); if (programField.referencedClass != referencedClass) { if (DEBUG) { System.out.println("MemberDescriptorSpecializer: "+programClass.getName()+"."+programField.getName(programClass)+" "+programField.getDescriptor(programClass)); System.out.println(" "+programField.referencedClass.getName()+" -> "+referencedClass.getName()); } programField.referencedClass = referencedClass; // Visit the field, if required. if (extraParameterMemberVisitor != null) { extraParameterMemberVisitor.visitProgramField(programClass, programField); } } } }
Example #3
Source File: ConstantPoolRemapper.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitInnerClassesInfo(Clazz clazz, InnerClassesInfo innerClassesInfo) { if (innerClassesInfo.u2innerClassIndex != 0) { innerClassesInfo.u2innerClassIndex = remapConstantIndex(innerClassesInfo.u2innerClassIndex); } if (innerClassesInfo.u2outerClassIndex != 0) { innerClassesInfo.u2outerClassIndex = remapConstantIndex(innerClassesInfo.u2outerClassIndex); } if (innerClassesInfo.u2innerNameIndex != 0) { innerClassesInfo.u2innerNameIndex = remapConstantIndex(innerClassesInfo.u2innerNameIndex); } }
Example #4
Source File: ConcreteClassDownTraveler.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitLibraryClass(LibraryClass libraryClass) { // Is this an abstract class or interface? if ((libraryClass.getAccessFlags() & (ClassConstants.INTERNAL_ACC_INTERFACE | ClassConstants.INTERNAL_ACC_ABSTRACT)) != 0) { // Travel down the hierarchy. Clazz[] subClasses = libraryClass.subClasses; if (subClasses != null) { for (int index = 0; index < subClasses.length; index++) { subClasses[index].accept(this); } } } else { // Visit the class. Don't descend any further. libraryClass.accept(classVisitor); } }
Example #5
Source File: ClassPrinter.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) { println(visitorInfo(codeAttribute) + " Code attribute instructions (code length = "+ codeAttribute.u4codeLength + ", locals = "+ codeAttribute.u2maxLocals + ", stack = "+ codeAttribute.u2maxStack + "):"); indent(); codeAttribute.instructionsAccept(clazz, method, this); println("Code attribute exceptions (count = " + codeAttribute.u2exceptionTableLength + "):"); codeAttribute.exceptionsAccept(clazz, method, this); println("Code attribute attributes (attribute count = " + codeAttribute.u2attributesCount + "):"); codeAttribute.attributesAccept(clazz, method, this); outdent(); }
Example #6
Source File: BootstrapMethodsAttribute.java From proguard with GNU General Public License v2.0 | 5 votes |
/** * Applies the given visitor to the specified bootstrap method info * entry. */ public void bootstrapMethodEntryAccept(Clazz clazz, int bootstrapMethodIndex, BootstrapMethodInfoVisitor bootstrapMethodInfoVisitor) { // We don't need double dispatching here, since there is only one // type of BootstrapMethodInfo. bootstrapMethodInfoVisitor.visitBootstrapMethodInfo(clazz, bootstrapMethods[bootstrapMethodIndex]); }
Example #7
Source File: AttributeNameFilter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitConstantValueAttribute(Clazz clazz, Field field, ConstantValueAttribute constantValueAttribute) { if (accepted(clazz, constantValueAttribute)) { constantValueAttribute.accept(clazz, field, attributeVisitor); } }
Example #8
Source File: VisitorDTO.java From atlas with Apache License 2.0 | 5 votes |
public String findRootLibClazz(String className) { if (isLibClazz(className)) { return className; } Clazz clazz = currentClassPool.getClass(className); //assert clazz!=null; if (null == clazz) { return ""; } return findRootLibClazz(clazz); }
Example #9
Source File: ConstantPoolRemapper.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitConstantElementValue(Clazz clazz, Annotation annotation, ConstantElementValue constantElementValue) { constantElementValue.u2elementNameIndex = remapConstantIndex(constantElementValue.u2elementNameIndex); constantElementValue.u2constantValueIndex = remapConstantIndex(constantElementValue.u2constantValueIndex); }
Example #10
Source File: EvaluationSimplifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Replaces the integer pushing instruction at the given offset by a simpler * push instruction, if possible. */ private void replaceIntegerPushInstruction(Clazz clazz, int offset, Instruction instruction) { replaceIntegerPushInstruction(clazz, offset, instruction, partialEvaluator.getVariablesBefore(offset).size()); }
Example #11
Source File: RequiredAttributeFilter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) { if (optionalAttributeVisitor != null) { runtimeInvisibleAnnotationsAttribute.accept(clazz, field, optionalAttributeVisitor); } }
Example #12
Source File: ProgramClassReader.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitLocalVariableTypeInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeInfo localVariableTypeInfo) { localVariableTypeInfo.u2startPC = dataInput.readUnsignedShort(); localVariableTypeInfo.u2length = dataInput.readUnsignedShort(); localVariableTypeInfo.u2nameIndex = dataInput.readUnsignedShort(); localVariableTypeInfo.u2signatureIndex = dataInput.readUnsignedShort(); localVariableTypeInfo.u2index = dataInput.readUnsignedShort(); }
Example #13
Source File: ConstantPoolEditor.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Finds or creates a InterfaceMethodrefConstant constant pool entry with the * given class constant pool entry index and name and type constant pool * entry index. * @return the constant pool index of the InterfaceMethodrefConstant. */ public int addInterfaceMethodrefConstant(int classIndex, int nameAndTypeIndex, Clazz referencedClass, Member referencedMember) { int constantPoolCount = targetClass.u2constantPoolCount; Constant[] constantPool = targetClass.constantPool; // Check if the entry already exists. for (int index = 1; index < constantPoolCount; index++) { Constant constant = constantPool[index]; if (constant != null && constant.getTag() == ClassConstants.CONSTANT_InterfaceMethodref) { InterfaceMethodrefConstant methodrefConstant = (InterfaceMethodrefConstant)constant; if (methodrefConstant.u2classIndex == classIndex && methodrefConstant.u2nameAndTypeIndex == nameAndTypeIndex) { return index; } } } return addConstant(new InterfaceMethodrefConstant(classIndex, nameAndTypeIndex, referencedClass, referencedMember)); }
Example #14
Source File: ClassMerger.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public static void setTargetClass(Clazz clazz, Clazz targetClass) { ClassOptimizationInfo info = ClassOptimizationInfo.getClassOptimizationInfo(clazz); if (info != null) { info.setTargetClass(targetClass); } }
Example #15
Source File: InstructionSequenceMatcher.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitStringConstant(Clazz clazz, StringConstant stringConstant) { StringConstant stringPatternConstant = (StringConstant)patternConstant; // Check the UTF-8 constant. matchingConstant = matchingConstantIndices(clazz, stringConstant.u2stringIndex, stringPatternConstant.u2stringIndex); }
Example #16
Source File: EvaluationSimplifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Deletes the reference popping instruction at the given offset, if * it is at the start of a subroutine that doesn't return or a subroutine * that is only called from one place. */ private void deleteReferencePopInstruction(Clazz clazz, int offset, Instruction instruction) { if (partialEvaluator.isSubroutineStart(offset) && (!partialEvaluator.isSubroutineReturning(offset) || partialEvaluator.branchOrigins(offset).instructionOffsetCount() == 1)) { if (DEBUG) System.out.println(" Deleting store of subroutine return address "+instruction.toString(offset)); // A reference value can only be specific if it is null. codeAttributeEditor.deleteInstruction(offset); } }
Example #17
Source File: ReferencedClassVisitor.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitAnnotation(Clazz clazz, Annotation annotation) { // Let the visitor visit the classes referenced in the annotation. annotation.referencedClassesAccept(classVisitor); // Visit the element values. annotation.elementValuesAccept(clazz, this); }
Example #18
Source File: AnnotationTypeFilter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitAnnotation(Clazz clazz, Field field, Annotation annotation) { if (accepted(annotation.getType(clazz))) { annotationVisitor.visitAnnotation(clazz, field, annotation); } }
Example #19
Source File: IdentifiedReferenceValue.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Creates a new long value with the given ID. */ public IdentifiedReferenceValue(String type, Clazz referencedClass, boolean mayBeNull, ValueFactory valuefactory, int id) { super(type, referencedClass, mayBeNull); this.valuefactory = valuefactory; this.id = id; }
Example #20
Source File: ClassPrinter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitFullFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, FullFrame fullFrame) { print(visitorInfo(fullFrame) + " [" + offset + "]" + " Var: "); fullFrame.variablesAccept(clazz, method, codeAttribute, offset, this); ps.print(", Stack: "); fullFrame.stackAccept(clazz, method, codeAttribute, offset, this); println(); }
Example #21
Source File: ClassMerger.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Returns whether the given class or its subclasses shadow any methods in * the given target class. */ private boolean shadowsAnyMethods(Clazz clazz, Clazz targetClass) { MemberCounter counter = new MemberCounter(); // Visit all private methods, counting the ones that are shadowing // non-private methods in the class hierarchy of the target class. clazz.hierarchyAccept(true, false, false, true, new AllMethodVisitor( new MemberAccessFilter(ClassConstants.INTERNAL_ACC_PRIVATE, 0, new MemberNameFilter(new NotMatcher(new FixedStringMatcher(ClassConstants.INTERNAL_METHOD_NAME_INIT)), new SimilarMemberVisitor(targetClass, true, true, true, false, new MemberAccessFilter(0, ClassConstants.INTERNAL_ACC_PRIVATE, counter)))))); // Visit all static methods, counting the ones that are shadowing // non-private methods in the class hierarchy of the target class. clazz.hierarchyAccept(true, false, false, true, new AllMethodVisitor( new MemberAccessFilter(ClassConstants.INTERNAL_ACC_STATIC, 0, new MemberNameFilter(new NotMatcher(new FixedStringMatcher(ClassConstants.INTERNAL_METHOD_NAME_CLINIT)), new SimilarMemberVisitor(targetClass, true, true, true, false, new MemberAccessFilter(0, ClassConstants.INTERNAL_ACC_PRIVATE, counter)))))); return counter.getCount() > 0; }
Example #22
Source File: DotClassClassVisitor.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction) { byte opcode = constantInstruction.opcode; // Could this instruction be a .class construct? if (opcode == InstructionConstants.OP_LDC || opcode == InstructionConstants.OP_LDC_W) { clazz.constantPoolEntryAccept(constantInstruction.constantIndex, this); } }
Example #23
Source File: ProgramClassReader.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute) { // Read the default element value. ElementValue elementValue = createElementValue(); elementValue.accept(clazz, null, this); annotationDefaultAttribute.defaultValue = elementValue; }
Example #24
Source File: RequiredAttributeFilter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitDeprecatedAttribute(Clazz clazz, DeprecatedAttribute deprecatedAttribute) { if (optionalAttributeVisitor != null) { deprecatedAttribute.accept(clazz, optionalAttributeVisitor); } }
Example #25
Source File: UsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitClassConstant(Clazz clazz, ClassConstant classConstant) { if (shouldBeMarkedAsUsed(classConstant)) { markAsUsed(classConstant); markConstant(clazz, classConstant.u2nameIndex); // Mark the referenced class itself. classConstant.referencedClassAccept(this); } }
Example #26
Source File: RequiredAttributeFilter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitSourceDirAttribute(Clazz clazz, SourceDirAttribute sourceDirAttribute) { if (optionalAttributeVisitor != null) { sourceDirAttribute.accept(clazz, optionalAttributeVisitor); } }
Example #27
Source File: MemberReferenceFixer.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) { // Recompute the maximum stack size if necessary. if (stackSizesMayHaveChanged) { stackSizeUpdater.visitCodeAttribute(clazz, method, codeAttribute); } // Fix the nested attributes. codeAttribute.attributesAccept(clazz, method, this); }
Example #28
Source File: Utf8UsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute) { markCpUtf8Entry(clazz, annotationDefaultAttribute.u2attributeNameIndex); // Mark the UTF-8 entries referenced by the element value. annotationDefaultAttribute.defaultValueAccept(clazz, this); }
Example #29
Source File: MultiAttributeVisitor.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitDeprecatedAttribute(Clazz clazz, Method method, DeprecatedAttribute deprecatedAttribute) { for (int index = 0; index < attributeVisitors.length; index++) { attributeVisitors[index].visitDeprecatedAttribute(clazz, method, deprecatedAttribute); } }
Example #30
Source File: AttributeNameFilter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitRuntimeInvisibleAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleAnnotationsAttribute runtimeInvisibleAnnotationsAttribute) { if (accepted(clazz, runtimeInvisibleAnnotationsAttribute)) { runtimeInvisibleAnnotationsAttribute.accept(clazz, field, attributeVisitor); } }