< prev index next >

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

Print this page




1594                 case Constants.DLOAD:
1595                 case Constants.ALOAD:
1596                 case Constants.ISTORE:
1597                 case Constants.LSTORE:
1598                 case Constants.FSTORE:
1599                 case Constants.DSTORE:
1600                 case Constants.ASTORE:
1601                 case Constants.RET:
1602                 case Constants.BIPUSH:
1603                 case Constants.NEWARRAY:
1604                 case Constants.LDC:
1605                     currentOffset += 2;
1606                     break;
1607                 case Constants.SIPUSH:
1608                 case Constants.LDC_W:
1609                 case Constants.LDC2_W:
1610                 case Constants.GETSTATIC:
1611                 case Constants.PUTSTATIC:
1612                 case Constants.GETFIELD:
1613                 case Constants.PUTFIELD:


1614                 case Constants.INVOKEVIRTUAL:
1615                 case Constants.INVOKESPECIAL:
1616                 case Constants.INVOKESTATIC:
1617                 case Constants.NEW:
1618                 case Constants.ANEWARRAY:
1619                 case Constants.CHECKCAST:
1620                 case Constants.INSTANCEOF:
1621                 case Constants.IINC:
1622                     currentOffset += 3;
1623                     break;
1624                 case Constants.INVOKEINTERFACE:
1625                 case Constants.INVOKEDYNAMIC:
1626                     currentOffset += 5;
1627                     break;
1628                 case Constants.MULTIANEWARRAY:
1629                     currentOffset += 4;
1630                     break;
1631                 default:
1632                     throw new IllegalArgumentException();
1633             }


2209                     currentOffset += 3;
2210                     break;
2211                 case Constants.LDC:
2212                     methodVisitor.visitLdcInsn(
2213                             readConst(classFileBuffer[currentOffset + 1] & 0xFF, charBuffer));
2214                     currentOffset += 2;
2215                     break;
2216                 case Constants.LDC_W:
2217                 case Constants.LDC2_W:
2218                     methodVisitor.visitLdcInsn(readConst(readUnsignedShort(currentOffset + 1), charBuffer));
2219                     currentOffset += 3;
2220                     break;
2221                 case Constants.GETSTATIC:
2222                 case Constants.PUTSTATIC:
2223                 case Constants.GETFIELD:
2224                 case Constants.PUTFIELD:
2225                 case Constants.INVOKEVIRTUAL:
2226                 case Constants.INVOKESPECIAL:
2227                 case Constants.INVOKESTATIC:
2228                 case Constants.INVOKEINTERFACE:

2229                     {
2230                         int cpInfoOffset = cpInfoOffsets[readUnsignedShort(currentOffset + 1)];
2231                         int nameAndTypeCpInfoOffset = cpInfoOffsets[readUnsignedShort(cpInfoOffset + 2)];
2232                         String owner = readClass(cpInfoOffset, charBuffer);
2233                         String name = readUTF8(nameAndTypeCpInfoOffset, charBuffer);
2234                         String descriptor = readUTF8(nameAndTypeCpInfoOffset + 2, charBuffer);
2235                         if (opcode < Opcodes.INVOKEVIRTUAL) {
2236                             methodVisitor.visitFieldInsn(opcode, owner, name, descriptor);
2237                         } else {
2238                             boolean isInterface =
2239                                     classFileBuffer[cpInfoOffset - 1] == Symbol.CONSTANT_INTERFACE_METHODREF_TAG;
2240                             methodVisitor.visitMethodInsn(opcode, owner, name, descriptor, isInterface);


2241                         }
2242                         if (opcode == Opcodes.INVOKEINTERFACE) {
2243                             currentOffset += 5;
2244                         } else {
2245                             currentOffset += 3;
2246                         }
2247                         break;
2248                     }
2249                 case Constants.INVOKEDYNAMIC:
2250                     {
2251                         int cpInfoOffset = cpInfoOffsets[readUnsignedShort(currentOffset + 1)];
2252                         int nameAndTypeCpInfoOffset = cpInfoOffsets[readUnsignedShort(cpInfoOffset + 2)];
2253                         String name = readUTF8(nameAndTypeCpInfoOffset, charBuffer);
2254                         String descriptor = readUTF8(nameAndTypeCpInfoOffset + 2, charBuffer);
2255                         int bootstrapMethodOffset = bootstrapMethodOffsets[readUnsignedShort(cpInfoOffset)];
2256                         Handle handle =
2257                                 (Handle) readConst(readUnsignedShort(bootstrapMethodOffset), charBuffer);
2258                         Object[] bootstrapMethodArguments =
2259                                 new Object[readUnsignedShort(bootstrapMethodOffset + 2)];
2260                         bootstrapMethodOffset += 4;
2261                         for (int i = 0; i < bootstrapMethodArguments.length; i++) {
2262                             bootstrapMethodArguments[i] =
2263                                     readConst(readUnsignedShort(bootstrapMethodOffset), charBuffer);
2264                             bootstrapMethodOffset += 2;
2265                         }
2266                         methodVisitor.visitInvokeDynamicInsn(
2267                                 name, descriptor, handle, bootstrapMethodArguments);
2268                         currentOffset += 5;
2269                         break;
2270                     }
2271                 case Constants.NEW:
2272                 case Constants.ANEWARRAY:
2273                 case Constants.CHECKCAST:
2274                 case Constants.INSTANCEOF:

