Java Code Examples for proguard.classfile.ClassConstants#INTERNAL_ACC_NATIVE
The following examples show how to use
proguard.classfile.ClassConstants#INTERNAL_ACC_NATIVE .
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: SideEffectMethodMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) { if (!hasSideEffects(programMethod) && !NoSideEffectMethodMarker.hasNoSideEffects(programMethod)) { // Initialize the return value. hasSideEffects = (programMethod.getAccessFlags() & (ClassConstants.INTERNAL_ACC_NATIVE | ClassConstants.INTERNAL_ACC_SYNCHRONIZED)) != 0; // Look further if the method hasn't been marked yet. if (!hasSideEffects) { // Investigate the actual code. programMethod.attributesAccept(programClass, this); } // Mark the method depending on the return value. if (hasSideEffects) { markSideEffects(programMethod); newSideEffectCount++; } } }
Example 2
Source File: ClassUtil.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Converts internal method access flags into an external access description. * @param accessFlags the method access flags. * @param prefix a prefix that is added to each access modifier. * @return the external method access description, * e.g. "public synchronized ". */ public static String externalMethodAccessFlags(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) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_PRIVATE).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_PROTECTED) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_PROTECTED).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_STATIC) != 0) { 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_SYNCHRONIZED) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_SYNCHRONIZED).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_BRIDGE) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_BRIDGE).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_VARARGS) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_VARARGS).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_NATIVE) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_NATIVE).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_ABSTRACT) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_ABSTRACT).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_STRICT) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_STRICT).append(' '); } if ((accessFlags & ClassConstants.INTERNAL_ACC_SYNTHETIC) != 0) { string.append(prefix).append(ClassConstants.EXTERNAL_ACC_SYNTHETIC).append(' '); } return string.toString(); }
Example 3
Source File: ParameterUsageMarker.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) { int parameterSize = ClassUtil.internalMethodParameterSize(programMethod.getDescriptor(programClass), programMethod.getAccessFlags()); if (parameterSize > 0) { int accessFlags = programMethod.getAccessFlags(); // Must we mark the 'this' parameter? if (markThisParameter && (accessFlags & ClassConstants.INTERNAL_ACC_STATIC) == 0) { // Mark the 'this' parameter. markParameterUsed(programMethod, 0); } // Must we mark all other parameters? if (markAllParameters) { // Mark all parameters, without the 'this' parameter. markUsedParameters(programMethod, (accessFlags & ClassConstants.INTERNAL_ACC_STATIC) != 0 ? -1L : -2L); } // Is it a native method? if ((accessFlags & ClassConstants.INTERNAL_ACC_NATIVE) != 0) { // Mark all parameters. markUsedParameters(programMethod, -1L); } // Is it an abstract method? else if ((accessFlags & ClassConstants.INTERNAL_ACC_ABSTRACT) != 0) { // Mark the 'this' parameter. markParameterUsed(programMethod, 0); } // Is it a non-native, concrete method? else { // Is the method not static, but synchronized, or can it have // other implementations, or is it a class instance initializer? if ((accessFlags & ClassConstants.INTERNAL_ACC_STATIC) == 0 && ((accessFlags & ClassConstants.INTERNAL_ACC_SYNCHRONIZED) != 0 || programClass.mayHaveImplementations(programMethod) || programMethod.getName(programClass).equals(ClassConstants.INTERNAL_METHOD_NAME_INIT))) { // Mark the 'this' parameter. markParameterUsed(programMethod, 0); } // Mark the parameters that are used by the code. programMethod.attributesAccept(programClass, this); } if (DEBUG) { System.out.print("ParameterUsageMarker: ["+programClass.getName() +"."+programMethod.getName(programClass)+programMethod.getDescriptor(programClass)+"]: "); for (int index = 0; index < parameterSize; index++) { System.out.print(isParameterUsed(programMethod, index) ? '+' : '-'); } System.out.println(); } } // Set the parameter size. setParameterSize(programMethod, parameterSize); }
Example 4
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 5
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--; } }