< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java

Print this page

1814                 case Opcodes.DLOAD:
1815                 case Opcodes.ALOAD:
1816                 case Opcodes.ISTORE:
1817                 case Opcodes.LSTORE:
1818                 case Opcodes.FSTORE:
1819                 case Opcodes.DSTORE:
1820                 case Opcodes.ASTORE:
1821                 case Opcodes.RET:
1822                 case Opcodes.BIPUSH:
1823                 case Opcodes.NEWARRAY:
1824                 case Opcodes.LDC:
1825                     currentOffset += 2;
1826                     break;
1827                 case Opcodes.SIPUSH:
1828                 case Constants.LDC_W:
1829                 case Constants.LDC2_W:
1830                 case Opcodes.GETSTATIC:
1831                 case Opcodes.PUTSTATIC:
1832                 case Opcodes.GETFIELD:
1833                 case Opcodes.PUTFIELD:


1834                 case Opcodes.INVOKEVIRTUAL:
1835                 case Opcodes.INVOKESPECIAL:
1836                 case Opcodes.INVOKESTATIC:
1837                 case Opcodes.NEW:
1838                 case Opcodes.ANEWARRAY:
1839                 case Opcodes.CHECKCAST:
1840                 case Opcodes.INSTANCEOF:
1841                 case Opcodes.IINC:
1842                     currentOffset += 3;
1843                     break;
1844                 case Opcodes.INVOKEINTERFACE:
1845                 case Opcodes.INVOKEDYNAMIC:
1846                     currentOffset += 5;
1847                     break;
1848                 case Opcodes.MULTIANEWARRAY:
1849                     currentOffset += 4;
1850                     break;
1851                 default:
1852                     throw new IllegalArgumentException();
1853             }

2426                     methodVisitor.visitIntInsn(opcode, readShort(currentOffset + 1));
2427                     currentOffset += 3;
2428                     break;
2429                 case Opcodes.LDC:
2430                     methodVisitor.visitLdcInsn(readConst(classBuffer[currentOffset + 1] & 0xFF, charBuffer));
2431                     currentOffset += 2;
2432                     break;
2433                 case Constants.LDC_W:
2434                 case Constants.LDC2_W:
2435                     methodVisitor.visitLdcInsn(readConst(readUnsignedShort(currentOffset + 1), charBuffer));
2436                     currentOffset += 3;
2437                     break;
2438                 case Opcodes.GETSTATIC:
2439                 case Opcodes.PUTSTATIC:
2440                 case Opcodes.GETFIELD:
2441                 case Opcodes.PUTFIELD:
2442                 case Opcodes.INVOKEVIRTUAL:
2443                 case Opcodes.INVOKESPECIAL:
2444                 case Opcodes.INVOKESTATIC:
2445                 case Opcodes.INVOKEINTERFACE:

2446                     {
2447                         int cpInfoOffset = cpInfoOffsets[readUnsignedShort(currentOffset + 1)];
2448                         int nameAndTypeCpInfoOffset = cpInfoOffsets[readUnsignedShort(cpInfoOffset + 2)];
2449                         String owner = readClass(cpInfoOffset, charBuffer);
2450                         String name = readUTF8(nameAndTypeCpInfoOffset, charBuffer);
2451                         String descriptor = readUTF8(nameAndTypeCpInfoOffset + 2, charBuffer);
2452                         if (opcode < Opcodes.INVOKEVIRTUAL) {
2453                             methodVisitor.visitFieldInsn(opcode, owner, name, descriptor);
2454                         } else {
2455                             boolean isInterface =
2456                                     classBuffer[cpInfoOffset - 1] == Symbol.CONSTANT_INTERFACE_METHODREF_TAG;
2457                             methodVisitor.visitMethodInsn(opcode, owner, name, descriptor, isInterface);


2458                         }
2459                         if (opcode == Opcodes.INVOKEINTERFACE) {
2460                             currentOffset += 5;
2461                         } else {
2462                             currentOffset += 3;
2463                         }
2464                         break;
2465                     }
2466                 case Opcodes.INVOKEDYNAMIC:
2467                     {
2468                         int cpInfoOffset = cpInfoOffsets[readUnsignedShort(currentOffset + 1)];
2469                         int nameAndTypeCpInfoOffset = cpInfoOffsets[readUnsignedShort(cpInfoOffset + 2)];
2470                         String name = readUTF8(nameAndTypeCpInfoOffset, charBuffer);
2471                         String descriptor = readUTF8(nameAndTypeCpInfoOffset + 2, charBuffer);
2472                         int bootstrapMethodOffset = bootstrapMethodOffsets[readUnsignedShort(cpInfoOffset)];
2473                         Handle handle =
2474                                 (Handle) readConst(readUnsignedShort(bootstrapMethodOffset), charBuffer);
2475                         Object[] bootstrapMethodArguments =
2476                                 new Object[readUnsignedShort(bootstrapMethodOffset + 2)];
2477                         bootstrapMethodOffset += 4;
2478                         for (int i = 0; i < bootstrapMethodArguments.length; i++) {
2479                             bootstrapMethodArguments[i] =
2480                                     readConst(readUnsignedShort(bootstrapMethodOffset), charBuffer);
2481                             bootstrapMethodOffset += 2;
2482                         }
2483                         methodVisitor.visitInvokeDynamicInsn(
2484                                 name, descriptor, handle, bootstrapMethodArguments);
2485                         currentOffset += 5;
2486                         break;
2487                     }
2488                 case Opcodes.NEW:
2489                 case Opcodes.ANEWARRAY:
2490                 case Opcodes.CHECKCAST:
2491                 case Opcodes.INSTANCEOF:

