title: ProGuard fails with ArrayIndexOutOfBoundsException
body: <p>I'm using ProGuard during the build of a J2ME application. ProGruard fails during optimization with ArrayIndexOutOfBoundsException exception (see (1)).</p>
  
  <p>The code that cause the failure is 'straintforward' : it is a method that copies 23 fields from one POJO to another (see (2)). In addition, when I comment some get/set statements, ProGruad doesn't fail (see (3)).</p>
  
  <p>(1) ProGruard logs</p>
  
  <pre><code> [proguard] ProGuard, version 4.3
   [proguard] Reading input...
   [proguard] Reading program jar [...] (filtered)
   [proguard] Reading library jar [.../WTK2.5.2/lib/midpapi21.jar]
   [proguard] Reading library jar [.../WTK2.5.2/lib/cldcapi11.jar]
   [proguard] Reading library jar [.../WTK2.5.2/lib/wma20.jar]
   [proguard] Initializing...
   [proguard] Ignoring unused library classes...
   [proguard]   Original number of library classes: 947
   [proguard]   Final number of library classes:    87
   [proguard] Printing kept classes, fields, and methods...
   [proguard] Shrinking...
   [proguard] Removing unused program classes and class elements...
   [proguard]   Original number of program classes: 223
   [proguard]   Final number of program classes:    189
   [proguard] Inlining subroutines...
   [proguard] Optimizing...
   [proguard] Unexpected error while merging classes:
   [proguard]   Class        = [.../TransactionEntityBuilder]
   [proguard]   Target class = [.../TransactionEntity]
   [proguard]   Exception    = [java.lang.ArrayIndexOutOfBoundsException] (3113)
   [proguard] java.lang.ArrayIndexOutOfBoundsException: 3113
   [proguard]     at proguard.classfile.editor.CodeAttributeComposer.appendInstruction(CodeAttributeComposer.java:184)
   [proguard]     at proguard.classfile.editor.InstructionAdder.visitConstantInstruction(InstructionAdder.java:74)
   [proguard]     at proguard.classfile.instruction.ConstantInstruction.accept(ConstantInstruction.java:161)
   [proguard]     at proguard.classfile.attribute.CodeAttribute.instructionsAccept(CodeAttribute.java:138)
   [proguard]     at proguard.classfile.attribute.CodeAttribute.instructionsAccept(CodeAttribute.java:110)
   [proguard]     at proguard.classfile.editor.AttributeAdder.visitCodeAttribute(AttributeAdder.java:262)
   [proguard]     at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:101)
   [proguard]     at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:79)
   [proguard]     at proguard.classfile.editor.MemberAdder.visitProgramMethod(MemberAdder.java:234)
   [proguard]     at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:71)
   [proguard]     at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:439)
   [proguard]     at proguard.optimize.peephole.ClassMerger.visitProgramClass0(ClassMerger.java:259)
   [proguard]     at proguard.optimize.peephole.ClassMerger.visitProgramClass(ClassMerger.java:116)
   [proguard]     at proguard.classfile.visitor.ProgramClassFilter.visitProgramClass(ProgramClassFilter.java:52)
   [proguard]     at proguard.classfile.ProgramClass.accept(ProgramClass.java:281)
   [proguard]     at proguard.classfile.LibraryClass.subclassesAccept(LibraryClass.java:370)
   [proguard]     at proguard.classfile.visitor.SubclassTraveler.visitLibraryClass(SubclassTraveler.java:58)
   [proguard]     at proguard.classfile.LibraryClass.accept(LibraryClass.java:248)
   [proguard]     at proguard.classfile.constant.ClassConstant.referencedClassAccept(ClassConstant.java:102)
   [proguard]     at proguard.classfile.visitor.ReferencedClassVisitor.visitClassConstant(ReferencedClassVisitor.java:128)
   [proguard]     at proguard.classfile.constant.ClassConstant.accept(ClassConstant.java:91)
   [proguard]     at proguard.classfile.ProgramClass.superClassConstantAccept(ProgramClass.java:402)
   [proguard]     at proguard.optimize.peephole.HorizontalClassMerger.visitProgramClass(HorizontalClassMerger.java:82)
   [proguard]     at proguard.classfile.ProgramClass.accept(ProgramClass.java:281)
   [proguard]     at proguard.classfile.ClassPool.classesAccept(ClassPool.java:114)
   [proguard]     at proguard.optimize.Optimizer.execute(Optimizer.java:301)
   [proguard]     at proguard.ProGuard.optimize(ProGuard.java:325)
   [proguard]     at proguard.ProGuard.execute(ProGuard.java:114)
   [proguard]     at proguard.ProGuard.main(ProGuard.java:499)
  </code></pre>
  
  <p>(2) The method that fail</p>
  
  <pre><code>    public static TransactionEntityShadow convertFromLegacy(TransactionEntity legacy) {
          TransactionEntityShadow result = new TransactionEntityShadow(legacy.getService(), legacy.getAliasCode());
  
          result.setAliasCode                 (legacy.getAliasCode());
          result.setAmount                    (legacy.getAmount());
          result.setBeneficiaryAccountNumber  (legacy.getBeneficiaryAccountNumber());
          result.setBeneficiaryId             (legacy.getBeneficiaryId());
          result.setBeneficiaryIdTypeId       (legacy.getBeneficiaryIdTypeId());
          result.setBeneficiaryMSISDN         (legacy.getBeneficiaryMSISDN());
          result.setBeneficiaryName           (legacy.getBeneficiaryName());
          result.setBeta                      (legacy.getBeta());
          result.setBillContractNumber        (legacy.getBillContractNumber());
          result.setBillNumber                (legacy.getBillNumber());
          result.setBillSecretCode            (legacy.getBillSecretCode());
          result.setContractBeta              (legacy.getContractBeta());
          result.setCustomerKey               (legacy.getCustomerKey());
          result.setFeesAmount                (legacy.getFeesAmount());
          result.setFreeByte1                 (legacy.getFreeByte1());
          result.setFreeByte2                 (legacy.getFreeByte2());
          result.setLanguageIndex             (legacy.getLanguageIndex());
          result.setMerchantCode              (legacy.getMerchantCode());
          result.setMerchantServiceCode       (legacy.getMerchantServiceCode());
          result.setPinDigest                 (legacy.getPinDigest());
          result.setService                   (legacy.getService());
          result.setSessionKey                (legacy.getSessionKey());
          result.setTransactionDate           (legacy.getTransactionDate());
  
          return result;
      }
  </code></pre>
  
  <p>(3) Commenting some lines of the method will make ProGruad not to fail</p>
  
  <pre><code>    public static TransactionEntityShadow convertFromLegacy(TransactionEntity legacy) {
          TransactionEntityShadow result = new TransactionEntityShadow(legacy.getService(), legacy.getAliasCode());
  
          result.setAliasCode                 (legacy.getAliasCode());
          result.setAmount                    (legacy.getAmount());
          result.setBeneficiaryAccountNumber  (legacy.getBeneficiaryAccountNumber());
          result.setBeneficiaryId             (legacy.getBeneficiaryId());
          result.setBeneficiaryIdTypeId       (legacy.getBeneficiaryIdTypeId());
          result.setBeneficiaryMSISDN         (legacy.getBeneficiaryMSISDN());
  //      result.setBeneficiaryName           (legacy.getBeneficiaryName());
  //      result.setBeta                      (legacy.getBeta());
  //      result.setBillContractNumber        (legacy.getBillContractNumber());
  //      result.setBillNumber                (legacy.getBillNumber());
  //      result.setBillSecretCode            (legacy.getBillSecretCode());
  //      result.setContractBeta              (legacy.getContractBeta());
          result.setCustomerKey               (legacy.getCustomerKey());
          result.setFeesAmount                (legacy.getFeesAmount());
          result.setFreeByte1                 (legacy.getFreeByte1());
          result.setFreeByte2                 (legacy.getFreeByte2());
          result.setLanguageIndex             (legacy.getLanguageIndex());
          result.setMerchantCode              (legacy.getMerchantCode());
          result.setMerchantServiceCode       (legacy.getMerchantServiceCode());
          result.setPinDigest                 (legacy.getPinDigest());
          result.setService                   (legacy.getService());
          result.setSessionKey                (legacy.getSessionKey());
          result.setTransactionDate           (legacy.getTransactionDate());
  
          return result;
      }
  </code></pre>