1 11 package org.eclipse.jdt.internal.core.util; 12 13 import org.eclipse.jdt.core.util.ClassFormatException; 14 import org.eclipse.jdt.core.util.IAttributeNamesConstants; 15 import org.eclipse.jdt.core.util.IBytecodeVisitor; 16 import org.eclipse.jdt.core.util.IClassFileAttribute; 17 import org.eclipse.jdt.core.util.ICodeAttribute; 18 import org.eclipse.jdt.core.util.IConstantPool; 19 import org.eclipse.jdt.core.util.IConstantPoolConstant; 20 import org.eclipse.jdt.core.util.IConstantPoolEntry; 21 import org.eclipse.jdt.core.util.IExceptionTableEntry; 22 import org.eclipse.jdt.core.util.ILineNumberAttribute; 23 import org.eclipse.jdt.core.util.ILocalVariableAttribute; 24 import org.eclipse.jdt.core.util.IOpcodeMnemonics; 25 26 29 public class CodeAttribute extends ClassFileAttribute implements ICodeAttribute { 30 private static final IExceptionTableEntry[] NO_EXCEPTION_TABLE = new IExceptionTableEntry[0]; 31 private IClassFileAttribute[] attributes; 32 private int attributesCount; 33 private byte[] bytecodes; 34 private byte[] classFileBytes; 35 private long codeLength; 36 private int codeOffset; 37 private IConstantPool constantPool; 38 private IExceptionTableEntry[] exceptionTableEntries; 39 private int exceptionTableLength; 40 private ILineNumberAttribute lineNumberAttribute; 41 private ILocalVariableAttribute localVariableAttribute; 42 private int maxLocals; 43 private int maxStack; 44 45 CodeAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { 46 super(classFileBytes, constantPool, offset); 47 this.classFileBytes = classFileBytes; 48 this.constantPool = constantPool; 49 this.maxStack = u2At(classFileBytes, 6, offset); 50 this.maxLocals = u2At(classFileBytes, 8, offset); 51 this.codeLength = u4At(classFileBytes, 10, offset); 52 this.codeOffset = offset + 14; 53 int readOffset = (int) (14 + this.codeLength); 54 this.exceptionTableLength = u2At(classFileBytes, readOffset, offset); 55 readOffset += 2; 56 this.exceptionTableEntries = NO_EXCEPTION_TABLE; 57 if (this.exceptionTableLength != 0) { 58 this.exceptionTableEntries = new ExceptionTableEntry[this.exceptionTableLength]; 59 for (int i = 0; i < this.exceptionTableLength; i++) { 60 this.exceptionTableEntries [i] = new ExceptionTableEntry(classFileBytes, constantPool, offset + readOffset); 61 readOffset += 8; 62 } 63 } 64 this.attributesCount = u2At(classFileBytes, readOffset, offset); 65 this.attributes = ClassFileAttribute.NO_ATTRIBUTES; 66 if (this.attributesCount != 0) { 67 this.attributes = new IClassFileAttribute[this.attributesCount]; 68 } 69 int attributesIndex = 0; 70 readOffset += 2; 71 for (int i = 0; i < this.attributesCount; i++) { 72 IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset)); 73 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { 74 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 75 } 76 char[] attributeName = constantPoolEntry.getUtf8Value(); 77 if (equals(attributeName, IAttributeNamesConstants.LINE_NUMBER)) { 78 this.lineNumberAttribute = new LineNumberAttribute(classFileBytes, constantPool, offset + readOffset); 79 this.attributes[attributesIndex++] = this.lineNumberAttribute; 80 } else if (equals(attributeName, IAttributeNamesConstants.LOCAL_VARIABLE)) { 81 this.localVariableAttribute = new LocalVariableAttribute(classFileBytes, constantPool, offset + readOffset); 82 this.attributes[attributesIndex++] = this.localVariableAttribute; 83 } else if (equals(attributeName, IAttributeNamesConstants.LOCAL_VARIABLE_TYPE_TABLE)) { 84 this.attributes[attributesIndex++] = new LocalVariableTypeAttribute(classFileBytes, constantPool, offset + readOffset); 85 } else if (equals(attributeName, IAttributeNamesConstants.STACK_MAP_TABLE)) { 86 this.attributes[attributesIndex++] = new StackMapTableAttribute(classFileBytes, constantPool, offset + readOffset); 87 } else if (equals(attributeName, IAttributeNamesConstants.STACK_MAP)) { 88 this.attributes[attributesIndex++] = new StackMapAttribute(classFileBytes, constantPool, offset + readOffset); 89 } else { 90 this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset); 91 } 92 readOffset += (6 + u4At(classFileBytes, readOffset + 2, offset)); 93 } 94 } 95 98 public IClassFileAttribute[] getAttributes() { 99 return this.attributes; 100 } 101 102 105 public int getAttributesCount() { 106 return this.attributesCount; 107 } 108 109 112 public byte[] getBytecodes() { 113 if (this.bytecodes == null) { 114 System.arraycopy(this.classFileBytes, this.codeOffset, (this.bytecodes = new byte[(int) this.codeLength]), 0, (int) this.codeLength); 115 } 116 return this.bytecodes; 117 } 118 119 122 public long getCodeLength() { 123 return this.codeLength; 124 } 125 126 129 public IExceptionTableEntry[] getExceptionTable() { 130 return this.exceptionTableEntries; 131 } 132 133 136 public int getExceptionTableLength() { 137 return this.exceptionTableLength; 138 } 139 140 143 public ILineNumberAttribute getLineNumberAttribute() { 144 return this.lineNumberAttribute; 145 } 146 147 150 public ILocalVariableAttribute getLocalVariableAttribute() { 151 return this.localVariableAttribute; 152 } 153 154 157 public int getMaxLocals() { 158 return this.maxLocals; 159 } 160 161 164 public int getMaxStack() { 165 return this.maxStack; 166 } 167 168 171 public void traverse(IBytecodeVisitor visitor) throws ClassFormatException { 172 int pc = this.codeOffset; 173 int opcode, index, _const, branchOffset; 174 IConstantPoolEntry constantPoolEntry; 175 while (true) { 176 opcode = u1At(this.classFileBytes, 0, pc); 177 switch(opcode) { 178 case IOpcodeMnemonics.NOP : 179 visitor._nop(pc - this.codeOffset); 180 pc++; 181 break; 182 case IOpcodeMnemonics.ACONST_NULL : 183 visitor._aconst_null(pc - this.codeOffset); 184 pc++; 185 break; 186 case IOpcodeMnemonics.ICONST_M1 : 187 visitor._iconst_m1(pc - this.codeOffset); 188 pc++; 189 break; 190 case IOpcodeMnemonics.ICONST_0 : 191 visitor._iconst_0(pc - this.codeOffset); 192 pc++; 193 break; 194 case IOpcodeMnemonics.ICONST_1 : 195 visitor._iconst_1(pc - this.codeOffset); 196 pc++; 197 break; 198 case IOpcodeMnemonics.ICONST_2 : 199 visitor._iconst_2(pc - this.codeOffset); 200 pc++; 201 break; 202 case IOpcodeMnemonics.ICONST_3 : 203 visitor._iconst_3(pc - this.codeOffset); 204 pc++; 205 break; 206 case IOpcodeMnemonics.ICONST_4 : 207 visitor._iconst_4(pc - this.codeOffset); 208 pc++; 209 break; 210 case IOpcodeMnemonics.ICONST_5 : 211 visitor._iconst_5(pc - this.codeOffset); 212 pc++; 213 break; 214 case IOpcodeMnemonics.LCONST_0 : 215 visitor._lconst_0(pc - this.codeOffset); 216 pc++; 217 break; 218 case IOpcodeMnemonics.LCONST_1 : 219 visitor._lconst_1(pc - this.codeOffset); 220 pc++; 221 break; 222 case IOpcodeMnemonics.FCONST_0 : 223 visitor._fconst_0(pc - this.codeOffset); 224 pc++; 225 break; 226 case IOpcodeMnemonics.FCONST_1 : 227 visitor._fconst_1(pc - this.codeOffset); 228 pc++; 229 break; 230 case IOpcodeMnemonics.FCONST_2 : 231 visitor._fconst_2(pc - this.codeOffset); 232 pc++; 233 break; 234 case IOpcodeMnemonics.DCONST_0 : 235 visitor._dconst_0(pc - this.codeOffset); 236 pc++; 237 break; 238 case IOpcodeMnemonics.DCONST_1 : 239 visitor._dconst_1(pc - this.codeOffset); 240 pc++; 241 break; 242 case IOpcodeMnemonics.BIPUSH : 243 visitor._bipush(pc - this.codeOffset, (byte) i1At(this.classFileBytes, 1, pc)); 244 pc+=2; 245 break; 246 case IOpcodeMnemonics.SIPUSH : 247 visitor._sipush(pc - this.codeOffset, (short) i2At(this.classFileBytes, 1, pc)); 248 pc+=3; 249 break; 250 case IOpcodeMnemonics.LDC : 251 index = u1At(this.classFileBytes, 1, pc); 252 constantPoolEntry = this.constantPool.decodeEntry(index); 253 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Float 254 && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Integer 255 && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_String 256 && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { 257 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 258 } 259 visitor._ldc(pc - this.codeOffset, index, constantPoolEntry); 260 pc+=2; 261 break; 262 case IOpcodeMnemonics.LDC_W : 263 index = u2At(this.classFileBytes, 1, pc); 264 constantPoolEntry = this.constantPool.decodeEntry(index); 265 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Float 266 && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Integer 267 && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_String 268 && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { 269 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 270 } 271 visitor._ldc_w(pc - this.codeOffset, index, constantPoolEntry); 272 pc+=3; 273 break; 274 case IOpcodeMnemonics.LDC2_W : 275 index = u2At(this.classFileBytes, 1, pc); 276 constantPoolEntry = this.constantPool.decodeEntry(index); 277 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Double 278 && constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Long) { 279 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 280 } 281 visitor._ldc2_w(pc - this.codeOffset, index, constantPoolEntry); 282 pc+=3; 283 break; 284 case IOpcodeMnemonics.ILOAD : 285 index = u1At(this.classFileBytes, 1, pc); 286 visitor._iload(pc - this.codeOffset, index); 287 pc+=2; 288 break; 289 case IOpcodeMnemonics.LLOAD : 290 index = u1At(this.classFileBytes, 1, pc); 291 visitor._lload(pc - this.codeOffset, index); 292 pc+=2; 293 break; 294 case IOpcodeMnemonics.FLOAD : 295 index = u1At(this.classFileBytes, 1, pc); 296 visitor._fload(pc - this.codeOffset, index); 297 pc+=2; 298 break; 299 case IOpcodeMnemonics.DLOAD : 300 index = u1At(this.classFileBytes, 1, pc); 301 visitor._dload(pc - this.codeOffset, index); 302 pc+=2; 303 break; 304 case IOpcodeMnemonics.ALOAD : 305 index = u1At(this.classFileBytes, 1, pc); 306 visitor._aload(pc - this.codeOffset, index); 307 pc+=2; 308 break; 309 case IOpcodeMnemonics.ILOAD_0 : 310 visitor._iload_0(pc - this.codeOffset); 311 pc++; 312 break; 313 case IOpcodeMnemonics.ILOAD_1 : 314 visitor._iload_1(pc - this.codeOffset); 315 pc++; 316 break; 317 case IOpcodeMnemonics.ILOAD_2 : 318 visitor._iload_2(pc - this.codeOffset); 319 pc++; 320 break; 321 case IOpcodeMnemonics.ILOAD_3 : 322 visitor._iload_3(pc - this.codeOffset); 323 pc++; 324 break; 325 case IOpcodeMnemonics.LLOAD_0 : 326 visitor._lload_0(pc - this.codeOffset); 327 pc++; 328 break; 329 case IOpcodeMnemonics.LLOAD_1 : 330 visitor._lload_1(pc - this.codeOffset); 331 pc++; 332 break; 333 case IOpcodeMnemonics.LLOAD_2 : 334 visitor._lload_2(pc - this.codeOffset); 335 pc++; 336 break; 337 case IOpcodeMnemonics.LLOAD_3 : 338 visitor._lload_3(pc - this.codeOffset); 339 pc++; 340 break; 341 case IOpcodeMnemonics.FLOAD_0 : 342 visitor._fload_0(pc - this.codeOffset); 343 pc++; 344 break; 345 case IOpcodeMnemonics.FLOAD_1 : 346 visitor._fload_1(pc - this.codeOffset); 347 pc++; 348 break; 349 case IOpcodeMnemonics.FLOAD_2 : 350 visitor._fload_2(pc - this.codeOffset); 351 pc++; 352 break; 353 case IOpcodeMnemonics.FLOAD_3 : 354 visitor._fload_3(pc - this.codeOffset); 355 pc++; 356 break; 357 case IOpcodeMnemonics.DLOAD_0 : 358 visitor._dload_0(pc - this.codeOffset); 359 pc++; 360 break; 361 case IOpcodeMnemonics.DLOAD_1 : 362 visitor._dload_1(pc - this.codeOffset); 363 pc++; 364 break; 365 case IOpcodeMnemonics.DLOAD_2 : 366 visitor._dload_2(pc - this.codeOffset); 367 pc++; 368 break; 369 case IOpcodeMnemonics.DLOAD_3 : 370 visitor._dload_3(pc - this.codeOffset); 371 pc++; 372 break; 373 case IOpcodeMnemonics.ALOAD_0 : 374 visitor._aload_0(pc - this.codeOffset); 375 pc++; 376 break; 377 case IOpcodeMnemonics.ALOAD_1 : 378 visitor._aload_1(pc - this.codeOffset); 379 pc++; 380 break; 381 case IOpcodeMnemonics.ALOAD_2 : 382 visitor._aload_2(pc - this.codeOffset); 383 pc++; 384 break; 385 case IOpcodeMnemonics.ALOAD_3 : 386 visitor._aload_3(pc - this.codeOffset); 387 pc++; 388 break; 389 case IOpcodeMnemonics.IALOAD : 390 visitor._iaload(pc - this.codeOffset); 391 pc++; 392 break; 393 case IOpcodeMnemonics.LALOAD : 394 visitor._laload(pc - this.codeOffset); 395 pc++; 396 break; 397 case IOpcodeMnemonics.FALOAD : 398 visitor._faload(pc - this.codeOffset); 399 pc++; 400 break; 401 case IOpcodeMnemonics.DALOAD : 402 visitor._daload(pc - this.codeOffset); 403 pc++; 404 break; 405 case IOpcodeMnemonics.AALOAD : 406 visitor._aaload(pc - this.codeOffset); 407 pc++; 408 break; 409 case IOpcodeMnemonics.BALOAD : 410 visitor._baload(pc - this.codeOffset); 411 pc++; 412 break; 413 case IOpcodeMnemonics.CALOAD : 414 visitor._caload(pc - this.codeOffset); 415 pc++; 416 break; 417 case IOpcodeMnemonics.SALOAD : 418 visitor._saload(pc - this.codeOffset); 419 pc++; 420 break; 421 case IOpcodeMnemonics.ISTORE : 422 index = u1At(this.classFileBytes, 1, pc); 423 visitor._istore(pc - this.codeOffset, index); 424 pc+=2; 425 break; 426 case IOpcodeMnemonics.LSTORE : 427 index = u1At(this.classFileBytes, 1, pc); 428 visitor._lstore(pc - this.codeOffset, index); 429 pc+=2; 430 break; 431 case IOpcodeMnemonics.FSTORE : 432 index = u1At(this.classFileBytes, 1, pc); 433 visitor._fstore(pc - this.codeOffset, index); 434 pc+=2; 435 break; 436 case IOpcodeMnemonics.DSTORE : 437 index = u1At(this.classFileBytes, 1, pc); 438 visitor._dstore(pc - this.codeOffset, index); 439 pc+=2; 440 break; 441 case IOpcodeMnemonics.ASTORE : 442 index = u1At(this.classFileBytes, 1, pc); 443 visitor._astore(pc - this.codeOffset, index); 444 pc+=2; 445 break; 446 case IOpcodeMnemonics.ISTORE_0 : 447 visitor._istore_0(pc - this.codeOffset); 448 pc++; 449 break; 450 case IOpcodeMnemonics.ISTORE_1 : 451 visitor._istore_1(pc - this.codeOffset); 452 pc++; 453 break; 454 case IOpcodeMnemonics.ISTORE_2 : 455 visitor._istore_2(pc - this.codeOffset); 456 pc++; 457 break; 458 case IOpcodeMnemonics.ISTORE_3 : 459 visitor._istore_3(pc - this.codeOffset); 460 pc++; 461 break; 462 case IOpcodeMnemonics.LSTORE_0 : 463 visitor._lstore_0(pc - this.codeOffset); 464 pc++; 465 break; 466 case IOpcodeMnemonics.LSTORE_1 : 467 visitor._lstore_1(pc - this.codeOffset); 468 pc++; 469 break; 470 case IOpcodeMnemonics.LSTORE_2 : 471 visitor._lstore_2(pc - this.codeOffset); 472 pc++; 473 break; 474 case IOpcodeMnemonics.LSTORE_3 : 475 visitor._lstore_3(pc - this.codeOffset); 476 pc++; 477 break; 478 case IOpcodeMnemonics.FSTORE_0 : 479 visitor._fstore_0(pc - this.codeOffset); 480 pc++; 481 break; 482 case IOpcodeMnemonics.FSTORE_1 : 483 visitor._fstore_1(pc - this.codeOffset); 484 pc++; 485 break; 486 case IOpcodeMnemonics.FSTORE_2 : 487 visitor._fstore_2(pc - this.codeOffset); 488 pc++; 489 break; 490 case IOpcodeMnemonics.FSTORE_3 : 491 visitor._fstore_3(pc - this.codeOffset); 492 pc++; 493 break; 494 case IOpcodeMnemonics.DSTORE_0 : 495 visitor._dstore_0(pc - this.codeOffset); 496 pc++; 497 break; 498 case IOpcodeMnemonics.DSTORE_1 : 499 visitor._dstore_1(pc - this.codeOffset); 500 pc++; 501 break; 502 case IOpcodeMnemonics.DSTORE_2 : 503 visitor._dstore_2(pc - this.codeOffset); 504 pc++; 505 break; 506 case IOpcodeMnemonics.DSTORE_3 : 507 visitor._dstore_3(pc - this.codeOffset); 508 pc++; 509 break; 510 case IOpcodeMnemonics.ASTORE_0 : 511 visitor._astore_0(pc - this.codeOffset); 512 pc++; 513 break; 514 case IOpcodeMnemonics.ASTORE_1 : 515 visitor._astore_1(pc - this.codeOffset); 516 pc++; 517 break; 518 case IOpcodeMnemonics.ASTORE_2 : 519 visitor._astore_2(pc - this.codeOffset); 520 pc++; 521 break; 522 case IOpcodeMnemonics.ASTORE_3 : 523 visitor._astore_3(pc - this.codeOffset); 524 pc++; 525 break; 526 case IOpcodeMnemonics.IASTORE : 527 visitor._iastore(pc - this.codeOffset); 528 pc++; 529 break; 530 case IOpcodeMnemonics.LASTORE : 531 visitor._lastore(pc - this.codeOffset); 532 pc++; 533 break; 534 case IOpcodeMnemonics.FASTORE : 535 visitor._fastore(pc - this.codeOffset); 536 pc++; 537 break; 538 case IOpcodeMnemonics.DASTORE : 539 visitor._dastore(pc - this.codeOffset); 540 pc++; 541 break; 542 case IOpcodeMnemonics.AASTORE : 543 visitor._aastore(pc - this.codeOffset); 544 pc++; 545 break; 546 case IOpcodeMnemonics.BASTORE : 547 visitor._bastore(pc - this.codeOffset); 548 pc++; 549 break; 550 case IOpcodeMnemonics.CASTORE : 551 visitor._castore(pc - this.codeOffset); 552 pc++; 553 break; 554 case IOpcodeMnemonics.SASTORE : 555 visitor._sastore(pc - this.codeOffset); 556 pc++; 557 break; 558 case IOpcodeMnemonics.POP : 559 visitor._pop(pc - this.codeOffset); 560 pc++; 561 break; 562 case IOpcodeMnemonics.POP2 : 563 visitor._pop2(pc - this.codeOffset); 564 pc++; 565 break; 566 case IOpcodeMnemonics.DUP : 567 visitor._dup(pc - this.codeOffset); 568 pc++; 569 break; 570 case IOpcodeMnemonics.DUP_X1 : 571 visitor._dup_x1(pc - this.codeOffset); 572 pc++; 573 break; 574 case IOpcodeMnemonics.DUP_X2 : 575 visitor._dup_x2(pc - this.codeOffset); 576 pc++; 577 break; 578 case IOpcodeMnemonics.DUP2 : 579 visitor._dup2(pc - this.codeOffset); 580 pc++; 581 break; 582 case IOpcodeMnemonics.DUP2_X1 : 583 visitor._dup2_x1(pc - this.codeOffset); 584 pc++; 585 break; 586 case IOpcodeMnemonics.DUP2_X2 : 587 visitor._dup2_x2(pc - this.codeOffset); 588 pc++; 589 break; 590 case IOpcodeMnemonics.SWAP : 591 visitor._swap(pc - this.codeOffset); 592 pc++; 593 break; 594 case IOpcodeMnemonics.IADD : 595 visitor._iadd(pc - this.codeOffset); 596 pc++; 597 break; 598 case IOpcodeMnemonics.LADD : 599 visitor._ladd(pc - this.codeOffset); 600 pc++; 601 break; 602 case IOpcodeMnemonics.FADD : 603 visitor._fadd(pc - this.codeOffset); 604 pc++; 605 break; 606 case IOpcodeMnemonics.DADD : 607 visitor._dadd(pc - this.codeOffset); 608 pc++; 609 break; 610 case IOpcodeMnemonics.ISUB : 611 visitor._isub(pc - this.codeOffset); 612 pc++; 613 break; 614 case IOpcodeMnemonics.LSUB : 615 visitor._lsub(pc - this.codeOffset); 616 pc++; 617 break; 618 case IOpcodeMnemonics.FSUB : 619 visitor._fsub(pc - this.codeOffset); 620 pc++; 621 break; 622 case IOpcodeMnemonics.DSUB : 623 visitor._dsub(pc - this.codeOffset); 624 pc++; 625 break; 626 case IOpcodeMnemonics.IMUL : 627 visitor._imul(pc - this.codeOffset); 628 pc++; 629 break; 630 case IOpcodeMnemonics.LMUL : 631 visitor._lmul(pc - this.codeOffset); 632 pc++; 633 break; 634 case IOpcodeMnemonics.FMUL : 635 visitor._fmul(pc - this.codeOffset); 636 pc++; 637 break; 638 case IOpcodeMnemonics.DMUL : 639 visitor._dmul(pc - this.codeOffset); 640 pc++; 641 break; 642 case IOpcodeMnemonics.IDIV : 643 visitor._idiv(pc - this.codeOffset); 644 pc++; 645 break; 646 case IOpcodeMnemonics.LDIV : 647 visitor._ldiv(pc - this.codeOffset); 648 pc++; 649 break; 650 case IOpcodeMnemonics.FDIV : 651 visitor._fdiv(pc - this.codeOffset); 652 pc++; 653 break; 654 case IOpcodeMnemonics.DDIV : 655 visitor._ddiv(pc - this.codeOffset); 656 pc++; 657 break; 658 case IOpcodeMnemonics.IREM : 659 visitor._irem(pc - this.codeOffset); 660 pc++; 661 break; 662 case IOpcodeMnemonics.LREM : 663 visitor._lrem(pc - this.codeOffset); 664 pc++; 665 break; 666 case IOpcodeMnemonics.FREM : 667 visitor._frem(pc - this.codeOffset); 668 pc++; 669 break; 670 case IOpcodeMnemonics.DREM : 671 visitor._drem(pc - this.codeOffset); 672 pc++; 673 break; 674 case IOpcodeMnemonics.INEG : 675 visitor._ineg(pc - this.codeOffset); 676 pc++; 677 break; 678 case IOpcodeMnemonics.LNEG : 679 visitor._lneg(pc - this.codeOffset); 680 pc++; 681 break; 682 case IOpcodeMnemonics.FNEG : 683 visitor._fneg(pc - this.codeOffset); 684 pc++; 685 break; 686 case IOpcodeMnemonics.DNEG : 687 visitor._dneg(pc - this.codeOffset); 688 pc++; 689 break; 690 case IOpcodeMnemonics.ISHL : 691 visitor._ishl(pc - this.codeOffset); 692 pc++; 693 break; 694 case IOpcodeMnemonics.LSHL : 695 visitor._lshl(pc - this.codeOffset); 696 pc++; 697 break; 698 case IOpcodeMnemonics.ISHR : 699 visitor._ishr(pc - this.codeOffset); 700 pc++; 701 break; 702 case IOpcodeMnemonics.LSHR : 703 visitor._lshr(pc - this.codeOffset); 704 pc++; 705 break; 706 case IOpcodeMnemonics.IUSHR : 707 visitor._iushr(pc - this.codeOffset); 708 pc++; 709 break; 710 case IOpcodeMnemonics.LUSHR : 711 visitor._lushr(pc - this.codeOffset); 712 pc++; 713 break; 714 case IOpcodeMnemonics.IAND : 715 visitor._iand(pc - this.codeOffset); 716 pc++; 717 break; 718 case IOpcodeMnemonics.LAND : 719 visitor._land(pc - this.codeOffset); 720 pc++; 721 break; 722 case IOpcodeMnemonics.IOR : 723 visitor._ior(pc - this.codeOffset); 724 pc++; 725 break; 726 case IOpcodeMnemonics.LOR : 727 visitor._lor(pc - this.codeOffset); 728 pc++; 729 break; 730 case IOpcodeMnemonics.IXOR : 731 visitor._ixor(pc - this.codeOffset); 732 pc++; 733 break; 734 case IOpcodeMnemonics.LXOR : 735 visitor._lxor(pc - this.codeOffset); 736 pc++; 737 break; 738 case IOpcodeMnemonics.IINC : 739 index = u1At(this.classFileBytes, 1, pc); 740 _const = i1At(this.classFileBytes, 2, pc); 741 visitor._iinc(pc - this.codeOffset, index, _const); 742 pc+=3; 743 break; 744 case IOpcodeMnemonics.I2L : 745 visitor._i2l(pc - this.codeOffset); 746 pc++; 747 break; 748 case IOpcodeMnemonics.I2F : 749 visitor._i2f(pc - this.codeOffset); 750 pc++; 751 break; 752 case IOpcodeMnemonics.I2D : 753 visitor._i2d(pc - this.codeOffset); 754 pc++; 755 break; 756 case IOpcodeMnemonics.L2I : 757 visitor._l2i(pc - this.codeOffset); 758 pc++; 759 break; 760 case IOpcodeMnemonics.L2F : 761 visitor._l2f(pc - this.codeOffset); 762 pc++; 763 break; 764 case IOpcodeMnemonics.L2D : 765 visitor._l2d(pc - this.codeOffset); 766 pc++; 767 break; 768 case IOpcodeMnemonics.F2I : 769 visitor._f2i(pc - this.codeOffset); 770 pc++; 771 break; 772 case IOpcodeMnemonics.F2L : 773 visitor._f2l(pc - this.codeOffset); 774 pc++; 775 break; 776 case IOpcodeMnemonics.F2D : 777 visitor._f2d(pc - this.codeOffset); 778 pc++; 779 break; 780 case IOpcodeMnemonics.D2I : 781 visitor._d2i(pc - this.codeOffset); 782 pc++; 783 break; 784 case IOpcodeMnemonics.D2L : 785 visitor._d2l(pc - this.codeOffset); 786 pc++; 787 break; 788 case IOpcodeMnemonics.D2F : 789 visitor._d2f(pc - this.codeOffset); 790 pc++; 791 break; 792 case IOpcodeMnemonics.I2B : 793 visitor._i2b(pc - this.codeOffset); 794 pc++; 795 break; 796 case IOpcodeMnemonics.I2C : 797 visitor._i2c(pc - this.codeOffset); 798 pc++; 799 break; 800 case IOpcodeMnemonics.I2S : 801 visitor._i2s(pc - this.codeOffset); 802 pc++; 803 break; 804 case IOpcodeMnemonics.LCMP : 805 visitor._lcmp(pc - this.codeOffset); 806 pc++; 807 break; 808 case IOpcodeMnemonics.FCMPL : 809 visitor._fcmpl(pc - this.codeOffset); 810 pc++; 811 break; 812 case IOpcodeMnemonics.FCMPG : 813 visitor._fcmpg(pc - this.codeOffset); 814 pc++; 815 break; 816 case IOpcodeMnemonics.DCMPL : 817 visitor._dcmpl(pc - this.codeOffset); 818 pc++; 819 break; 820 case IOpcodeMnemonics.DCMPG : 821 visitor._dcmpg(pc - this.codeOffset); 822 pc++; 823 break; 824 case IOpcodeMnemonics.IFEQ : 825 branchOffset = i2At(this.classFileBytes, 1, pc); 826 visitor._ifeq(pc - this.codeOffset , branchOffset); 827 pc+=3; 828 break; 829 case IOpcodeMnemonics.IFNE : 830 branchOffset = i2At(this.classFileBytes, 1, pc); 831 visitor._ifne(pc - this.codeOffset , branchOffset); 832 pc+=3; 833 break; 834 case IOpcodeMnemonics.IFLT : 835 branchOffset = i2At(this.classFileBytes, 1, pc); 836 visitor._iflt(pc - this.codeOffset , branchOffset); 837 pc+=3; 838 break; 839 case IOpcodeMnemonics.IFGE : 840 branchOffset = i2At(this.classFileBytes, 1, pc); 841 visitor._ifge(pc - this.codeOffset , branchOffset); 842 pc+=3; 843 break; 844 case IOpcodeMnemonics.IFGT : 845 branchOffset = i2At(this.classFileBytes, 1, pc); 846 visitor._ifgt(pc - this.codeOffset , branchOffset); 847 pc+=3; 848 break; 849 case IOpcodeMnemonics.IFLE : 850 branchOffset = i2At(this.classFileBytes, 1, pc); 851 visitor._ifle(pc - this.codeOffset , branchOffset); 852 pc+=3; 853 break; 854 case IOpcodeMnemonics.IF_ICMPEQ : 855 branchOffset = i2At(this.classFileBytes, 1, pc); 856 visitor._if_icmpeq(pc - this.codeOffset , branchOffset); 857 pc+=3; 858 break; 859 case IOpcodeMnemonics.IF_ICMPNE : 860 branchOffset = i2At(this.classFileBytes, 1, pc); 861 visitor._if_icmpne(pc - this.codeOffset , branchOffset); 862 pc+=3; 863 break; 864 case IOpcodeMnemonics.IF_ICMPLT : 865 branchOffset = i2At(this.classFileBytes, 1, pc); 866 visitor._if_icmplt(pc - this.codeOffset , branchOffset); 867 pc+=3; 868 break; 869 case IOpcodeMnemonics.IF_ICMPGE : 870 branchOffset = i2At(this.classFileBytes, 1, pc); 871 visitor._if_icmpge(pc - this.codeOffset , branchOffset); 872 pc+=3; 873 break; 874 case IOpcodeMnemonics.IF_ICMPGT : 875 branchOffset = i2At(this.classFileBytes, 1, pc); 876 visitor._if_icmpgt(pc - this.codeOffset , branchOffset); 877 pc+=3; 878 break; 879 case IOpcodeMnemonics.IF_ICMPLE : 880 branchOffset = i2At(this.classFileBytes, 1, pc); 881 visitor._if_icmple(pc - this.codeOffset , branchOffset); 882 pc+=3; 883 break; 884 case IOpcodeMnemonics.IF_ACMPEQ : 885 branchOffset = i2At(this.classFileBytes, 1, pc); 886 visitor._if_acmpeq(pc - this.codeOffset , branchOffset); 887 pc+=3; 888 break; 889 case IOpcodeMnemonics.IF_ACMPNE : 890 branchOffset = i2At(this.classFileBytes, 1, pc); 891 visitor._if_acmpne(pc - this.codeOffset , branchOffset); 892 pc+=3; 893 break; 894 case IOpcodeMnemonics.GOTO : 895 branchOffset = i2At(this.classFileBytes, 1, pc); 896 visitor._goto(pc - this.codeOffset , branchOffset); 897 pc+=3; 898 break; 899 case IOpcodeMnemonics.JSR : 900 branchOffset = i2At(this.classFileBytes, 1, pc); 901 visitor._jsr(pc - this.codeOffset , branchOffset); 902 pc+=3; 903 break; 904 case IOpcodeMnemonics.RET : 905 index = u1At(this.classFileBytes, 1, pc); 906 visitor._ret(pc - this.codeOffset, index); 907 pc+=2; 908 break; 909 case IOpcodeMnemonics.TABLESWITCH : 910 int startpc = pc; 911 pc++; 912 while (((pc - this.codeOffset) & 0x03) != 0) { pc++; 914 } 915 int defaultOffset = i4At(this.classFileBytes, 0, pc); 916 pc += 4; 917 int low = i4At(this.classFileBytes, 0, pc); 918 pc += 4; 919 int high = i4At(this.classFileBytes, 0, pc); 920 pc += 4; 921 int length = high - low + 1; 922 int[] jumpOffsets = new int[length]; 923 for (int i = 0; i < length; i++) { 924 jumpOffsets[i] = i4At(this.classFileBytes, 0, pc); 925 pc += 4; 926 } 927 visitor._tableswitch(startpc - this.codeOffset, defaultOffset, low, high, jumpOffsets); 928 break; 929 case IOpcodeMnemonics.LOOKUPSWITCH : 930 startpc = pc; 931 pc++; 932 while (((pc - this.codeOffset) & 0x03) != 0) { 933 pc++; 934 } 935 defaultOffset = i4At(this.classFileBytes, 0, pc); 936 pc += 4; 937 int npairs = (int) u4At(this.classFileBytes, 0, pc); 938 int[][] offset_pairs = new int[npairs][2]; 939 pc += 4; 940 for (int i = 0; i < npairs; i++) { 941 offset_pairs[i][0] = i4At(this.classFileBytes, 0, pc); 942 pc += 4; 943 offset_pairs[i][1] = i4At(this.classFileBytes, 0, pc); 944 pc += 4; 945 } 946 visitor._lookupswitch(startpc - this.codeOffset, defaultOffset, npairs, offset_pairs); 947 break; 948 case IOpcodeMnemonics.IRETURN : 949 visitor._ireturn(pc - this.codeOffset); 950 pc++; 951 break; 952 case IOpcodeMnemonics.LRETURN : 953 visitor._lreturn(pc - this.codeOffset); 954 pc++; 955 break; 956 case IOpcodeMnemonics.FRETURN : 957 visitor._freturn(pc - this.codeOffset); 958 pc++; 959 break; 960 case IOpcodeMnemonics.DRETURN : 961 visitor._dreturn(pc - this.codeOffset); 962 pc++; 963 break; 964 case IOpcodeMnemonics.ARETURN : 965 visitor._areturn(pc - this.codeOffset); 966 pc++; 967 break; 968 case IOpcodeMnemonics.RETURN : 969 visitor._return(pc - this.codeOffset); 970 pc++; 971 break; 972 case IOpcodeMnemonics.GETSTATIC : 973 index = u2At(this.classFileBytes, 1, pc); 974 constantPoolEntry = this.constantPool.decodeEntry(index); 975 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) { 976 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 977 } 978 visitor._getstatic(pc - this.codeOffset, index, constantPoolEntry); 979 pc+=3; 980 break; 981 case IOpcodeMnemonics.PUTSTATIC : 982 index = u2At(this.classFileBytes, 1, pc); 983 constantPoolEntry = this.constantPool.decodeEntry(index); 984 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) { 985 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 986 } 987 visitor._putstatic(pc - this.codeOffset, index, constantPoolEntry); 988 pc+=3; 989 break; 990 case IOpcodeMnemonics.GETFIELD : 991 index = u2At(this.classFileBytes, 1, pc); 992 constantPoolEntry = this.constantPool.decodeEntry(index); 993 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) { 994 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 995 } 996 visitor._getfield(pc - this.codeOffset, index, constantPoolEntry); 997 pc+=3; 998 break; 999 case IOpcodeMnemonics.PUTFIELD : 1000 index = u2At(this.classFileBytes, 1, pc); 1001 constantPoolEntry = this.constantPool.decodeEntry(index); 1002 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Fieldref) { 1003 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1004 } 1005 visitor._putfield(pc - this.codeOffset, index, constantPoolEntry); 1006 pc+=3; 1007 break; 1008 case IOpcodeMnemonics.INVOKEVIRTUAL : 1009 index = u2At(this.classFileBytes, 1, pc); 1010 constantPoolEntry = this.constantPool.decodeEntry(index); 1011 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Methodref) { 1012 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1013 } 1014 visitor._invokevirtual(pc - this.codeOffset, index, constantPoolEntry); 1015 pc+=3; 1016 break; 1017 case IOpcodeMnemonics.INVOKESPECIAL : 1018 index = u2At(this.classFileBytes, 1, pc); 1019 constantPoolEntry = this.constantPool.decodeEntry(index); 1020 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Methodref) { 1021 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1022 } 1023 visitor._invokespecial(pc - this.codeOffset, index, constantPoolEntry); 1024 pc+=3; 1025 break; 1026 case IOpcodeMnemonics.INVOKESTATIC : 1027 index = u2At(this.classFileBytes, 1, pc); 1028 constantPoolEntry = this.constantPool.decodeEntry(index); 1029 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Methodref) { 1030 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1031 } 1032 visitor._invokestatic(pc - this.codeOffset, index, constantPoolEntry); 1033 pc+=3; 1034 break; 1035 case IOpcodeMnemonics.INVOKEINTERFACE : 1036 index = u2At(this.classFileBytes, 1, pc); 1037 constantPoolEntry = this.constantPool.decodeEntry(index); 1038 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_InterfaceMethodref) { 1039 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1040 } 1041 byte count = (byte) u1At(this.classFileBytes, 3, pc); 1042 int extraArgs = u1At(this.classFileBytes, 4, pc); 1043 if (extraArgs != 0) { 1044 throw new ClassFormatException(ClassFormatException.INVALID_ARGUMENTS_FOR_INVOKEINTERFACE); 1045 } 1046 visitor._invokeinterface(pc - this.codeOffset, index, count, constantPoolEntry); 1047 pc += 5; 1048 break; 1049 case IOpcodeMnemonics.NEW : 1050 index = u2At(this.classFileBytes, 1, pc); 1051 constantPoolEntry = this.constantPool.decodeEntry(index); 1052 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { 1053 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1054 } 1055 visitor._new(pc - this.codeOffset, index, constantPoolEntry); 1056 pc+=3; 1057 break; 1058 case IOpcodeMnemonics.NEWARRAY : 1059 int atype = u1At(this.classFileBytes, 1, pc); 1060 visitor._newarray(pc - this.codeOffset, atype); 1061 pc+=2; 1062 break; 1063 case IOpcodeMnemonics.ANEWARRAY : 1064 index = u2At(this.classFileBytes, 1, pc); 1065 constantPoolEntry = this.constantPool.decodeEntry(index); 1066 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { 1067 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1068 } 1069 visitor._anewarray(pc - this.codeOffset, index, constantPoolEntry); 1070 pc+=3; 1071 break; 1072 case IOpcodeMnemonics.ARRAYLENGTH : 1073 visitor._arraylength(pc - this.codeOffset); 1074 pc++; 1075 break; 1076 case IOpcodeMnemonics.ATHROW : 1077 visitor._athrow(pc - this.codeOffset); 1078 pc++; 1079 break; 1080 case IOpcodeMnemonics.CHECKCAST : 1081 index = u2At(this.classFileBytes, 1, pc); 1082 constantPoolEntry = this.constantPool.decodeEntry(index); 1083 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { 1084 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1085 } 1086 visitor._checkcast(pc - this.codeOffset, index, constantPoolEntry); 1087 pc+=3; 1088 break; 1089 case IOpcodeMnemonics.INSTANCEOF : 1090 index = u2At(this.classFileBytes, 1, pc); 1091 constantPoolEntry = this.constantPool.decodeEntry(index); 1092 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { 1093 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1094 } 1095 visitor._instanceof(pc - this.codeOffset, index, constantPoolEntry); 1096 pc+=3; 1097 break; 1098 case IOpcodeMnemonics.MONITORENTER : 1099 visitor._monitorenter(pc - this.codeOffset); 1100 pc++; 1101 break; 1102 case IOpcodeMnemonics.MONITOREXIT : 1103 visitor._monitorexit(pc - this.codeOffset); 1104 pc++; 1105 break; 1106 case IOpcodeMnemonics.WIDE : 1107 opcode = u1At(this.classFileBytes, 1, pc); 1108 if (opcode == IOpcodeMnemonics.IINC) { 1109 index = u2At(this.classFileBytes, 2, pc); 1110 _const = i2At(this.classFileBytes, 4, pc); 1111 visitor._wide(pc - this.codeOffset, opcode, index, _const); 1112 pc += 6; 1113 } else { 1114 index = u2At(this.classFileBytes, 2, pc); 1115 visitor._wide(pc - this.codeOffset , opcode, index); 1116 pc += 4; 1117 } 1118 break; 1119 case IOpcodeMnemonics.MULTIANEWARRAY : 1120 index = u2At(this.classFileBytes, 1, pc); 1121 constantPoolEntry = this.constantPool.decodeEntry(index); 1122 if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Class) { 1123 throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); 1124 } 1125 int dimensions = u1At(this.classFileBytes, 3, pc); 1126 visitor._multianewarray(pc - this.codeOffset, index, dimensions, constantPoolEntry); 1127 pc+=4; 1128 break; 1129 case IOpcodeMnemonics.IFNULL : 1130 branchOffset = i2At(this.classFileBytes, 1, pc); 1131 visitor._ifnull(pc - this.codeOffset , branchOffset); 1132 pc+=3; 1133 break; 1134 case IOpcodeMnemonics.IFNONNULL : 1135 branchOffset = i2At(this.classFileBytes, 1, pc); 1136 visitor._ifnonnull(pc - this.codeOffset , branchOffset); 1137 pc+=3; 1138 break; 1139 case IOpcodeMnemonics.GOTO_W : 1140 branchOffset = i4At(this.classFileBytes, 1, pc); 1141 visitor._goto_w(pc - this.codeOffset, branchOffset); 1142 pc+=5; 1143 break; 1144 case IOpcodeMnemonics.JSR_W : 1145 branchOffset = i4At(this.classFileBytes, 1, pc); 1146 visitor._jsr_w(pc - this.codeOffset, branchOffset); 1147 pc+=5; 1148 break; 1149 case IOpcodeMnemonics.BREAKPOINT : 1150 visitor._breakpoint(pc - this.codeOffset); 1151 pc++; 1152 break; 1153 case IOpcodeMnemonics.IMPDEP1 : 1154 visitor._impdep1(pc - this.codeOffset); 1155 pc++; 1156 break; 1157 case IOpcodeMnemonics.IMPDEP2 : 1158 visitor._impdep2(pc - this.codeOffset); 1159 pc++; 1160 break; 1161 default: 1162 throw new ClassFormatException(ClassFormatException.INVALID_BYTECODE); 1163 } 1164 if (pc >= (this.codeLength + this.codeOffset)) { 1165 break; 1166 } 1167 } 1168 } 1169} 1170 | Popular Tags |