/** * {@inheritDoc} */ public StackManipulation resolve(TypeDescription instrumentedType) { return IntegerConstant.forValue(value); } }
@Override protected ArgumentProvider make(Object value) { return new WrappingArgumentProvider(IntegerConstant.forValue((Boolean) value)); } },
@Override protected ArgumentProvider make(Object value) { return new WrappingArgumentProvider(IntegerConstant.forValue((Integer) value)); } },
@Override protected ArgumentProvider make(Object value) { return new WrappingArgumentProvider(IntegerConstant.forValue((Short) value)); } },
@Override protected ArgumentProvider make(Object value) { return new WrappingArgumentProvider(IntegerConstant.forValue((Character) value)); } },
@Override protected ArgumentProvider make(Object value) { return new WrappingArgumentProvider(IntegerConstant.forValue((Byte) value)); } },
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(IntegerConstant.forValue(value), TypeDescription.ForLoadedType.of(int.class)); }
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(IntegerConstant.forValue(value), TypeDescription.ForLoadedType.of(boolean.class)); }
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(IntegerConstant.forValue(value), TypeDescription.ForLoadedType.of(byte.class)); }
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(IntegerConstant.forValue(value), TypeDescription.ForLoadedType.of(short.class)); }
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(IntegerConstant.forValue(value), TypeDescription.ForLoadedType.of(char.class)); }
/** * Applies a stack manipulation to the values of an array. The array must have at least as many values as the list has elements. * * @param processInstructions The elements to apply. * @return A stack manipulation that applies the supplied instructions. */ public StackManipulation forEach(List<? extends StackManipulation> processInstructions) { List<StackManipulation> stackManipulations = new ArrayList<StackManipulation>(processInstructions.size()); int index = 0; for (StackManipulation processInstruction : processInstructions) { stackManipulations.add(new StackManipulation.Compound( Duplication.SINGLE, IntegerConstant.forValue(index++), new Loader(), processInstruction )); } return new StackManipulation.Compound(stackManipulations); }
/** * {@inheritDoc} */ public StackManipulation resolveIncrement(int value) { return new StackManipulation.Compound( resolveRead(), IntegerConstant.forValue(value), Addition.INTEGER, resolveWrite() ); } }
return new ForStackManipulation(NullConstant.INSTANCE); } else if (value instanceof Boolean) { return new ForStackManipulation(IntegerConstant.forValue((Boolean) value)); } else if (value instanceof Byte) { return new ForStackManipulation(IntegerConstant.forValue((Byte) value)); } else if (value instanceof Short) { return new ForStackManipulation(IntegerConstant.forValue((Short) value)); } else if (value instanceof Character) { return new ForStackManipulation(IntegerConstant.forValue((Character) value)); } else if (value instanceof Integer) { return new ForStackManipulation(IntegerConstant.forValue((Integer) value)); } else if (value instanceof Long) { return new ForStackManipulation(LongConstant.forValue((Long) value));
return new OfDefaultValue<S>(annotationType); } else if (value instanceof Boolean) { stackManipulation = IntegerConstant.forValue((Boolean) value); typeDescription = TypeDescription.ForLoadedType.of(boolean.class); } else if (value instanceof Byte) { stackManipulation = IntegerConstant.forValue((Byte) value); typeDescription = TypeDescription.ForLoadedType.of(byte.class); } else if (value instanceof Short) { stackManipulation = IntegerConstant.forValue((Short) value); typeDescription = TypeDescription.ForLoadedType.of(short.class); } else if (value instanceof Character) { stackManipulation = IntegerConstant.forValue((Character) value); typeDescription = TypeDescription.ForLoadedType.of(char.class); } else if (value instanceof Integer) { stackManipulation = IntegerConstant.forValue((Integer) value); typeDescription = TypeDescription.ForLoadedType.of(int.class); } else if (value instanceof Long) {
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Context implementationContext, MethodDescription instrumentedMethod) { if (instrumentedMethod.isStatic()) { throw new IllegalStateException("Hash code method must not be static: " + instrumentedMethod); } else if (!instrumentedMethod.getReturnType().represents(int.class)) { throw new IllegalStateException("Hash code method does not return primitive integer: " + instrumentedMethod); } List<StackManipulation> stackManipulations = new ArrayList<StackManipulation>(2 + fieldDescriptions.size() * 8); stackManipulations.add(initialValue); int padding = 0; for (FieldDescription.InDefinedShape fieldDescription : fieldDescriptions) { stackManipulations.add(IntegerConstant.forValue(multiplier)); stackManipulations.add(Multiplication.INTEGER); stackManipulations.add(MethodVariableAccess.loadThis()); stackManipulations.add(FieldAccess.forField(fieldDescription).read()); NullValueGuard nullValueGuard = fieldDescription.getType().isPrimitive() || fieldDescription.getType().isArray() || nonNullable.matches(fieldDescription) ? NullValueGuard.NoOp.INSTANCE : new NullValueGuard.UsingJump(instrumentedMethod); stackManipulations.add(nullValueGuard.before()); stackManipulations.add(ValueTransformer.of(fieldDescription.getType())); stackManipulations.add(Addition.INTEGER); stackManipulations.add(nullValueGuard.after()); padding = Math.max(padding, nullValueGuard.getRequiredVariablePadding()); } stackManipulations.add(MethodReturn.INTEGER); return new Size(new StackManipulation.Compound(stackManipulations).apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize() + padding); } }
/** * {@inheritDoc} */ public StackManipulation resolveIncrement(int value) { return typeDefinition.represents(int.class) ? MethodVariableAccess.of(typeDefinition).increment(offset, value) : new StackManipulation.Compound(resolveRead(), IntegerConstant.forValue(1), Addition.INTEGER, resolveWrite()); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { Size size = IntegerConstant.forValue(stackManipulations.size()).apply(methodVisitor, implementationContext); // The array's construction does not alter the stack's size. size = size.aggregate(arrayCreator.apply(methodVisitor, implementationContext)); int index = 0; for (StackManipulation stackManipulation : stackManipulations) { methodVisitor.visitInsn(Opcodes.DUP); size = size.aggregate(StackSize.SINGLE.toIncreasingSize()); size = size.aggregate(IntegerConstant.forValue(index++).apply(methodVisitor, implementationContext)); size = size.aggregate(stackManipulation.apply(methodVisitor, implementationContext)); methodVisitor.visitInsn(arrayCreator.getStorageOpcode()); size = size.aggregate(sizeDecrease); } return size; } }
padding = Math.max(padding, nullValueGuard.getRequiredVariablePadding()); stackManipulations.add(IntegerConstant.forValue(true)); stackManipulations.add(MethodReturn.INTEGER); return new Size(new StackManipulation.Compound(stackManipulations).apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize() + padding);
return setsValue(ClassConstant.of(TypeDescription.ForLoadedType.of((Class<?>) value)), Class.class); } else if (type == Boolean.class) { return setsValue(IntegerConstant.forValue((Boolean) value), boolean.class); } else if (type == Byte.class) { return setsValue(IntegerConstant.forValue((Byte) value), byte.class); } else if (type == Short.class) { return setsValue(IntegerConstant.forValue((Short) value), short.class); } else if (type == Character.class) { return setsValue(IntegerConstant.forValue((Character) value), char.class); } else if (type == Integer.class) { return setsValue(IntegerConstant.forValue((Integer) value), int.class); } else if (type == Long.class) { return setsValue(LongConstant.forValue((Long) value), long.class);