Java Code Examples for proguard.classfile.ClassConstants#INTERNAL_ACC_INTERFACE
The following examples show how to use
proguard.classfile.ClassConstants#INTERNAL_ACC_INTERFACE .
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: ConcreteClassDownTraveler.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitProgramClass(ProgramClass programClass) { // Is this an abstract class or an interface? if ((programClass.getAccessFlags() & (ClassConstants.INTERNAL_ACC_INTERFACE | ClassConstants.INTERNAL_ACC_ABSTRACT)) != 0) { // Travel down the hierarchy. Clazz[] subClasses = programClass.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. programClass.accept(classVisitor); } }
Example 2
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 3
Source File: MethodInvocationFixer.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
private void debug(Clazz clazz, Method method, int offset, ConstantInstruction constantInstruction, Instruction replacementInstruction) { System.out.println("MethodInvocationFixer:"); System.out.println(" Class = "+clazz.getName()); System.out.println(" Method = "+method.getName(clazz)+method.getDescriptor(clazz)); System.out.println(" Instruction = "+constantInstruction.toString(offset)); System.out.println(" -> Class = "+referencedClass); System.out.println(" Method = "+referencedMethod); if ((referencedClass.getAccessFlags() & ClassConstants.INTERNAL_ACC_INTERFACE) != 0) { System.out.println(" Parameter size = "+(ClassUtil.internalMethodParameterSize(referencedMethod.getDescriptor(referencedMethodClass), false))); } System.out.println(" Replacement instruction = "+replacementInstruction.toString(offset)); }
Example 4
Source File: MemberReferenceFixer.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitClassConstant(Clazz clazz, ClassConstant classConstant) { // Check if this class entry is an array type. if (ClassUtil.isInternalArrayType(classConstant.getName(clazz))) { isInterfaceMethod = false; } else { // Check if this class entry refers to an interface class. Clazz referencedClass = classConstant.referencedClass; if (referencedClass != null) { isInterfaceMethod = (referencedClass.getAccessFlags() & ClassConstants.INTERNAL_ACC_INTERFACE) != 0; } } }
Example 5
Source File: ClassFinalizer.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void visitProgramClass(ProgramClass programClass) { // If the class is not final/interface/abstract, // and it is not being kept, // and it doesn't have any subclasses, // then make it final. if ((programClass.u2accessFlags & (ClassConstants.INTERNAL_ACC_FINAL | ClassConstants.INTERNAL_ACC_INTERFACE | ClassConstants.INTERNAL_ACC_ABSTRACT)) == 0 && !KeepMarker.isKept(programClass) && programClass.subClasses == null) { programClass.u2accessFlags |= ClassConstants.INTERNAL_ACC_FINAL; // Visit the class, if required. if (extraClassVisitor != null) { extraClassVisitor.visitProgramClass(programClass); } } }
Example 6
Source File: ClassMerger.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Returns whether the given class would introduce any abstract methods * in the target class. */ private boolean introducesUnwantedAbstractMethods(Clazz clazz, ProgramClass targetClass) { // It's ok if the target class is already abstract and it has at most // the class as a subclass. if ((targetClass.getAccessFlags() & (ClassConstants.INTERNAL_ACC_ABSTRACT | ClassConstants.INTERNAL_ACC_INTERFACE)) != 0 && (targetClass.subClasses == null || isOnlySubClass(clazz, targetClass))) { return false; } MemberCounter counter = new MemberCounter(); Set targetSet = new HashSet(); // Collect all abstract methods, and similar abstract methods in the // class hierarchy of the target class. clazz.methodsAccept(new MemberAccessFilter(ClassConstants.INTERNAL_ACC_ABSTRACT, 0, new MultiMemberVisitor(new MemberVisitor[] { counter, new SimilarMemberVisitor(targetClass, true, true, true, false, new MemberAccessFilter(ClassConstants.INTERNAL_ACC_ABSTRACT, 0, new MemberCollector(targetSet))) }))); return targetSet.size() < counter.getCount(); }
Example 7
Source File: ClassUtil.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Converts internal class access flags into an external access description. * @param accessFlags the class access flags. * @param prefix a prefix that is added to each access modifier. * @return the external class access description, * e.g. "<code>public final </code>". */ public static String externalClassAccessFlags(int accessFlags, String prefix) { if (accessFlags == 0) { return EMPTY_STRING; } StringBuffer string = new StringBuffer(50); if ((accessFlags & ClassConstants.INTERNAL_ACC_PUBLIC) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_PUBLIC).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_PRIVATE) != 0) { // Only in InnerClasses attributes. string.append(prefix).append(ClassConstants.EXTERNAL_ACC_PRIVATE).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_PROTECTED) != 0) { // Only in InnerClasses attributes. string.append(prefix).append(ClassConstants.EXTERNAL_ACC_PROTECTED).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_STATIC) != 0) { // Only in InnerClasses attributes. string.append(prefix).append(ClassConstants.EXTERNAL_ACC_STATIC).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_FINAL) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_FINAL).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_ANNOTATTION) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_ANNOTATION); } if ((accessFlags & ClassConstants.INTERNAL_ACC_INTERFACE) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_INTERFACE).append(' '); } else if ((accessFlags & ClassConstants.INTERNAL_ACC_ENUM) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_ENUM).append(' '); } else if ((accessFlags & ClassConstants.INTERNAL_ACC_ABSTRACT) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_ABSTRACT).append(' '); } else if ((accessFlags & ClassConstants.INTERNAL_ACC_SYNTHETIC) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_SYNTHETIC).append(' '); } return string.toString(); }
Example 8
Source File: ConfigurationWriter.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
private void writeOption(String optionName, ClassSpecification classSpecification) { writer.println(); // Write out the comments for this option. writeComments(classSpecification.comments); writer.print(optionName); writer.print(' '); // Write out the required annotation, if any. if (classSpecification.annotationType != null) { writer.print(ConfigurationConstants.ANNOTATION_KEYWORD); writer.print(ClassUtil.externalType(classSpecification.annotationType)); writer.print(' '); } // Write out the class access flags. writer.print(ClassUtil.externalClassAccessFlags(classSpecification.requiredUnsetAccessFlags, ConfigurationConstants.NEGATOR_KEYWORD)); writer.print(ClassUtil.externalClassAccessFlags(classSpecification.requiredSetAccessFlags)); // Write out the class keyword, if we didn't write the interface // keyword earlier. if (((classSpecification.requiredSetAccessFlags | classSpecification.requiredUnsetAccessFlags) & (ClassConstants.INTERNAL_ACC_INTERFACE | ClassConstants.INTERNAL_ACC_ENUM)) == 0) { writer.print(ConfigurationConstants.CLASS_KEYWORD); } writer.print(' '); // Write out the class name. writer.print(classSpecification.className != null ? ClassUtil.externalClassName(classSpecification.className) : ConfigurationConstants.ANY_CLASS_KEYWORD); // Write out the extends template, if any. if (classSpecification.extendsAnnotationType != null || classSpecification.extendsClassName != null) { writer.print(' '); writer.print(ConfigurationConstants.EXTENDS_KEYWORD); writer.print(' '); // Write out the required extends annotation, if any. if (classSpecification.extendsAnnotationType != null) { writer.print(ConfigurationConstants.ANNOTATION_KEYWORD); writer.print(ClassUtil.externalType(classSpecification.extendsAnnotationType)); writer.print(' '); } // Write out the extended class name. writer.print(classSpecification.extendsClassName != null ? ClassUtil.externalClassName(classSpecification.extendsClassName) : ConfigurationConstants.ANY_CLASS_KEYWORD); } // Write out the keep field and keep method options, if any. if (classSpecification.fieldSpecifications != null || classSpecification.methodSpecifications != null) { writer.print(' '); writer.println(ConfigurationConstants.OPEN_KEYWORD); writeFieldSpecification( classSpecification.fieldSpecifications); writeMethodSpecification(classSpecification.methodSpecifications); writer.println(ConfigurationConstants.CLOSE_KEYWORD); } else { writer.println(); } }
Example 9
Source File: TailRecursionSimplifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute) { int accessFlags = method.getAccessFlags(); if (// Only check the method if it is private, static, or final. (accessFlags & (ClassConstants.INTERNAL_ACC_PRIVATE | ClassConstants.INTERNAL_ACC_STATIC | ClassConstants.INTERNAL_ACC_FINAL)) != 0 && // Only check the method if it is not synchronized, etc. (accessFlags & (ClassConstants.INTERNAL_ACC_SYNCHRONIZED | ClassConstants.INTERNAL_ACC_NATIVE | ClassConstants.INTERNAL_ACC_INTERFACE | ClassConstants.INTERNAL_ACC_ABSTRACT)) == 0) { // codeAttributeComposer.DEBUG = DEBUG = // clazz.getName().equals("abc/Def") && // method.getName(clazz).equals("abc"); targetMethod = method; inlinedAny = false; codeAttributeComposer.reset(); // The code may expand, due to expanding constant and variable // instructions. codeAttributeComposer.beginCodeFragment(codeAttribute.u4codeLength); // Copy the instructions. codeAttribute.instructionsAccept(clazz, method, this); // Update the code attribute if any code has been inlined. if (inlinedAny) { // Copy the exceptions. codeAttribute.exceptionsAccept(clazz, method, this); // Append a label just after the code. codeAttributeComposer.appendLabel(codeAttribute.u4codeLength); codeAttributeComposer.endCodeFragment(); codeAttributeComposer.visitCodeAttribute(clazz, method, codeAttribute); } } }
Example 10
Source File: MethodInliner.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) { int accessFlags = programMethod.getAccessFlags(); if (// Only inline the method if it is private, static, or final. (accessFlags & (ClassConstants.INTERNAL_ACC_PRIVATE | ClassConstants.INTERNAL_ACC_STATIC | ClassConstants.INTERNAL_ACC_FINAL)) != 0 && // Only inline the method if it is not synchronized, etc. (accessFlags & (ClassConstants.INTERNAL_ACC_SYNCHRONIZED | ClassConstants.INTERNAL_ACC_NATIVE | ClassConstants.INTERNAL_ACC_INTERFACE | ClassConstants.INTERNAL_ACC_ABSTRACT)) == 0 && // Don't inline an <init> method, except in an <init> method in the // same class. // (!programMethod.getName(programClass).equals(ClassConstants.INTERNAL_METHOD_NAME_INIT) || // (programClass.equals(targetClass) && // targetMethod.getName(targetClass).equals(ClassConstants.INTERNAL_METHOD_NAME_INIT))) && !programMethod.getName(programClass).equals(ClassConstants.INTERNAL_METHOD_NAME_INIT) && // Don't inline a method into itself. (!programMethod.equals(targetMethod) || !programClass.equals(targetClass)) && // Only inline the method if it isn't recursing. !inliningMethods.contains(programMethod) && // Only inline the method if its target class has at least the // same version number as the source class, in order to avoid // introducing incompatible constructs. targetClass.u4version >= programClass.u4version && // Only inline the method if it doesn't invoke a super method, or if // it is in the same class. (!SuperInvocationMarker.invokesSuperMethods(programMethod) || programClass.equals(targetClass)) && // Only inline the method if it doesn't branch backward while there // are uninitialized objects. (!BackwardBranchMarker.branchesBackward(programMethod) || uninitializedObjectCount == 0) && // Only inline if the code access of the inlined method allows it. (allowAccessModification || ((!AccessMethodMarker.accessesPrivateCode(programMethod) || programClass.equals(targetClass)) && (!AccessMethodMarker.accessesPackageCode(programMethod) || ClassUtil.internalPackageName(programClass.getName()).equals( ClassUtil.internalPackageName(targetClass.getName()))))) && // (!AccessMethodMarker.accessesProtectedCode(programMethod) || // targetClass.extends_(programClass) || // targetClass.implements_(programClass)) || (!AccessMethodMarker.accessesProtectedCode(programMethod) || programClass.equals(targetClass)) && // Only inline the method if it doesn't catch exceptions, or if it // is invoked with an empty stack. (!CatchExceptionMarker.catchesExceptions(programMethod) || emptyInvokingStack) && // Only inline the method if it comes from the a class with at most // a subset of the initialized superclasses. (programClass.equals(targetClass) || initializedSuperClasses(targetClass).containsAll(initializedSuperClasses(programClass)))) { boolean oldInlining = inlining; inlining = true; inliningMethods.push(programMethod); // Inline the method body. programMethod.attributesAccept(programClass, this); // Update the optimization information of the target method. MethodOptimizationInfo info = MethodOptimizationInfo.getMethodOptimizationInfo(targetMethod); if (info != null) { info.merge(MethodOptimizationInfo.getMethodOptimizationInfo(programMethod)); } inlining = oldInlining; inliningMethods.pop(); } else if (programMethod.getName(programClass).equals(ClassConstants.INTERNAL_METHOD_NAME_INIT)) { uninitializedObjectCount--; } }