diff options
Diffstat (limited to 'src/proguard/classfile/instruction/ConstantInstruction.java')
-rw-r--r-- | src/proguard/classfile/instruction/ConstantInstruction.java | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/proguard/classfile/instruction/ConstantInstruction.java b/src/proguard/classfile/instruction/ConstantInstruction.java index 6c2d1a3..42d1523 100644 --- a/src/proguard/classfile/instruction/ConstantInstruction.java +++ b/src/proguard/classfile/instruction/ConstantInstruction.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2013 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 @@ -93,13 +93,9 @@ implements ConstantVisitor public byte canonicalOpcode() { // Remove the _w extension, if any. - switch (opcode) - { - case InstructionConstants.OP_LDC_W: - case InstructionConstants.OP_LDC2_W: return InstructionConstants.OP_LDC; - - default: return opcode; - } + return + opcode == InstructionConstants.OP_LDC_W ? InstructionConstants.OP_LDC : + opcode; } public Instruction shrink() @@ -185,7 +181,8 @@ implements ConstantVisitor case InstructionConstants.OP_INVOKESPECIAL: case InstructionConstants.OP_INVOKESTATIC: case InstructionConstants.OP_INVOKEINTERFACE: - // The some parameters may be popped from the stack. + case InstructionConstants.OP_INVOKEDYNAMIC: + // Some parameters may be popped from the stack. clazz.constantPoolEntryAccept(constantIndex, this); stackPopCount += parameterStackDelta; break; @@ -208,6 +205,7 @@ implements ConstantVisitor case InstructionConstants.OP_INVOKESPECIAL: case InstructionConstants.OP_INVOKESTATIC: case InstructionConstants.OP_INVOKEINTERFACE: + case InstructionConstants.OP_INVOKEDYNAMIC: // The field value or a return value may be pushed onto the stack. clazz.constantPoolEntryAccept(constantIndex, this); stackPushCount += typeStackDelta; @@ -226,8 +224,9 @@ implements ConstantVisitor public void visitDoubleConstant(Clazz clazz, DoubleConstant doubleConstant) {} public void visitStringConstant(Clazz clazz, StringConstant stringConstant) {} public void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant) {} + public void visitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant) {} public void visitClassConstant(Clazz clazz, ClassConstant classConstant) {} - public void visitNameAndTypeConstant(Clazz clazz, NameAndTypeConstant nameAndTypeConstant) {} + public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant) {} public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant) @@ -238,21 +237,27 @@ implements ConstantVisitor } + public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant) + { + clazz.constantPoolEntryAccept(invokeDynamicConstant.u2nameAndTypeIndex, this); + } + + public void visitInterfaceMethodrefConstant(Clazz clazz, InterfaceMethodrefConstant interfaceMethodrefConstant) { - visitRefConstant(clazz, interfaceMethodrefConstant); + clazz.constantPoolEntryAccept(interfaceMethodrefConstant.u2nameAndTypeIndex, this); } public void visitMethodrefConstant(Clazz clazz, MethodrefConstant methodrefConstant) { - visitRefConstant(clazz, methodrefConstant); + clazz.constantPoolEntryAccept(methodrefConstant.u2nameAndTypeIndex, this); } - private void visitRefConstant(Clazz clazz, RefConstant methodrefConstant) + public void visitNameAndTypeConstant(Clazz clazz, NameAndTypeConstant nameAndTypeConstant) { - String type = methodrefConstant.getType(clazz); + String type = nameAndTypeConstant.getType(clazz); parameterStackDelta = ClassUtil.internalMethodParameterSize(type); typeStackDelta = ClassUtil.internalTypeSize(ClassUtil.internalMethodReturnType(type)); @@ -263,7 +268,7 @@ implements ConstantVisitor public String toString() { - return getName()+" #"+constantIndex; + return getName()+" #"+constantIndex+(constantSize() == 0 ? "" : ", "+constant); } @@ -285,6 +290,7 @@ implements ConstantVisitor private int constantSize() { return opcode == InstructionConstants.OP_MULTIANEWARRAY ? 1 : + opcode == InstructionConstants.OP_INVOKEDYNAMIC || opcode == InstructionConstants.OP_INVOKEINTERFACE ? 2 : 0; } |