2275                     methodVisitor.visitTypeInsn(opcode, readClass(currentOffset + 1, charBuffer));
2276                     currentOffset += 3;
2277                     break;
2278                 case Constants.IINC:
2279                     methodVisitor.visitIincInsn(
2280                             classFileBuffer[currentOffset + 1] & 0xFF, classFileBuffer[currentOffset + 2]);
2281                     currentOffset += 3;
2282                     break;
2283                 case Constants.MULTIANEWARRAY:
2284                     methodVisitor.visitMultiANewArrayInsn(
2285                             readClass(currentOffset + 1, charBuffer), classFileBuffer[currentOffset + 3] & 0xFF);
2286                     currentOffset += 4;
2287                     break;
2288                 default:
2289                     throw new AssertionError();
2290             }
2291 
2292             // Visit the runtime visible instruction annotations, if any.
2293             while (visibleTypeAnnotationOffsets != null
2294                     && currentVisibleTypeAnnotationIndex < visibleTypeAnnotationOffsets.length


3006                 case 'Z':
3007                 case 'C':
3008                 case 'B':
3009                 case 'S':
3010                 case 'I':
3011                     locals[numLocal++] = Opcodes.INTEGER;
3012                     break;
3013                 case 'F':
3014                     locals[numLocal++] = Opcodes.FLOAT;
3015                     break;
3016                 case 'J':
3017                     locals[numLocal++] = Opcodes.LONG;
3018                     break;
3019                 case 'D':
3020                     locals[numLocal++] = Opcodes.DOUBLE;
3021                     break;
3022                 case '[':
3023                     while (methodDescriptor.charAt(currentMethodDescritorOffset) == '[') {
3024                         ++currentMethodDescritorOffset;
3025                     }
3026                     if (methodDescriptor.charAt(currentMethodDescritorOffset) == 'L') {

3027                         ++currentMethodDescritorOffset;
3028                         while (methodDescriptor.charAt(currentMethodDescritorOffset) != ';') {
3029                             ++currentMethodDescritorOffset;
3030                         }
3031                     }
3032                     locals[numLocal++] =
3033                             methodDescriptor.substring(
3034                                     currentArgumentDescriptorStartOffset, ++currentMethodDescritorOffset);
3035                     break;
3036                 case 'L':
3037                     while (methodDescriptor.charAt(currentMethodDescritorOffset) != ';') {
3038                         ++currentMethodDescritorOffset;
3039                     }
3040                     locals[numLocal++] =
3041                             methodDescriptor.substring(
3042                                     currentArgumentDescriptorStartOffset + 1, currentMethodDescritorOffset++);
3043                     break;
3044                 default:
3045                     context.currentFrameLocalCount = numLocal;
3046                     return;




1594                 case Constants.DLOAD:
1595                 case Constants.ALOAD:
1596                 case Constants.ISTORE:
1597                 case Constants.LSTORE:
1598                 case Constants.FSTORE:
1599                 case Constants.DSTORE:
1600                 case Constants.ASTORE:
1601                 case Constants.RET:
1602                 case Constants.BIPUSH:
1603                 case Constants.NEWARRAY:
1604                 case Constants.LDC:
1605                     currentOffset += 2;
1606                     break;
1607                 case Constants.SIPUSH:
1608                 case Constants.LDC_W:
1609                 case Constants.LDC2_W:
1610                 case Constants.GETSTATIC:
1611                 case Constants.PUTSTATIC:
1612                 case Constants.GETFIELD:
1613                 case Constants.PUTFIELD:
1614                 case Constants.DEFAULT:
1615                 case Constants.WITHFIELD:
1616                 case Constants.INVOKEVIRTUAL:
1617                 case Constants.INVOKESPECIAL:
1618                 case Constants.INVOKESTATIC:
1619                 case Constants.NEW:
1620                 case Constants.ANEWARRAY:
1621                 case Constants.CHECKCAST:
1622                 case Constants.INSTANCEOF:
1623                 case Constants.IINC:
1624                     currentOffset += 3;
1625                     break;
1626                 case Constants.INVOKEINTERFACE:
1627                 case Constants.INVOKEDYNAMIC:
1628                     currentOffset += 5;
1629                     break;
1630                 case Constants.MULTIANEWARRAY:
1631                     currentOffset += 4;
1632                     break;
1633                 default:
1634                     throw new IllegalArgumentException();
1635             }