2492                     methodVisitor.visitTypeInsn(opcode, readClass(currentOffset + 1, charBuffer));
2493                     currentOffset += 3;
2494                     break;
2495                 case Opcodes.IINC:
2496                     methodVisitor.visitIincInsn(
2497                             classBuffer[currentOffset + 1] & 0xFF, classBuffer[currentOffset + 2]);
2498                     currentOffset += 3;
2499                     break;
2500                 case Opcodes.MULTIANEWARRAY:
2501                     methodVisitor.visitMultiANewArrayInsn(
2502                             readClass(currentOffset + 1, charBuffer), classBuffer[currentOffset + 3] & 0xFF);
2503                     currentOffset += 4;
2504                     break;
2505                 default:
2506                     throw new AssertionError();
2507             }
2508 
2509             // Visit the runtime visible instruction annotations, if any.
2510             while (visibleTypeAnnotationOffsets != null
2511                     && currentVisibleTypeAnnotationIndex < visibleTypeAnnotationOffsets.length

3223                 case 'Z':
3224                 case 'C':
3225                 case 'B':
3226                 case 'S':
3227                 case 'I':
3228                     locals[numLocal++] = Opcodes.INTEGER;
3229                     break;
3230                 case 'F':
3231                     locals[numLocal++] = Opcodes.FLOAT;
3232                     break;
3233                 case 'J':
3234                     locals[numLocal++] = Opcodes.LONG;
3235                     break;
3236                 case 'D':
3237                     locals[numLocal++] = Opcodes.DOUBLE;
3238                     break;
3239                 case '[':
3240                     while (methodDescriptor.charAt(currentMethodDescritorOffset) == '[') {
3241                         ++currentMethodDescritorOffset;
3242                     }
3243                     if (methodDescriptor.charAt(currentMethodDescritorOffset) == 'L') {

3244                         ++currentMethodDescritorOffset;
3245                         while (methodDescriptor.charAt(currentMethodDescritorOffset) != ';') {
3246                             ++currentMethodDescritorOffset;
3247                         }
3248                     }
3249                     locals[numLocal++] =
3250                             methodDescriptor.substring(
3251                                     currentArgumentDescriptorStartOffset, ++currentMethodDescritorOffset);
3252                     break;
3253                 case 'L':
3254                     while (methodDescriptor.charAt(currentMethodDescritorOffset) != ';') {
3255                         ++currentMethodDescritorOffset;
3256                     }
3257                     locals[numLocal++] =
3258                             methodDescriptor.substring(
3259                                     currentArgumentDescriptorStartOffset + 1, currentMethodDescritorOffset++);
3260                     break;
3261                 default:
3262                     context.currentFrameLocalCount = numLocal;
3263                     return;

1814                 case Opcodes.DLOAD:
1815                 case Opcodes.ALOAD:
1816                 case Opcodes.ISTORE:
1817                 case Opcodes.LSTORE:
1818                 case Opcodes.FSTORE:
1819                 case Opcodes.DSTORE:
1820                 case Opcodes.ASTORE:
1821                 case Opcodes.RET:
1822                 case Opcodes.BIPUSH:
1823                 case Opcodes.NEWARRAY:
1824                 case Opcodes.LDC:
1825                     currentOffset += 2;
1826                     break;
1827                 case Opcodes.SIPUSH:
1828                 case Constants.LDC_W:
1829                 case Constants.LDC2_W:
1830                 case Opcodes.GETSTATIC:
1831                 case Opcodes.PUTSTATIC:
1832                 case Opcodes.GETFIELD:
1833                 case Opcodes.PUTFIELD:
1834                 case Opcodes.DEFAULT:
1835                 case Opcodes.WITHFIELD:
1836                 case Opcodes.INVOKEVIRTUAL:
1837                 case Opcodes.INVOKESPECIAL:
1838                 case Opcodes.INVOKESTATIC:
1839                 case Opcodes.NEW:
1840                 case Opcodes.ANEWARRAY:
1841                 case Opcodes.CHECKCAST:
1842                 case Opcodes.INSTANCEOF:
1843                 case Opcodes.IINC:
1844                     currentOffset += 3;
1845                     break;
1846                 case Opcodes.INVOKEINTERFACE:
1847                 case Opcodes.INVOKEDYNAMIC:
1848                     currentOffset += 5;
1849                     break;
1850                 case Opcodes.MULTIANEWARRAY:
1851                     currentOffset += 4;
1852                     break;
1853                 default:
1854                     throw new IllegalArgumentException();
1855             }

