/** * Returns a method constant that uses an {@link AccessController} to look up this constant. * * @return A method constant that uses an {@link AccessController} to look up this constant. */ protected CanCache privileged() { return new PrivilegedLookup(methodDescription, methodName()); }
/** * Returns a cached version of this field constant. * * @return A cached version of this field constant. */ public StackManipulation cached() { return new Cached(this); }
/** * {@inheritDoc} */ public StackManipulation cached() { return new CachedMethod(this); } }
/** * {@inheritDoc} */ public StackManipulation resolve(TypeDescription instrumentedType) { return IntegerConstant.forValue(value); } }
/** * Creates a stack manipulation that loads a method constant onto the operand stack using an {@link AccessController}. * * @param methodDescription The method to be loaded onto the stack. * @return A stack manipulation that assigns a method constant for the given method description. */ public static CanCache ofPrivileged(MethodDescription.InDefinedShape methodDescription) { if (methodDescription.isTypeInitializer()) { return CanCacheIllegal.INSTANCE; } else if (methodDescription.isConstructor()) { return new ForConstructor(methodDescription).privileged(); } else { return new ForMethod(methodDescription).privileged(); } }
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(new TextConstant(value), TypeDescription.STRING); }
/** * Loads a method constant onto the operand stack. * * @param origin The origin annotation. * @param methodDescription The method description to load. * @return An appropriate stack manipulation. */ private static StackManipulation methodConstant(Origin origin, MethodDescription.InDefinedShape methodDescription) { MethodConstant.CanCache methodConstant = origin.privileged() ? MethodConstant.ofPrivileged(methodDescription) : MethodConstant.of(methodDescription); return origin.cache() ? methodConstant.cached() : methodConstant; }
/** * {@inheritDoc} */ public StackManipulation cached() { return methodDescription.isConstructor() ? new CachedConstructor(this) : new CachedMethod(this); }
/** * Creates a stack manipulation that loads a method constant onto the operand stack. * * @param methodDescription The method to be loaded onto the stack. * @return A stack manipulation that assigns a method constant for the given method description. */ public static CanCache of(MethodDescription.InDefinedShape methodDescription) { if (methodDescription.isTypeInitializer()) { return CanCacheIllegal.INSTANCE; } else if (methodDescription.isConstructor()) { return new ForConstructor(methodDescription); } else { return new ForMethod(methodDescription); } }
@Override protected ArgumentProvider make(Object value) { return new WrappingArgumentProvider(LongConstant.forValue((Long) value)); } },
/** * Creates a target for an offset mapping for a type constant. * * @param typeDescription The type constant to represent. * @return A mapping for a type constant. */ public static Target of(TypeDescription typeDescription) { return new ForStackManipulation(ClassConstant.of(typeDescription)); }
/** * {@inheritDoc} */ public StackManipulation cached() { return new CachedConstructor(this); } }
/** * Creates a stack manipulation for loading a {@code long} value onto the operand stack. * <p> </p> * This is achieved either by invoking a specific opcode, if any, or by creating a constant pool entry. * * @param value The {@code long} value to load onto the stack. * @return A stack manipulation for loading the given {@code long} value. */ public static StackManipulation forValue(long value) { if (value == 0L) { return ZERO; } else if (value == 1L) { return ONE; } else { return new ConstantPool(value); } }
/** * Creates a stack manipulation for loading a {@code double} value onto the operand stack. * <p> </p> * This is achieved either by invoking a specific opcode, if any, or by creating a constant pool entry. * * @param value The {@code double} value to load onto the stack. * @return A stack manipulation for loading the given {@code double} value. */ public static StackManipulation forValue(double value) { if (value == 0d) { return ZERO; } else if (value == 1d) { return ONE; } else { return new ConstantPool(value); } }
/** * {@inheritDoc} */ public StackManipulation resolveRead() { return new StackManipulation.Compound(DefaultValue.of(typeDefinition), readAssignment); }
@Override protected ArgumentProvider make(Object value) { return new WrappingArgumentProvider(FloatConstant.forValue((Float) value)); } },
/** * Creates a target for a {@link Method} or {@link Constructor} constant. * * @param methodDescription The method or constructor to represent. * @return A mapping for a method or constructor constant. */ public static Target of(MethodDescription.InDefinedShape methodDescription) { return new ForStackManipulation(MethodConstant.of(methodDescription)); }
@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((Character) value)); } },