/** * Adds an invokedynamic reference to the constant pool of the class being build. Does nothing if * the constant pool already contains a similar item. <i>This method is intended for {@link * Attribute} sub classes, and is normally not needed by class generators or adapters.</i> * * @param name name of the invoked method. * @param descriptor descriptor of the invoke method. * @param bootstrapMethodHandle the bootstrap method. * @param bootstrapMethodArguments the bootstrap method constant arguments. * @return the index of a new or already existing invokedynamic reference item. */ public int newInvokeDynamic( final String name, final String descriptor, final Handle bootstrapMethodHandle, final Object... bootstrapMethodArguments) { return symbolTable.addConstantInvokeDynamic( name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments) .index; }
@Override public void visitInvokeDynamicInsn( final String name, final String descriptor, final Handle bootstrapMethodHandle, final Object... bootstrapMethodArguments) { lastBytecodeOffset = code.length; // Add the instruction to the bytecode of the method. Symbol invokeDynamicSymbol = symbolTable.addConstantInvokeDynamic( name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments); code.put12(Opcodes.INVOKEDYNAMIC, invokeDynamicSymbol.index); code.putShort(0); // If needed, update the maximum stack size and number of locals, and stack map frames. if (currentBasicBlock != null) { if (compute == COMPUTE_ALL_FRAMES || compute == COMPUTE_INSERTED_FRAMES) { currentBasicBlock.frame.execute(Opcodes.INVOKEDYNAMIC, 0, invokeDynamicSymbol, symbolTable); } else { int argumentsAndReturnSize = invokeDynamicSymbol.getArgumentsAndReturnSizes(); int stackSizeDelta = (argumentsAndReturnSize & 3) - (argumentsAndReturnSize >> 2) + 1; int size = relativeStackSize + stackSizeDelta; if (size > maxRelativeStackSize) { maxRelativeStackSize = size; } relativeStackSize = size; } } }
/** * Adds an invokedynamic reference to the constant pool of the class being build. Does nothing if * the constant pool already contains a similar item. <i>This method is intended for {@link * Attribute} sub classes, and is normally not needed by class generators or adapters.</i> * * @param name name of the invoked method. * @param descriptor descriptor of the invoke method. * @param bootstrapMethodHandle the bootstrap method. * @param bootstrapMethodArguments the bootstrap method constant arguments. * @return the index of a new or already existing invokedynamic reference item. */ public int newInvokeDynamic( final String name, final String descriptor, final Handle bootstrapMethodHandle, final Object... bootstrapMethodArguments) { return symbolTable.addConstantInvokeDynamic( name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments) .index; }
@Override public void visitInvokeDynamicInsn( final String name, final String descriptor, final Handle bootstrapMethodHandle, final Object... bootstrapMethodArguments) { lastBytecodeOffset = code.length; // Add the instruction to the bytecode of the method. Symbol invokeDynamicSymbol = symbolTable.addConstantInvokeDynamic( name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments); code.put12(Opcodes.INVOKEDYNAMIC, invokeDynamicSymbol.index); code.putShort(0); // If needed, update the maximum stack size and number of locals, and stack map frames. if (currentBasicBlock != null) { if (compute == COMPUTE_ALL_FRAMES || compute == COMPUTE_INSERTED_FRAMES) { currentBasicBlock.frame.execute(Opcodes.INVOKEDYNAMIC, 0, invokeDynamicSymbol, symbolTable); } else { int argumentsAndReturnSize = invokeDynamicSymbol.getArgumentsAndReturnSizes(); int stackSizeDelta = (argumentsAndReturnSize & 3) - (argumentsAndReturnSize >> 2) + 1; int size = relativeStackSize + stackSizeDelta; if (size > maxRelativeStackSize) { maxRelativeStackSize = size; } relativeStackSize = size; } } }