Java Code Examples for proguard.classfile.instruction.Instruction#stackPushCount()
The following examples show how to use
proguard.classfile.instruction.Instruction#stackPushCount() .
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: EscapingClassMarker.java From proguard with GNU General Public License v2.0 | 5 votes |
public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) { // Does the instruction push a value that escapes? // We'll also count values that are returned, since they may be // downcast and the downcast type may escape in some calling // method. // TODO: Refine check: is a value is downcast to an escaping class, while it is being returned? if (instruction.stackPushCount(clazz) == 1 && (referenceEscapeChecker.isInstanceEscaping(offset) || referenceEscapeChecker.isInstanceReturned(offset))) { TracedStack stackAfter = partialEvaluator.getStackAfter(offset); Value stackEntry = stackAfter.getTop(0); // Is it really a reference type? if (stackEntry.computationalType() == Value.TYPE_REFERENCE) { // Is it a plain class reference type? ReferenceValue referenceValue = stackEntry.referenceValue(); if (referenceValue.isNull() != Value.ALWAYS && !ClassUtil.isInternalArrayType(referenceValue.getType())) { // Do we know the class? Clazz referencedClass = referenceValue.getReferencedClass(); if (referencedClass != null) { if (DEBUG) { System.out.println("EscapingClassMarker: ["+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz)+"]: "+instruction.toString(offset)+" pushes escaping ["+referencedClass.getName()+"]"); } // Mark it, along with its superclasses. referencedClass.hierarchyAccept(true, true, true, false, this); } } } } }