2211                     currentOffset += 3;
2212                     break;
2213                 case Constants.LDC:
2214                     methodVisitor.visitLdcInsn(
2215                             readConst(classFileBuffer[currentOffset + 1] & 0xFF, charBuffer));
2216                     currentOffset += 2;
2217                     break;
2218                 case Constants.LDC_W:
2219                 case Constants.LDC2_W:
2220                     methodVisitor.visitLdcInsn(readConst(readUnsignedShort(currentOffset + 1), charBuffer));
2221                     currentOffset += 3;
2222                     break;
2223                 case Constants.GETSTATIC:
2224                 case Constants.PUTSTATIC:
2225                 case Constants.GETFIELD:
2226                 case Constants.PUTFIELD:
2227                 case Constants.INVOKEVIRTUAL:
2228                 case Constants.INVOKESPECIAL:
2229                 case Constants.INVOKESTATIC:
2230                 case Constants.INVOKEINTERFACE:
2231                 case Constants.WITHFIELD:
2232                     {
2233                         int cpInfoOffset = cpInfoOffsets[readUnsignedShort(currentOffset + 1)];
2234                         int nameAndTypeCpInfoOffset = cpInfoOffsets[readUnsignedShort(cpInfoOffset + 2)];
2235                         String owner = readClass(cpInfoOffset, charBuffer);
2236                         String name = readUTF8(nameAndTypeCpInfoOffset, charBuffer);
2237                         String descriptor = readUTF8(nameAndTypeCpInfoOffset + 2, charBuffer);
2238                         if (opcode >= Opcodes.INVOKEVIRTUAL && opcode <= Opcodes.INVOKEINTERFACE) {


2239                             boolean isInterface =
2240                                     classFileBuffer[cpInfoOffset - 1] == Symbol.CONSTANT_INTERFACE_METHODREF_TAG;
2241                             methodVisitor.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
2242                         } else {
2243                             methodVisitor.visitFieldInsn(opcode, owner, name, descriptor);
2244                         }
2245                         if (opcode == Opcodes.INVOKEINTERFACE) {
2246                             currentOffset += 5;
2247                         } else {
2248                             currentOffset += 3;
2249                         }
2250                         break;
2251                     }
2252                 case Constants.INVOKEDYNAMIC:
2253                     {
2254                         int cpInfoOffset = cpInfoOffsets[readUnsignedShort(currentOffset + 1)];
2255                         int nameAndTypeCpInfoOffset = cpInfoOffsets[readUnsignedShort(cpInfoOffset + 2)];
2256                         String name = readUTF8(nameAndTypeCpInfoOffset, charBuffer);
2257                         String descriptor = readUTF8(nameAndTypeCpInfoOffset + 2, charBuffer);
2258                         int bootstrapMethodOffset = bootstrapMethodOffsets[readUnsignedShort(cpInfoOffset)];
2259                         Handle handle =
2260                                 (Handle) readConst(readUnsignedShort(bootstrapMethodOffset), charBuffer);
2261                         Object[] bootstrapMethodArguments =
2262                                 new Object[readUnsignedShort(bootstrapMethodOffset + 2)];
2263                         bootstrapMethodOffset += 4;
2264                         for (int i = 0; i < bootstrapMethodArguments.length; i++) {
2265                             bootstrapMethodArguments[i] =
2266                                     readConst(readUnsignedShort(bootstrapMethodOffset), charBuffer);
2267                             bootstrapMethodOffset += 2;
2268                         }
2269                         methodVisitor.visitInvokeDynamicInsn(
2270                                 name, descriptor, handle, bootstrapMethodArguments);
2271                         currentOffset += 5;
2272                         break;
2273                     }
2274                 case Constants.NEW:
2275                 case Constants.ANEWARRAY:
2276                 case Constants.CHECKCAST:
2277                 case Constants.INSTANCEOF:
2278                 case Constants.DEFAULT:
2279                     methodVisitor.visitTypeInsn(opcode, readClass(currentOffset + 1, charBuffer));
2280                     currentOffset += 3;
2281                     break;
2282                 case Constants.IINC:
2283                     methodVisitor.visitIincInsn(
2284                             classFileBuffer[currentOffset + 1] & 0xFF, classFileBuffer[currentOffset + 2]);
2285                     currentOffset += 3;
2286                     break;
2287                 case Constants.MULTIANEWARRAY:
2288                     methodVisitor.visitMultiANewArrayInsn(
2289                             readClass(currentOffset + 1, charBuffer), classFileBuffer[currentOffset + 3] & 0xFF);
2290                     currentOffset += 4;
2291                     break;
2292                 default:
2293                     throw new AssertionError();
2294             }
2295 
2296             // Visit the runtime visible instruction annotations, if any.
2297             while (visibleTypeAnnotationOffsets != null
2298                     && currentVisibleTypeAnnotationIndex < visibleTypeAnnotationOffsets.length


3010                 case 'Z':
3011                 case 'C':
3012                 case 'B':
3013                 case 'S':
3014                 case 'I':
3015                     locals[numLocal++] = Opcodes.INTEGER;
3016                     break;
3017                 case 'F':
3018                     locals[numLocal++] = Opcodes.FLOAT;
3019                     break;
3020                 case 'J':
3021                     locals[numLocal++] = Opcodes.LONG;
3022                     break;
3023                 case 'D':
3024                     locals[numLocal++] = Opcodes.DOUBLE;
3025                     break;
3026                 case '[':
3027                     while (methodDescriptor.charAt(currentMethodDescritorOffset) == '[') {
3028                         ++currentMethodDescritorOffset;
3029                     }
3030                     char descType = methodDescriptor.charAt(currentMethodDescritorOffset);
3031                     if (descType == 'L' || descType == 'Q') {
3032                         ++currentMethodDescritorOffset;
3033                         while (methodDescriptor.charAt(currentMethodDescritorOffset) != ';') {
3034                             ++currentMethodDescritorOffset;
3035                         }
3036                     }
3037                     locals[numLocal++] =
3038                             methodDescriptor.substring(
3039                                     currentArgumentDescriptorStartOffset, ++currentMethodDescritorOffset);
3040                     break;
3041                 case 'L':
3042                     while (methodDescriptor.charAt(currentMethodDescritorOffset) != ';') {
3043                         ++currentMethodDescritorOffset;
3044                     }
3045                     locals[numLocal++] =
3046                             methodDescriptor.substring(
3047                                     currentArgumentDescriptorStartOffset + 1, currentMethodDescritorOffset++);
3048                     break;
3049                 default:
3050                     context.currentFrameLocalCount = numLocal;
3051                     return;


< prev index next >