2428                     methodVisitor.visitIntInsn(opcode, readShort(currentOffset + 1));
2429                     currentOffset += 3;
2430                     break;
2431                 case Opcodes.LDC:
2432                     methodVisitor.visitLdcInsn(readConst(classBuffer[currentOffset + 1] & 0xFF, charBuffer));
2433                     currentOffset += 2;
2434                     break;
2435                 case Constants.LDC_W:
2436                 case Constants.LDC2_W:
2437                     methodVisitor.visitLdcInsn(readConst(readUnsignedShort(currentOffset + 1), charBuffer));
2438                     currentOffset += 3;
2439                     break;
2440                 case Opcodes.GETSTATIC:
2441                 case Opcodes.PUTSTATIC:
2442                 case Opcodes.GETFIELD:
2443                 case Opcodes.PUTFIELD:
2444                 case Opcodes.INVOKEVIRTUAL:
2445                 case Opcodes.INVOKESPECIAL:
2446                 case Opcodes.INVOKESTATIC:
2447                 case Opcodes.INVOKEINTERFACE:
2448                 case Opcodes.WITHFIELD:
2449                     {
2450                         int cpInfoOffset = cpInfoOffsets[readUnsignedShort(currentOffset + 1)];
2451                         int nameAndTypeCpInfoOffset = cpInfoOffsets[readUnsignedShort(cpInfoOffset + 2)];
2452                         String owner = readClass(cpInfoOffset, charBuffer);
2453                         String name = readUTF8(nameAndTypeCpInfoOffset, charBuffer);
2454                         String descriptor = readUTF8(nameAndTypeCpInfoOffset + 2, charBuffer);
2455                         if (opcode >= Opcodes.INVOKEVIRTUAL && opcode <= Opcodes.INVOKEINTERFACE) {


2456                             boolean isInterface =
2457                                     classBuffer[cpInfoOffset - 1] == Symbol.CONSTANT_INTERFACE_METHODREF_TAG;
2458                             methodVisitor.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
2459                         } else {
2460                             methodVisitor.visitFieldInsn(opcode, owner, name, descriptor);
2461                         }
2462                         if (opcode == Opcodes.INVOKEINTERFACE) {
2463                             currentOffset += 5;
2464                         } else {
2465                             currentOffset += 3;
2466                         }
2467                         break;
2468                     }
2469                 case Opcodes.INVOKEDYNAMIC:
2470                     {
2471                         int cpInfoOffset = cpInfoOffsets[readUnsignedShort(currentOffset + 1)];
2472                         int nameAndTypeCpInfoOffset = cpInfoOffsets[readUnsignedShort(cpInfoOffset + 2)];
2473                         String name = readUTF8(nameAndTypeCpInfoOffset, charBuffer);
2474                         String descriptor = readUTF8(nameAndTypeCpInfoOffset + 2, charBuffer);
2475                         int bootstrapMethodOffset = bootstrapMethodOffsets[readUnsignedShort(cpInfoOffset)];
2476                         Handle handle =
2477                                 (Handle) readConst(readUnsignedShort(bootstrapMethodOffset), charBuffer);
2478                         Object[] bootstrapMethodArguments =
2479                                 new Object[readUnsignedShort(bootstrapMethodOffset + 2)];
2480                         bootstrapMethodOffset += 4;
2481                         for (int i = 0; i < bootstrapMethodArguments.length; i++) {
2482                             bootstrapMethodArguments[i] =
2483                                     readConst(readUnsignedShort(bootstrapMethodOffset), charBuffer);
2484                             bootstrapMethodOffset += 2;
2485                         }
2486                         methodVisitor.visitInvokeDynamicInsn(
2487                                 name, descriptor, handle, bootstrapMethodArguments);
2488                         currentOffset += 5;
2489                         break;
2490                     }
2491                 case Opcodes.NEW:
2492                 case Opcodes.ANEWARRAY:
2493                 case Opcodes.CHECKCAST:
2494                 case Opcodes.INSTANCEOF:
2495                 case Opcodes.DEFAULT:
2496                     methodVisitor.visitTypeInsn(opcode, readClass(currentOffset + 1, charBuffer));
2497                     currentOffset += 3;
2498                     break;
2499                 case Opcodes.IINC:
2500                     methodVisitor.visitIincInsn(
2501                             classBuffer[currentOffset + 1] & 0xFF, classBuffer[currentOffset + 2]);
2502                     currentOffset += 3;
2503                     break;
2504                 case Opcodes.MULTIANEWARRAY:
2505                     methodVisitor.visitMultiANewArrayInsn(
2506                             readClass(currentOffset + 1, charBuffer), classBuffer[currentOffset + 3] & 0xFF);
2507                     currentOffset += 4;
2508                     break;
2509                 default:
2510                     throw new AssertionError();
2511             }
2512 
2513             // Visit the runtime visible instruction annotations, if any.
2514             while (visibleTypeAnnotationOffsets != null
2515                     && currentVisibleTypeAnnotationIndex < visibleTypeAnnotationOffsets.length

3227                 case 'Z':
3228                 case 'C':
3229                 case 'B':
3230                 case 'S':
3231                 case 'I':
3232                     locals[numLocal++] = Opcodes.INTEGER;
3233                     break;
3234                 case 'F':
3235                     locals[numLocal++] = Opcodes.FLOAT;
3236                     break;
3237                 case 'J':
3238                     locals[numLocal++] = Opcodes.LONG;
3239                     break;
3240                 case 'D':
3241                     locals[numLocal++] = Opcodes.DOUBLE;
3242                     break;
3243                 case '[':
3244                     while (methodDescriptor.charAt(currentMethodDescritorOffset) == '[') {
3245                         ++currentMethodDescritorOffset;
3246                     }
3247                     char descType = methodDescriptor.charAt(currentMethodDescritorOffset);
3248                     if (descType == 'L' || descType == 'Q') {
3249                         ++currentMethodDescritorOffset;
3250                         while (methodDescriptor.charAt(currentMethodDescritorOffset) != ';') {
3251                             ++currentMethodDescritorOffset;
3252                         }
3253                     }
3254                     locals[numLocal++] =
3255                             methodDescriptor.substring(
3256                                     currentArgumentDescriptorStartOffset, ++currentMethodDescritorOffset);
3257                     break;
3258                 case 'L':
3259                     while (methodDescriptor.charAt(currentMethodDescritorOffset) != ';') {
3260                         ++currentMethodDescritorOffset;
3261                     }
3262                     locals[numLocal++] =
3263                             methodDescriptor.substring(
3264                                     currentArgumentDescriptorStartOffset + 1, currentMethodDescritorOffset++);
3265                     break;
3266                 default:
3267                     context.currentFrameLocalCount = numLocal;
3268                     return;
< prev index next >