~ubuntu-branches/ubuntu/maverick/proguard/maverick

« back to all changes in this revision

Viewing changes to src/proguard/classfile/editor/ConstantPoolRemapper.java

  • Committer: Bazaar Package Importer
  • Author(s): Sam Clegg
  • Date: 2005-11-13 09:42:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051113094259-432zf4yyw4890mmn
Tags: 3.4-1
* New upstream release (Closes: #338355)
* debian/control: bump standards version
* debian/copyright: update FSF address
* increase java stack size for proguard and proguardgui

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: ConstantPoolRemapper.java,v 1.9 2004/11/20 15:41:24 eric Exp $
 
1
/* $Id: ConstantPoolRemapper.java,v 1.11 2005/06/11 13:13:15 eric Exp $
2
2
 *
3
3
 * ProGuard -- shrinking, optimization, and obfuscation of Java class files.
4
4
 *
5
 
 * Copyright (c) 2002-2004 Eric Lafortune (eric@graphics.cornell.edu)
 
5
 * Copyright (c) 2002-2005 Eric Lafortune (eric@graphics.cornell.edu)
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify it
8
8
 * under the terms of the GNU General Public License as published by the Free
542
542
 
543
543
    public void visitCpInstruction(ClassFile classFile, MethodInfo methodInfo, CodeAttrInfo codeAttrInfo, int offset, CpInstruction cpInstruction)
544
544
    {
545
 
        // Remap the instruction, and get the old and the new instruction length.
546
 
        int oldLength = cpInstruction.length(offset);
547
 
 
548
 
        cpInstruction.cpIndex = remapCpIndex(cpInstruction.cpIndex);
549
 
        cpInstruction.shrink();
550
 
 
551
 
        int newLength = cpInstruction.length(offset);
552
 
 
553
 
        // Is the code length changing?
554
 
        if (newLength != oldLength ||
555
 
            codeAttrInfoEditor.isModified())
 
545
        // Is the new constant pool index different from the original one?
 
546
        int newCpIndex = remapCpIndex(cpInstruction.cpIndex);
 
547
        if (newCpIndex != cpInstruction.cpIndex)
556
548
        {
557
 
            // We have to go through the code attribute editor.
 
549
            // Replace the instruction.
558
550
            cpInstruction = new CpInstruction().copy(cpInstruction);
 
551
            cpInstruction.cpIndex = newCpIndex;
 
552
            cpInstruction.shrink();
559
553
 
560
554
            codeAttrInfoEditor.replaceInstruction(offset, cpInstruction);
561
555
        }
562
 
        else
563
 
        {
564
 
            // We can write the instruction directly.
565
 
            cpInstruction.write(codeAttrInfo, offset);
566
 
        }
567
556
    }
568
557
 
569
558