Package org.eclipse.jdt.core.util

Examples of org.eclipse.jdt.core.util.ClassFormatException


    int attributesIndex = 0;
    readOffset += 2;
    for (int i = 0; i < this.attributesCount; i++) {
      IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset));
      if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
        throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
      }
      char[] attributeName = constantPoolEntry.getUtf8Value();
      if (equals(attributeName, IAttributeNamesConstants.LINE_NUMBER)) {
        this.lineNumberAttribute = new LineNumberAttribute(classFileBytes, constantPool, offset + readOffset);
        this.attributes[attributesIndex++] = this.lineNumberAttribute;
View Full Code Here


          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Float
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Integer
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_String
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
              throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._ldc(pc - this.codeOffset, index, constantPoolEntry);
          pc+=2;
          break;
        case IOpcodeMnemonics.LDC_W :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Float
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Integer
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_String
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
              throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._ldc_w(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.LDC2_W :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Double
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Long) {
              throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._ldc2_w(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.ILOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._iload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.LLOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._lload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.FLOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._fload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.DLOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._dload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.ALOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._aload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.ILOAD_0 :
          visitor._iload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ILOAD_1 :
          visitor._iload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ILOAD_2 :
          visitor._iload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ILOAD_3 :
          visitor._iload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LLOAD_0 :
          visitor._lload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LLOAD_1 :
          visitor._lload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LLOAD_2 :
          visitor._lload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LLOAD_3 :
          visitor._lload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FLOAD_0 :
          visitor._fload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FLOAD_1 :
          visitor._fload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FLOAD_2 :
          visitor._fload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FLOAD_3 :
          visitor._fload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DLOAD_0 :
          visitor._dload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DLOAD_1 :
          visitor._dload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DLOAD_2 :
          visitor._dload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DLOAD_3 :
          visitor._dload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ALOAD_0 :
          visitor._aload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ALOAD_1 :
          visitor._aload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ALOAD_2 :
          visitor._aload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ALOAD_3 :
          visitor._aload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IALOAD :
          visitor._iaload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LALOAD :
          visitor._laload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FALOAD :
          visitor._faload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DALOAD :
          visitor._daload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.AALOAD :
          visitor._aaload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.BALOAD :
          visitor._baload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.CALOAD :
          visitor._caload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.SALOAD :
          visitor._saload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._istore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.LSTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._lstore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.FSTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._fstore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.DSTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._dstore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.ASTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._astore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.ISTORE_0 :
          visitor._istore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISTORE_1 :
          visitor._istore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISTORE_2 :
          visitor._istore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISTORE_3 :
          visitor._istore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSTORE_0 :
          visitor._lstore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSTORE_1 :
          visitor._lstore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSTORE_2 :
          visitor._lstore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSTORE_3 :
          visitor._lstore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSTORE_0 :
          visitor._fstore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSTORE_1 :
          visitor._fstore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSTORE_2 :
          visitor._fstore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSTORE_3 :
          visitor._fstore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSTORE_0 :
          visitor._dstore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSTORE_1 :
          visitor._dstore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSTORE_2 :
          visitor._dstore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSTORE_3 :
          visitor._dstore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ASTORE_0 :
          visitor._astore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ASTORE_1 :
          visitor._astore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ASTORE_2 :
          visitor._astore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ASTORE_3 :
          visitor._astore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IASTORE :
          visitor._iastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LASTORE :
          visitor._lastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FASTORE :
          visitor._fastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DASTORE :
          visitor._dastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.AASTORE :
          visitor._aastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.BASTORE :
          visitor._bastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.CASTORE :
          visitor._castore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.SASTORE :
          visitor._sastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.POP :
          visitor._pop(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.POP2 :
          visitor._pop2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP :
          visitor._dup(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP_X1 :
          visitor._dup_x1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP_X2 :
          visitor._dup_x2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP2 :
          visitor._dup2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP2_X1 :
          visitor._dup2_x1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP2_X2 :
          visitor._dup2_x2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.SWAP :
          visitor._swap(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IADD :
          visitor._iadd(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LADD :
          visitor._ladd(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FADD :
          visitor._fadd(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DADD :
          visitor._dadd(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISUB :
          visitor._isub(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSUB :
          visitor._lsub(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSUB :
          visitor._fsub(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSUB :
          visitor._dsub(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IMUL :
          visitor._imul(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LMUL :
          visitor._lmul(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FMUL :
          visitor._fmul(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DMUL :
          visitor._dmul(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IDIV :
          visitor._idiv(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LDIV :
          visitor._ldiv(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FDIV :
          visitor._fdiv(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DDIV :
          visitor._ddiv(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IREM :
          visitor._irem(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LREM :
          visitor._lrem(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FREM :
          visitor._frem(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DREM :
          visitor._drem(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.INEG :
          visitor._ineg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LNEG :
          visitor._lneg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FNEG :
          visitor._fneg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DNEG :
          visitor._dneg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISHL :
          visitor._ishl(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSHL :
          visitor._lshl(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISHR :
          visitor._ishr(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSHR :
          visitor._lshr(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IUSHR :
          visitor._iushr(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LUSHR :
          visitor._lushr(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IAND :
          visitor._iand(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LAND :
          visitor._land(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IOR :
          visitor._ior(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LOR :
          visitor._lor(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IXOR :
          visitor._ixor(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LXOR :
          visitor._lxor(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IINC :
          index = u1At(this.classFileBytes, 1, pc);
          _const = i1At(this.classFileBytes, 2, pc);
          visitor._iinc(pc - this.codeOffset, index, _const);
          pc+=3;
          break;
        case IOpcodeMnemonics.I2L :
          visitor._i2l(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2F :
          visitor._i2f(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2D :
          visitor._i2d(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.L2I :
          visitor._l2i(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.L2F :
          visitor._l2f(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.L2D :
          visitor._l2d(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.F2I :
          visitor._f2i(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.F2L :
          visitor._f2l(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.F2D :
          visitor._f2d(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.D2I :
          visitor._d2i(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.D2L :
          visitor._d2l(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.D2F :
          visitor._d2f(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2B :
          visitor._i2b(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2C :
          visitor._i2c(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2S :
          visitor._i2s(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LCMP :
          visitor._lcmp(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FCMPL :
          visitor._fcmpl(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FCMPG :
          visitor._fcmpg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DCMPL :
          visitor._dcmpl(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DCMPG :
          visitor._dcmpg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IFEQ :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifeq(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFNE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifne(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFLT :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._iflt(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFGE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifge(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFGT :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifgt(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFLE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifle(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPEQ :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmpeq(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPNE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmpne(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPLT :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmplt(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPGE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmpge(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPGT :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmpgt(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPLE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmple(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ACMPEQ :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_acmpeq(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ACMPNE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_acmpne(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.GOTO :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._goto(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.JSR :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._jsr(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.RET :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._ret(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.TABLESWITCH :
          int startpc = pc;
          pc++;
          while (((pc - this.codeOffset) & 0x03) != 0) { // faster than % 4
            pc++;
          }
          int defaultOffset = i4At(this.classFileBytes, 0, pc);
          pc += 4;
          int low = i4At(this.classFileBytes, 0, pc);
          pc += 4;
          int high = i4At(this.classFileBytes, 0, pc);
          pc += 4;
          int length = high - low + 1;
          int[] jumpOffsets = new int[length];
          for (int i = 0; i < length; i++) {
            jumpOffsets[i] = i4At(this.classFileBytes, 0, pc);
            pc += 4;
          }
          visitor._tableswitch(startpc - this.codeOffset, defaultOffset, low, high, jumpOffsets);
          break;
        case IOpcodeMnemonics.LOOKUPSWITCH :
          startpc = pc;
          pc++;
          while (((pc - this.codeOffset) & 0x03) != 0) {
            pc++;
          }
          defaultOffset = i4At(this.classFileBytes, 0, pc);
          pc += 4;
          int npairs = (int) u4At(this.classFileBytes, 0, pc);
          int[][] offset_pairs = new int[npairs][2];
          pc += 4;
          for (int i = 0; i < npairs; i++) {
            offset_pairs[i][0] = i4At(this.classFileBytes, 0, pc);
            pc += 4;
            offset_pairs[i][1] = i4At(this.classFileBytes, 0, pc);
            pc += 4;
          }
          visitor._lookupswitch(startpc - this.codeOffset, defaultOffset, npairs, offset_pairs);
          break;
        case IOpcodeMnemonics.IRETURN :
          visitor._ireturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LRETURN :
          visitor._lreturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FRETURN :
          visitor._freturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DRETURN :
          visitor._dreturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ARETURN :
          visitor._areturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.RETURN :
          visitor._return(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.GETSTATIC :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._getstatic(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.PUTSTATIC :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._putstatic(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.GETFIELD :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._getfield(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.PUTFIELD :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._putfield(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INVOKEVIRTUAL :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Methodref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._invokevirtual(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INVOKESPECIAL :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Methodref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._invokespecial(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INVOKESTATIC :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Methodref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._invokestatic(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INVOKEINTERFACE :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_InterfaceMethodref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          byte count = (byte) u1At(this.classFileBytes, 3, pc);
          int extraArgs = u1At(this.classFileBytes, 4, pc);
          if (extraArgs != 0) {
            throw new ClassFormatException(ClassFormatException.INVALID_ARGUMENTS_FOR_INVOKEINTERFACE);
          }
          visitor._invokeinterface(pc - this.codeOffset, index, count, constantPoolEntry);
          pc += 5;
          break;
        case IOpcodeMnemonics.INVOKEDYNAMIC :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_NameAndType) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._invokedynamic(
              pc - this.codeOffset,
              index,
              this.constantPool.decodeEntry(constantPoolEntry.getNameAndTypeInfoNameIndex()),
              this.constantPool.decodeEntry(constantPoolEntry.getNameAndTypeInfoDescriptorIndex()));
          pc += 5;
          break;
        case IOpcodeMnemonics.NEW :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._new(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.NEWARRAY :
          int atype = u1At(this.classFileBytes, 1, pc);
          visitor._newarray(pc - this.codeOffset, atype);
          pc+=2;
          break;
        case IOpcodeMnemonics.ANEWARRAY :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._anewarray(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.ARRAYLENGTH :
          visitor._arraylength(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ATHROW :
          visitor._athrow(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.CHECKCAST :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._checkcast(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INSTANCEOF :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._instanceof(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.MONITORENTER :
          visitor._monitorenter(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.MONITOREXIT :
          visitor._monitorexit(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.WIDE :
          opcode = u1At(this.classFileBytes, 1, pc);
          if (opcode == IOpcodeMnemonics.IINC) {
            index = u2At(this.classFileBytes, 2, pc);
            _const = i2At(this.classFileBytes, 4, pc);
            visitor._wide(pc - this.codeOffset, opcode, index, _const);
            pc += 6;
          } else {
            index = u2At(this.classFileBytes, 2, pc);
            visitor._wide(pc - this.codeOffset , opcode, index);
            pc += 4;
          }
          break;
        case IOpcodeMnemonics.MULTIANEWARRAY :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          int dimensions = u1At(this.classFileBytes, 3, pc);
          visitor._multianewarray(pc - this.codeOffset, index, dimensions, constantPoolEntry);
          pc+=4;
          break;
        case IOpcodeMnemonics.IFNULL :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifnull(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFNONNULL :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifnonnull(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.GOTO_W :
          branchOffset = i4At(this.classFileBytes, 1, pc);
          visitor._goto_w(pc - this.codeOffset, branchOffset);
          pc+=5;
          break;
        case IOpcodeMnemonics.JSR_W :
          branchOffset = i4At(this.classFileBytes, 1, pc);
          visitor._jsr_w(pc - this.codeOffset, branchOffset);
          pc+=5;
          break;
        case IOpcodeMnemonics.BREAKPOINT :
          visitor._breakpoint(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IMPDEP1 :
          visitor._impdep1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IMPDEP2 :
          visitor._impdep2(pc - this.codeOffset);
          pc++;
          break;
        default:
          throw new ClassFormatException(ClassFormatException.INVALID_BYTECODE);
      }
      if (pc >= (this.codeLength + this.codeOffset)) {
        break;
      }
    }
View Full Code Here

    int constantPoolCount;
    int[] constantPoolOffsets;
    try {
      this.magicNumber = (int) u4At(classFileBytes, 0, 0);
      if (this.magicNumber != 0xCAFEBABE) {
        throw new ClassFormatException(ClassFormatException.INVALID_MAGIC_NUMBER);
      }

      int readOffset = 10;
      this.minorVersion = u2At(classFileBytes, 4, 0);
      this.majorVersion = u2At(classFileBytes, 6, 0);

      if ((decodingFlags & IClassFileReader.CONSTANT_POOL) == 0) {
        // no need to go further
        return;
      }

      constantPoolCount = u2At(classFileBytes, 8, 0);
      // Pass #1 - Fill in all primitive constants
      constantPoolOffsets = new int[constantPoolCount];
      for (int i = 1; i < constantPoolCount; i++) {
        int tag = u1At(classFileBytes, readOffset, 0);
        switch (tag) {
          case IConstantPoolConstant.CONSTANT_Utf8 :
            constantPoolOffsets[i] = readOffset;
            readOffset += u2At(classFileBytes, readOffset + 1, 0);
            readOffset += IConstantPoolConstant.CONSTANT_Utf8_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Integer :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Integer_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Float :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Float_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Long :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Long_SIZE;
            i++;
            break;
          case IConstantPoolConstant.CONSTANT_Double :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Double_SIZE;
            i++;
            break;
          case IConstantPoolConstant.CONSTANT_Class :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Class_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_String :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_String_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Fieldref :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Fieldref_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Methodref :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Methodref_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_InterfaceMethodref :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_InterfaceMethodref_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_NameAndType :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_NameAndType_SIZE;
            break;
          default:
            throw new ClassFormatException(ClassFormatException.INVALID_TAG_CONSTANT);
        }
      }

      this.constantPool = new ConstantPool(classFileBytes, constantPoolOffsets);
      // Read and validate access flags
      this.accessFlags = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;

      // Read the classname, use exception handlers to catch bad format
      this.classNameIndex = u2At(classFileBytes, readOffset, 0);
      this.className = getConstantClassNameAt(classFileBytes, constantPoolOffsets, this.classNameIndex);
      readOffset += 2;

      // Read the superclass name, can be zero for java.lang.Object
      this.superclassNameIndex = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;
      // if superclassNameIndex is equals to 0 there is no need to set a value for the
      // field this.superclassName. null is fine.
      if (this.superclassNameIndex != 0) {
        this.superclassName = getConstantClassNameAt(classFileBytes, constantPoolOffsets, this.superclassNameIndex);
      }

      // Read the interfaces, use exception handlers to catch bad format
      this.interfacesCount = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;
      this.interfaceNames = NO_INTERFACES_NAMES;
      this.interfaceIndexes = Util.EMPTY_INT_ARRAY;
      if (this.interfacesCount != 0) {
        if ((decodingFlags & IClassFileReader.SUPER_INTERFACES) != IClassFileReader.CONSTANT_POOL) {
          this.interfaceNames = new char[this.interfacesCount][];
          this.interfaceIndexes = new int[this.interfacesCount];
          for (int i = 0; i < this.interfacesCount; i++) {
            this.interfaceIndexes[i] = u2At(classFileBytes, readOffset, 0);
            this.interfaceNames[i] = getConstantClassNameAt(classFileBytes, constantPoolOffsets, this.interfaceIndexes[i]);
            readOffset += 2;
          }
        } else {
          readOffset += (2 * this.interfacesCount);
        }
      }
      // Read the this.fields, use exception handlers to catch bad format
      this.fieldsCount = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;
      this.fields = NO_FIELD_INFOS;
      if (this.fieldsCount != 0) {
        if ((decodingFlags & IClassFileReader.FIELD_INFOS) != IClassFileReader.CONSTANT_POOL) {
          FieldInfo field;
          this.fields = new FieldInfo[this.fieldsCount];
          for (int i = 0; i < this.fieldsCount; i++) {
            field = new FieldInfo(classFileBytes, this.constantPool, readOffset);
            this.fields[i] = field;
            readOffset += field.sizeInBytes();
          }
        } else {
          for (int i = 0; i < this.fieldsCount; i++) {
            int attributeCountForField = u2At(classFileBytes, 6, readOffset);
            readOffset += 8;
            if (attributeCountForField != 0) {
              for (int j = 0; j < attributeCountForField; j++) {
                int attributeLength = (int) u4At(classFileBytes, 2, readOffset);
                readOffset += (6 + attributeLength);
              }
            }
          }
        }
      }
      // Read the this.methods
      this.methodsCount = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;
      this.methods = NO_METHOD_INFOS;
      if (this.methodsCount != 0) {
        if ((decodingFlags & IClassFileReader.METHOD_INFOS) != IClassFileReader.CONSTANT_POOL) {
          this.methods = new MethodInfo[this.methodsCount];
          MethodInfo method;
          for (int i = 0; i < this.methodsCount; i++) {
            method = new MethodInfo(classFileBytes, this.constantPool, readOffset, decodingFlags);
            this.methods[i] = method;
            readOffset += method.sizeInBytes();
          }
        } else {
          for (int i = 0; i < this.methodsCount; i++) {
            int attributeCountForMethod = u2At(classFileBytes, 6, readOffset);
            readOffset += 8;
            if (attributeCountForMethod != 0) {
              for (int j = 0; j < attributeCountForMethod; j++) {
                int attributeLength = (int) u4At(classFileBytes, 2, readOffset);
                readOffset += (6 + attributeLength);
              }
            }
          }
        }
      }

      // Read the attributes
      this.attributesCount = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;

      int attributesIndex = 0;
      this.attributes = ClassFileAttribute.NO_ATTRIBUTES;
      if (this.attributesCount != 0) {
        if ((decodingFlags & IClassFileReader.CLASSFILE_ATTRIBUTES) != IClassFileReader.CONSTANT_POOL) {
          this.attributes = new IClassFileAttribute[this.attributesCount];
          for (int i = 0; i < this.attributesCount; i++) {
            int utf8Offset = constantPoolOffsets[u2At(classFileBytes, readOffset, 0)];
            char[] attributeName = utf8At(classFileBytes, utf8Offset + 3, 0, u2At(classFileBytes, utf8Offset + 1, 0));
            if (equals(attributeName, IAttributeNamesConstants.INNER_CLASSES)) {
              this.innerClassesAttribute = new InnerClassesAttribute(classFileBytes, this.constantPool, readOffset);
              this.attributes[attributesIndex++] = this.innerClassesAttribute;
            } else if (equals(attributeName, IAttributeNamesConstants.SOURCE)) {
              this.sourceFileAttribute = new SourceFileAttribute(classFileBytes, this.constantPool, readOffset);
              this.attributes[attributesIndex++] = this.sourceFileAttribute;
            } else if (equals(attributeName, IAttributeNamesConstants.ENCLOSING_METHOD)) {
              this.attributes[attributesIndex++] = new EnclosingMethodAttribute(classFileBytes, this.constantPool, readOffset);
            } else if (equals(attributeName, IAttributeNamesConstants.SIGNATURE)) {
              this.attributes[attributesIndex++] = new SignatureAttribute(classFileBytes, this.constantPool, readOffset);
            } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_VISIBLE_ANNOTATIONS)) {
              this.attributes[attributesIndex++] = new RuntimeVisibleAnnotationsAttribute(classFileBytes, this.constantPool, readOffset);
            } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_INVISIBLE_ANNOTATIONS)) {
              this.attributes[attributesIndex++] = new RuntimeInvisibleAnnotationsAttribute(classFileBytes, this.constantPool, readOffset);
            } else {
              this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, this.constantPool, readOffset);
            }
            readOffset += (6 + u4At(classFileBytes, readOffset + 2, 0));
          }
        } else {
          for (int i = 0; i < this.attributesCount; i++) {
            readOffset += (6 + u4At(classFileBytes, readOffset + 2, 0));
          }
        }
      }
      if (readOffset != classFileBytes.length) {
        throw new ClassFormatException(ClassFormatException.TOO_MANY_BYTES);
      }
    } catch(ClassFormatException e) {
      throw e;
    } catch (Exception e) {
      e.printStackTrace();
      throw new ClassFormatException(ClassFormatException.ERROR_TRUNCATED_INPUT);
    }
  }
View Full Code Here

    int constantPoolCount;
    int[] constantPoolOffsets;
    try {
      this.magicNumber = (int) u4At(classFileBytes, 0, 0);
      if (this.magicNumber != 0xCAFEBABE) {
        throw new ClassFormatException(ClassFormatException.INVALID_MAGIC_NUMBER);
      }

      int readOffset = 10;
      this.minorVersion = u2At(classFileBytes, 4, 0);
      this.majorVersion = u2At(classFileBytes, 6, 0);

      if ((decodingFlags & IClassFileReader.CONSTANT_POOL) == 0) {
        // no need to go further
        return;
      }

      constantPoolCount = u2At(classFileBytes, 8, 0);
      // Pass #1 - Fill in all primitive constants
      constantPoolOffsets = new int[constantPoolCount];
      for (int i = 1; i < constantPoolCount; i++) {
        int tag = u1At(classFileBytes, readOffset, 0);
        switch (tag) {
          case IConstantPoolConstant.CONSTANT_Utf8 :
            constantPoolOffsets[i] = readOffset;
            readOffset += u2At(classFileBytes, readOffset + 1, 0);
            readOffset += IConstantPoolConstant.CONSTANT_Utf8_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Integer :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Integer_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Float :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Float_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Long :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Long_SIZE;
            i++;
            break;
          case IConstantPoolConstant.CONSTANT_Double :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Double_SIZE;
            i++;
            break;
          case IConstantPoolConstant.CONSTANT_Class :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Class_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_String :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_String_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Fieldref :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Fieldref_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_Methodref :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_Methodref_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_InterfaceMethodref :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_InterfaceMethodref_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_NameAndType :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_NameAndType_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_MethodHandle :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_MethodHandle_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_MethodType :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_MethodType_SIZE;
            break;
          case IConstantPoolConstant.CONSTANT_InvokeDynamic :
            constantPoolOffsets[i] = readOffset;
            readOffset += IConstantPoolConstant.CONSTANT_InvokeDynamic_SIZE;
            break;
          default:
            throw new ClassFormatException(ClassFormatException.INVALID_TAG_CONSTANT);
        }
      }

      this.constantPool = new ConstantPool(classFileBytes, constantPoolOffsets);
      // Read and validate access flags
      this.accessFlags = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;

      // Read the classname, use exception handlers to catch bad format
      this.classNameIndex = u2At(classFileBytes, readOffset, 0);
      this.className = getConstantClassNameAt(classFileBytes, constantPoolOffsets, this.classNameIndex);
      readOffset += 2;

      // Read the superclass name, can be zero for java.lang.Object
      this.superclassNameIndex = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;
      // if superclassNameIndex is equals to 0 there is no need to set a value for the
      // field this.superclassName. null is fine.
      if (this.superclassNameIndex != 0) {
        this.superclassName = getConstantClassNameAt(classFileBytes, constantPoolOffsets, this.superclassNameIndex);
      }

      // Read the interfaces, use exception handlers to catch bad format
      this.interfacesCount = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;
      this.interfaceNames = NO_INTERFACES_NAMES;
      this.interfaceIndexes = Util.EMPTY_INT_ARRAY;
      if (this.interfacesCount != 0) {
        if ((decodingFlags & IClassFileReader.SUPER_INTERFACES) != IClassFileReader.CONSTANT_POOL) {
          this.interfaceNames = new char[this.interfacesCount][];
          this.interfaceIndexes = new int[this.interfacesCount];
          for (int i = 0; i < this.interfacesCount; i++) {
            this.interfaceIndexes[i] = u2At(classFileBytes, readOffset, 0);
            this.interfaceNames[i] = getConstantClassNameAt(classFileBytes, constantPoolOffsets, this.interfaceIndexes[i]);
            readOffset += 2;
          }
        } else {
          readOffset += (2 * this.interfacesCount);
        }
      }
      // Read the this.fields, use exception handlers to catch bad format
      this.fieldsCount = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;
      this.fields = NO_FIELD_INFOS;
      if (this.fieldsCount != 0) {
        if ((decodingFlags & IClassFileReader.FIELD_INFOS) != IClassFileReader.CONSTANT_POOL) {
          FieldInfo field;
          this.fields = new FieldInfo[this.fieldsCount];
          for (int i = 0; i < this.fieldsCount; i++) {
            field = new FieldInfo(classFileBytes, this.constantPool, readOffset);
            this.fields[i] = field;
            readOffset += field.sizeInBytes();
          }
        } else {
          for (int i = 0; i < this.fieldsCount; i++) {
            int attributeCountForField = u2At(classFileBytes, 6, readOffset);
            readOffset += 8;
            if (attributeCountForField != 0) {
              for (int j = 0; j < attributeCountForField; j++) {
                int attributeLength = (int) u4At(classFileBytes, 2, readOffset);
                readOffset += (6 + attributeLength);
              }
            }
          }
        }
      }
      // Read the this.methods
      this.methodsCount = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;
      this.methods = NO_METHOD_INFOS;
      if (this.methodsCount != 0) {
        if ((decodingFlags & IClassFileReader.METHOD_INFOS) != IClassFileReader.CONSTANT_POOL) {
          this.methods = new MethodInfo[this.methodsCount];
          MethodInfo method;
          for (int i = 0; i < this.methodsCount; i++) {
            method = new MethodInfo(classFileBytes, this.constantPool, readOffset, decodingFlags);
            this.methods[i] = method;
            readOffset += method.sizeInBytes();
          }
        } else {
          for (int i = 0; i < this.methodsCount; i++) {
            int attributeCountForMethod = u2At(classFileBytes, 6, readOffset);
            readOffset += 8;
            if (attributeCountForMethod != 0) {
              for (int j = 0; j < attributeCountForMethod; j++) {
                int attributeLength = (int) u4At(classFileBytes, 2, readOffset);
                readOffset += (6 + attributeLength);
              }
            }
          }
        }
      }

      // Read the attributes
      this.attributesCount = u2At(classFileBytes, readOffset, 0);
      readOffset += 2;

      int attributesIndex = 0;
      this.attributes = ClassFileAttribute.NO_ATTRIBUTES;
      if (this.attributesCount != 0) {
        if ((decodingFlags & IClassFileReader.CLASSFILE_ATTRIBUTES) != IClassFileReader.CONSTANT_POOL) {
          this.attributes = new IClassFileAttribute[this.attributesCount];
          for (int i = 0; i < this.attributesCount; i++) {
            int utf8Offset = constantPoolOffsets[u2At(classFileBytes, readOffset, 0)];
            char[] attributeName = utf8At(classFileBytes, utf8Offset + 3, 0, u2At(classFileBytes, utf8Offset + 1, 0));
            if (equals(attributeName, IAttributeNamesConstants.INNER_CLASSES)) {
              this.innerClassesAttribute = new InnerClassesAttribute(classFileBytes, this.constantPool, readOffset);
              this.attributes[attributesIndex++] = this.innerClassesAttribute;
            } else if (equals(attributeName, IAttributeNamesConstants.SOURCE)) {
              this.sourceFileAttribute = new SourceFileAttribute(classFileBytes, this.constantPool, readOffset);
              this.attributes[attributesIndex++] = this.sourceFileAttribute;
            } else if (equals(attributeName, IAttributeNamesConstants.ENCLOSING_METHOD)) {
              this.attributes[attributesIndex++] = new EnclosingMethodAttribute(classFileBytes, this.constantPool, readOffset);
            } else if (equals(attributeName, IAttributeNamesConstants.SIGNATURE)) {
              this.attributes[attributesIndex++] = new SignatureAttribute(classFileBytes, this.constantPool, readOffset);
            } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_VISIBLE_ANNOTATIONS)) {
              this.attributes[attributesIndex++] = new RuntimeVisibleAnnotationsAttribute(classFileBytes, this.constantPool, readOffset);
            } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_INVISIBLE_ANNOTATIONS)) {
              this.attributes[attributesIndex++] = new RuntimeInvisibleAnnotationsAttribute(classFileBytes, this.constantPool, readOffset);
            } else if (equals(attributeName, IAttributeNamesConstants.BOOTSTRAP_METHODS)) {
              this.attributes[attributesIndex++] = new BootstrapMethodsAttribute(classFileBytes, this.constantPool, readOffset);
            } else {
              this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, this.constantPool, readOffset);
            }
            readOffset += (6 + u4At(classFileBytes, readOffset + 2, 0));
          }
        } else {
          for (int i = 0; i < this.attributesCount; i++) {
            readOffset += (6 + u4At(classFileBytes, readOffset + 2, 0));
          }
        }
      }
      if (readOffset != classFileBytes.length) {
        throw new ClassFormatException(ClassFormatException.TOO_MANY_BYTES);
      }
    } catch(ClassFormatException e) {
      throw e;
    } catch (Exception e) {
      e.printStackTrace();
      throw new ClassFormatException(ClassFormatException.ERROR_TRUNCATED_INPUT);
    }
  }
View Full Code Here

    int attributesIndex = 0;
    readOffset += 2;
    for (int i = 0; i < this.attributesCount; i++) {
      IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset));
      if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
        throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
      }
      char[] attributeName = constantPoolEntry.getUtf8Value();
      if (equals(attributeName, IAttributeNamesConstants.LINE_NUMBER)) {
        this.lineNumberAttribute = new LineNumberAttribute(classFileBytes, constantPool, offset + readOffset);
        this.attributes[attributesIndex++] = this.lineNumberAttribute;
View Full Code Here

          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Float
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Integer
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_String
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
              throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._ldc(pc - this.codeOffset, index, constantPoolEntry);
          pc+=2;
          break;
        case IOpcodeMnemonics.LDC_W :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Float
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Integer
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_String
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
              throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._ldc_w(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.LDC2_W :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Double
            && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Long) {
              throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._ldc2_w(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.ILOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._iload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.LLOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._lload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.FLOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._fload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.DLOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._dload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.ALOAD :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._aload(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.ILOAD_0 :
          visitor._iload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ILOAD_1 :
          visitor._iload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ILOAD_2 :
          visitor._iload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ILOAD_3 :
          visitor._iload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LLOAD_0 :
          visitor._lload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LLOAD_1 :
          visitor._lload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LLOAD_2 :
          visitor._lload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LLOAD_3 :
          visitor._lload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FLOAD_0 :
          visitor._fload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FLOAD_1 :
          visitor._fload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FLOAD_2 :
          visitor._fload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FLOAD_3 :
          visitor._fload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DLOAD_0 :
          visitor._dload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DLOAD_1 :
          visitor._dload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DLOAD_2 :
          visitor._dload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DLOAD_3 :
          visitor._dload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ALOAD_0 :
          visitor._aload_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ALOAD_1 :
          visitor._aload_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ALOAD_2 :
          visitor._aload_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ALOAD_3 :
          visitor._aload_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IALOAD :
          visitor._iaload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LALOAD :
          visitor._laload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FALOAD :
          visitor._faload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DALOAD :
          visitor._daload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.AALOAD :
          visitor._aaload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.BALOAD :
          visitor._baload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.CALOAD :
          visitor._caload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.SALOAD :
          visitor._saload(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._istore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.LSTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._lstore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.FSTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._fstore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.DSTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._dstore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.ASTORE :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._astore(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.ISTORE_0 :
          visitor._istore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISTORE_1 :
          visitor._istore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISTORE_2 :
          visitor._istore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISTORE_3 :
          visitor._istore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSTORE_0 :
          visitor._lstore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSTORE_1 :
          visitor._lstore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSTORE_2 :
          visitor._lstore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSTORE_3 :
          visitor._lstore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSTORE_0 :
          visitor._fstore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSTORE_1 :
          visitor._fstore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSTORE_2 :
          visitor._fstore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSTORE_3 :
          visitor._fstore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSTORE_0 :
          visitor._dstore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSTORE_1 :
          visitor._dstore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSTORE_2 :
          visitor._dstore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSTORE_3 :
          visitor._dstore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ASTORE_0 :
          visitor._astore_0(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ASTORE_1 :
          visitor._astore_1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ASTORE_2 :
          visitor._astore_2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ASTORE_3 :
          visitor._astore_3(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IASTORE :
          visitor._iastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LASTORE :
          visitor._lastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FASTORE :
          visitor._fastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DASTORE :
          visitor._dastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.AASTORE :
          visitor._aastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.BASTORE :
          visitor._bastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.CASTORE :
          visitor._castore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.SASTORE :
          visitor._sastore(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.POP :
          visitor._pop(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.POP2 :
          visitor._pop2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP :
          visitor._dup(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP_X1 :
          visitor._dup_x1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP_X2 :
          visitor._dup_x2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP2 :
          visitor._dup2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP2_X1 :
          visitor._dup2_x1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DUP2_X2 :
          visitor._dup2_x2(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.SWAP :
          visitor._swap(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IADD :
          visitor._iadd(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LADD :
          visitor._ladd(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FADD :
          visitor._fadd(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DADD :
          visitor._dadd(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISUB :
          visitor._isub(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSUB :
          visitor._lsub(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FSUB :
          visitor._fsub(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DSUB :
          visitor._dsub(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IMUL :
          visitor._imul(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LMUL :
          visitor._lmul(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FMUL :
          visitor._fmul(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DMUL :
          visitor._dmul(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IDIV :
          visitor._idiv(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LDIV :
          visitor._ldiv(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FDIV :
          visitor._fdiv(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DDIV :
          visitor._ddiv(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IREM :
          visitor._irem(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LREM :
          visitor._lrem(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FREM :
          visitor._frem(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DREM :
          visitor._drem(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.INEG :
          visitor._ineg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LNEG :
          visitor._lneg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FNEG :
          visitor._fneg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DNEG :
          visitor._dneg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISHL :
          visitor._ishl(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSHL :
          visitor._lshl(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ISHR :
          visitor._ishr(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LSHR :
          visitor._lshr(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IUSHR :
          visitor._iushr(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LUSHR :
          visitor._lushr(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IAND :
          visitor._iand(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LAND :
          visitor._land(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IOR :
          visitor._ior(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LOR :
          visitor._lor(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IXOR :
          visitor._ixor(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LXOR :
          visitor._lxor(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IINC :
          index = u1At(this.classFileBytes, 1, pc);
          _const = i1At(this.classFileBytes, 2, pc);
          visitor._iinc(pc - this.codeOffset, index, _const);
          pc+=3;
          break;
        case IOpcodeMnemonics.I2L :
          visitor._i2l(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2F :
          visitor._i2f(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2D :
          visitor._i2d(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.L2I :
          visitor._l2i(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.L2F :
          visitor._l2f(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.L2D :
          visitor._l2d(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.F2I :
          visitor._f2i(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.F2L :
          visitor._f2l(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.F2D :
          visitor._f2d(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.D2I :
          visitor._d2i(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.D2L :
          visitor._d2l(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.D2F :
          visitor._d2f(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2B :
          visitor._i2b(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2C :
          visitor._i2c(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.I2S :
          visitor._i2s(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LCMP :
          visitor._lcmp(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FCMPL :
          visitor._fcmpl(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FCMPG :
          visitor._fcmpg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DCMPL :
          visitor._dcmpl(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DCMPG :
          visitor._dcmpg(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IFEQ :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifeq(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFNE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifne(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFLT :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._iflt(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFGE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifge(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFGT :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifgt(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFLE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifle(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPEQ :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmpeq(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPNE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmpne(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPLT :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmplt(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPGE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmpge(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPGT :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmpgt(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ICMPLE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_icmple(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ACMPEQ :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_acmpeq(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IF_ACMPNE :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._if_acmpne(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.GOTO :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._goto(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.JSR :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._jsr(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.RET :
          index = u1At(this.classFileBytes, 1, pc);
          visitor._ret(pc - this.codeOffset, index);
          pc+=2;
          break;
        case IOpcodeMnemonics.TABLESWITCH :
          int startpc = pc;
          pc++;
          while (((pc - this.codeOffset) & 0x03) != 0) { // faster than % 4
            pc++;
          }
          int defaultOffset = i4At(this.classFileBytes, 0, pc);
          pc += 4;
          int low = i4At(this.classFileBytes, 0, pc);
          pc += 4;
          int high = i4At(this.classFileBytes, 0, pc);
          pc += 4;
          int length = high - low + 1;
          int[] jumpOffsets = new int[length];
          for (int i = 0; i < length; i++) {
            jumpOffsets[i] = i4At(this.classFileBytes, 0, pc);
            pc += 4;
          }
          visitor._tableswitch(startpc - this.codeOffset, defaultOffset, low, high, jumpOffsets);
          break;
        case IOpcodeMnemonics.LOOKUPSWITCH :
          startpc = pc;
          pc++;
          while (((pc - this.codeOffset) & 0x03) != 0) {
            pc++;
          }
          defaultOffset = i4At(this.classFileBytes, 0, pc);
          pc += 4;
          int npairs = (int) u4At(this.classFileBytes, 0, pc);
          int[][] offset_pairs = new int[npairs][2];
          pc += 4;
          for (int i = 0; i < npairs; i++) {
            offset_pairs[i][0] = i4At(this.classFileBytes, 0, pc);
            pc += 4;
            offset_pairs[i][1] = i4At(this.classFileBytes, 0, pc);
            pc += 4;
          }
          visitor._lookupswitch(startpc - this.codeOffset, defaultOffset, npairs, offset_pairs);
          break;
        case IOpcodeMnemonics.IRETURN :
          visitor._ireturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.LRETURN :
          visitor._lreturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.FRETURN :
          visitor._freturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.DRETURN :
          visitor._dreturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ARETURN :
          visitor._areturn(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.RETURN :
          visitor._return(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.GETSTATIC :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._getstatic(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.PUTSTATIC :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._putstatic(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.GETFIELD :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._getfield(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.PUTFIELD :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._putfield(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INVOKEVIRTUAL :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Methodref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._invokevirtual(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INVOKESPECIAL :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Methodref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._invokespecial(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INVOKESTATIC :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Methodref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._invokestatic(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INVOKEINTERFACE :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_InterfaceMethodref) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          byte count = (byte) u1At(this.classFileBytes, 3, pc);
          int extraArgs = u1At(this.classFileBytes, 4, pc);
          if (extraArgs != 0) {
            throw new ClassFormatException(ClassFormatException.INVALID_ARGUMENTS_FOR_INVOKEINTERFACE);
          }
          visitor._invokeinterface(pc - this.codeOffset, index, count, constantPoolEntry);
          pc += 5;
          break;
        case IOpcodeMnemonics.INVOKEDYNAMIC :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_InvokeDynamic) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._invokedynamic(
              pc - this.codeOffset,
              index,
              constantPoolEntry);
          pc += 5;
          break;
        case IOpcodeMnemonics.NEW :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._new(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.NEWARRAY :
          int atype = u1At(this.classFileBytes, 1, pc);
          visitor._newarray(pc - this.codeOffset, atype);
          pc+=2;
          break;
        case IOpcodeMnemonics.ANEWARRAY :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._anewarray(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.ARRAYLENGTH :
          visitor._arraylength(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.ATHROW :
          visitor._athrow(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.CHECKCAST :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._checkcast(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.INSTANCEOF :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          visitor._instanceof(pc - this.codeOffset, index, constantPoolEntry);
          pc+=3;
          break;
        case IOpcodeMnemonics.MONITORENTER :
          visitor._monitorenter(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.MONITOREXIT :
          visitor._monitorexit(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.WIDE :
          opcode = u1At(this.classFileBytes, 1, pc);
          if (opcode == IOpcodeMnemonics.IINC) {
            index = u2At(this.classFileBytes, 2, pc);
            _const = i2At(this.classFileBytes, 4, pc);
            visitor._wide(pc - this.codeOffset, opcode, index, _const);
            pc += 6;
          } else {
            index = u2At(this.classFileBytes, 2, pc);
            visitor._wide(pc - this.codeOffset , opcode, index);
            pc += 4;
          }
          break;
        case IOpcodeMnemonics.MULTIANEWARRAY :
          index = u2At(this.classFileBytes, 1, pc);
          constantPoolEntry = this.constantPool.decodeEntry(index);
          if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
            throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
          }
          int dimensions = u1At(this.classFileBytes, 3, pc);
          visitor._multianewarray(pc - this.codeOffset, index, dimensions, constantPoolEntry);
          pc+=4;
          break;
        case IOpcodeMnemonics.IFNULL :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifnull(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.IFNONNULL :
          branchOffset = i2At(this.classFileBytes, 1, pc);
          visitor._ifnonnull(pc - this.codeOffset , branchOffset);
          pc+=3;
          break;
        case IOpcodeMnemonics.GOTO_W :
          branchOffset = i4At(this.classFileBytes, 1, pc);
          visitor._goto_w(pc - this.codeOffset, branchOffset);
          pc+=5;
          break;
        case IOpcodeMnemonics.JSR_W :
          branchOffset = i4At(this.classFileBytes, 1, pc);
          visitor._jsr_w(pc - this.codeOffset, branchOffset);
          pc+=5;
          break;
        case IOpcodeMnemonics.BREAKPOINT :
          visitor._breakpoint(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IMPDEP1 :
          visitor._impdep1(pc - this.codeOffset);
          pc++;
          break;
        case IOpcodeMnemonics.IMPDEP2 :
          visitor._impdep2(pc - this.codeOffset);
          pc++;
          break;
        default:
          throw new ClassFormatException(ClassFormatException.INVALID_BYTECODE);
      }
      if (pc >= (this.codeLength + this.codeOffset)) {
        break;
      }
    }
View Full Code Here

      this.isSynthetic = true;
    }
    this.nameIndex = u2At(classFileBytes, 2, offset);
    IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(this.nameIndex);
    if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
      throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
    }
    this.name = constantPoolEntry.getUtf8Value();

    this.descriptorIndex = u2At(classFileBytes, 4, offset);
    constantPoolEntry = constantPool.decodeEntry(this.descriptorIndex);
    if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
      throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
    }
    this.descriptor = constantPoolEntry.getUtf8Value();

    this.attributesCount = u2At(classFileBytes, 6, offset);
    this.attributes = ClassFileAttribute.NO_ATTRIBUTES;
    int readOffset = 8;
    if (this.attributesCount != 0) {
      this.attributes = new IClassFileAttribute[this.attributesCount];
    }
    int attributesIndex = 0;
    for (int i = 0; i < this.attributesCount; i++) {
      constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset));
      if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
        throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
      }
      char[] attributeName = constantPoolEntry.getUtf8Value();
      if (equals(attributeName, IAttributeNamesConstants.DEPRECATED)) {
        this.isDeprecated = true;
        this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset);
View Full Code Here

    }

    this.nameIndex = u2At(classFileBytes, 2, offset);
    IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(this.nameIndex);
    if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
      throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
    }
    this.name = constantPoolEntry.getUtf8Value();

    this.descriptorIndex = u2At(classFileBytes, 4, offset);
    constantPoolEntry = constantPool.decodeEntry(this.descriptorIndex);
    if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
      throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
    }
    this.descriptor = constantPoolEntry.getUtf8Value();

    this.attributesCount = u2At(classFileBytes, 6, offset);
    this.attributes = ClassFileAttribute.NO_ATTRIBUTES;
    if (this.attributesCount != 0) {
      if (no_code_attribute && !isAbstract() && !isNative()) {
        if (this.attributesCount != 1) {
          this.attributes = new IClassFileAttribute[this.attributesCount - 1];
        }
      } else {
        this.attributes = new IClassFileAttribute[this.attributesCount];
      }
    }
    int attributesIndex = 0;
    int readOffset = 8;
    for (int i = 0; i < this.attributesCount; i++) {
      constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset));
      if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
        throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
      }
      char[] attributeName = constantPoolEntry.getUtf8Value();
      if (equals(attributeName, IAttributeNamesConstants.DEPRECATED)) {
        this.isDeprecated = true;
        this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset);
View Full Code Here

      this.isSynthetic = true;
    }
    this.nameIndex = u2At(classFileBytes, 2, offset);
    IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(this.nameIndex);
    if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
      throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
    }
    this.name = constantPoolEntry.getUtf8Value();

    this.descriptorIndex = u2At(classFileBytes, 4, offset);
    constantPoolEntry = constantPool.decodeEntry(this.descriptorIndex);
    if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
      throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
    }
    this.descriptor = constantPoolEntry.getUtf8Value();

    this.attributesCount = u2At(classFileBytes, 6, offset);
    this.attributes = ClassFileAttribute.NO_ATTRIBUTES;
    int readOffset = 8;
    if (this.attributesCount != 0) {
      this.attributes = new IClassFileAttribute[this.attributesCount];
    }
    int attributesIndex = 0;
    for (int i = 0; i < this.attributesCount; i++) {
      constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset));
      if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
        throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
      }
      char[] attributeName = constantPoolEntry.getUtf8Value();
      if (equals(attributeName, IAttributeNamesConstants.DEPRECATED)) {
        this.isDeprecated = true;
        this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset);
View Full Code Here

    super(classFileBytes, constantPool, offset);
    int index = u2At(classFileBytes, 6, offset);
    this.enclosingClassIndex = index;
    IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(index);
    if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) {
      throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
    }
    this.enclosingClassName = constantPoolEntry.getClassInfoName();
    this.methodNameAndTypeIndex = u2At(classFileBytes, 8, offset);
    if (this.methodNameAndTypeIndex != 0) {
      constantPoolEntry = constantPool.decodeEntry(this.methodNameAndTypeIndex);
      if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_NameAndType) {
        throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
      }
      this.methodDescriptorIndex = constantPoolEntry.getNameAndTypeInfoDescriptorIndex();
      this.methodNameIndex = constantPoolEntry.getNameAndTypeInfoNameIndex();
      constantPoolEntry = constantPool.decodeEntry(this.methodDescriptorIndex);
      if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
        throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
      }
      this.methodDescriptor = constantPoolEntry.getUtf8Value();
      constantPoolEntry = constantPool.decodeEntry(this.methodNameIndex);
      if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) {
        throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY);
      }
      this.methodName = constantPoolEntry.getUtf8Value();
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.util.ClassFormatException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.