From 9f606f95f03a75961498803e24bee6799a7c0885 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 27 Feb 2012 18:34:24 -0800 Subject: Revert "Upgrade from Progaurd 4.4 to 4.7." This reverts commit cfead78069f3dc32998dc118ee08cab3867acea2. Bug: 6079915 --- .../classfile/editor/MethodInvocationFixer.java | 57 +++++++++++++--------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'src/proguard/classfile/editor/MethodInvocationFixer.java') diff --git a/src/proguard/classfile/editor/MethodInvocationFixer.java b/src/proguard/classfile/editor/MethodInvocationFixer.java index f33ef1d..ef76012 100644 --- a/src/proguard/classfile/editor/MethodInvocationFixer.java +++ b/src/proguard/classfile/editor/MethodInvocationFixer.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2011 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -28,6 +28,7 @@ import proguard.classfile.constant.visitor.ConstantVisitor; import proguard.classfile.instruction.*; import proguard.classfile.instruction.visitor.InstructionVisitor; import proguard.classfile.util.*; +import proguard.classfile.visitor.*; /** * This AttributeVisitor fixes all inappropriate special/virtual/static/interface @@ -39,7 +40,9 @@ public class MethodInvocationFixer extends SimplifiedVisitor implements AttributeVisitor, InstructionVisitor, - ConstantVisitor + ConstantVisitor, + ClassVisitor, + MemberVisitor { private static final boolean DEBUG = false; @@ -85,8 +88,7 @@ implements AttributeVisitor, clazz.constantPoolEntryAccept(constantIndex, this); // Did we find the called class and method? - if (referencedClass != null && - referencedMethod != null) + if (referencedMethod != null) { // Do we need to update the opcode? byte opcode = constantInstruction.opcode; @@ -166,7 +168,6 @@ implements AttributeVisitor, // but not a super call)? if (opcode != InstructionConstants.OP_INVOKEVIRTUAL && (opcode != InstructionConstants.OP_INVOKESPECIAL || - clazz.equals(referencedClass) || !clazz.extends_(referencedClass))) { // Replace the invocation by an invokevirtual instruction. @@ -193,30 +194,40 @@ implements AttributeVisitor, public void visitAnyMethodrefConstant(Clazz clazz, RefConstant refConstant) { - // Remember the referenced class. Note that we're interested in the - // class of the method reference, not in the class in which the - // method was actually found, unless it is an array type. - // - if (ClassUtil.isInternalArrayType(refConstant.getClassName(clazz))) - { - // For an array type, the class will be java.lang.Object. - referencedClass = refConstant.referencedClass; - } - else - { - clazz.constantPoolEntryAccept(refConstant.u2classIndex, this); - } - - // Remember the referenced method. - referencedMethodClass = refConstant.referencedClass; - referencedMethod = refConstant.referencedMember; + // Check if this is an interface method. Note that we're interested in + // the class of the method reference, not in the class in which the + // method was actually found. + //refConstant.referencedClassAccept(this); + clazz.constantPoolEntryAccept(refConstant.u2classIndex, this); + + // Get the referenced access flags and names. + refConstant.referencedMemberAccept(this); } public void visitClassConstant(Clazz clazz, ClassConstant classConstant) + { + // Check if this is an interface class. + classConstant.referencedClassAccept(this); + } + + + // Implementations for ClassVisitor. + + public void visitAnyClass(Clazz clazz) { // Remember the referenced class. - referencedClass = classConstant.referencedClass; + referencedClass = clazz; + } + + + // Implementations for MemberVisitor. + + public void visitAnyMember(Clazz clazz, Member member) + { + // Remember the referenced method. + referencedMethodClass = clazz; + referencedMethod = member; } -- cgit v1.2.3