/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(new TextConstant(value), TypeDescription.STRING); }
@Override protected StackManipulation methodName() { return new TextConstant(methodDescription.getInternalName()); }
/** * {@inheritDoc} */ public StackManipulation make() { return new StackManipulation.Compound( TypeCreation.of(throwableType), Duplication.SINGLE, new TextConstant(message), MethodInvocation.invoke(targetConstructor)); } }
Duplication.SINGLE, ClassConstant.of(targetType), new TextConstant(lambdaType.getInternalName()), new TextConstant(lambdaMethodName), new TextConstant(lambdaMethod.getDescriptor()), IntegerConstant.forValue(targetMethod.getHandleType().getIdentifier()), new TextConstant(targetMethod.getOwnerType().getInternalName()), new TextConstant(targetMethod.getName()), new TextConstant(targetMethod.getDescriptor()), new TextConstant(specializedMethod.getDescriptor()), ArrayFactory.forType(TypeDescription.Generic.OBJECT).withValues(lambdaArguments), MethodInvocation.invoke(serializedLambda.getDeclaredMethods().filter(isConstructor()).getOnly()),
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { try { return new Compound( ClassConstant.of(fieldDescription.getDeclaringType()), new TextConstant(fieldDescription.getInternalName()), MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(Class.class.getMethod("getDeclaredField", String.class))) ).apply(methodVisitor, implementationContext); } catch (NoSuchMethodException exception) { throw new IllegalStateException("Cannot locate Class::getDeclaredField", exception); } }
stackManipulations.add(TypeCreation.of(TypeDescription.ForLoadedType.of(StringBuilder.class))); stackManipulations.add(Duplication.SINGLE); stackManipulations.add(new TextConstant(prefix)); stackManipulations.add(MethodInvocation.invoke(STRING_BUILDER_CONSTRUCTOR)); stackManipulations.add(new TextConstant(start)); stackManipulations.add(ValueConsumer.STRING); boolean first = true; first = false; } else { stackManipulations.add(new TextConstant(separator)); stackManipulations.add(ValueConsumer.STRING); stackManipulations.add(new TextConstant(fieldDescription.getName() + definer)); stackManipulations.add(ValueConsumer.STRING); stackManipulations.add(MethodVariableAccess.loadThis()); stackManipulations.add(ValueConsumer.of(fieldDescription.getType().asErasure())); stackManipulations.add(new TextConstant(end)); stackManipulations.add(ValueConsumer.STRING); stackManipulations.add(MethodInvocation.invoke(TO_STRING));
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { try { return new StackManipulation.Compound( TypeCreation.of(TypeDescription.ForLoadedType.of(ObjectInputStream.class)), Duplication.SINGLE, TypeCreation.of(TypeDescription.ForLoadedType.of(ByteArrayInputStream.class)), Duplication.SINGLE, new TextConstant(serialization), new TextConstant(CHARSET), MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(String.class.getMethod("getBytes", String.class))), MethodInvocation.invoke(new MethodDescription.ForLoadedConstructor(ByteArrayInputStream.class.getConstructor(byte[].class))), MethodInvocation.invoke(new MethodDescription.ForLoadedConstructor(ObjectInputStream.class.getConstructor(InputStream.class))), MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(ObjectInputStream.class.getMethod("readObject"))) ).apply(methodVisitor, implementationContext); } catch (NoSuchMethodException exception) { throw new IllegalStateException("Could not locate Java API method", exception); } } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) { try { return new ByteCodeAppender.Simple(new StackManipulation.Compound( MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(ClassLoader.class.getMethod("getSystemClassLoader"))), new TextConstant(Nexus.class.getName()), MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(ClassLoader.class.getMethod("loadClass", String.class))), new TextConstant("initialize"), ArrayFactory.forType(TypeDescription.Generic.CLASS) .withValues(Arrays.asList( ClassConstant.of(TypeDescription.CLASS), ClassConstant.of(TypeDescription.ForLoadedType.of(int.class)))), MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(Class.class.getMethod("getMethod", String.class, Class[].class))), NullConstant.INSTANCE, ArrayFactory.forType(TypeDescription.Generic.OBJECT) .withValues(Arrays.asList( ClassConstant.of(instrumentedMethod.getDeclaringType().asErasure()), new StackManipulation.Compound( IntegerConstant.forValue(identification), MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(Integer.class.getMethod("valueOf", int.class)))))), MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(Method.class.getMethod("invoke", Object.class, Object[].class))), Removal.SINGLE )).apply(methodVisitor, implementationContext, instrumentedMethod); } catch (NoSuchMethodException exception) { throw new IllegalStateException("Cannot locate method", exception); } } }
return new ForStackManipulation(DoubleConstant.forValue((Double) value)); } else if (value instanceof String) { return new ForStackManipulation(new TextConstant((String) value)); } else { throw new IllegalArgumentException("Not a constant value: " + value);
TypeCreation.of(instrumentedType), Duplication.SINGLE, new TextConstant(value), IntegerConstant.forValue(ordinal++), MethodInvocation.invoke(enumConstructor),
return new MethodDelegationBinder.ParameterBinding.Anonymous(methodConstant(annotation.loadSilent(), source.asDefined())); } else if (parameterType.represents(String.class)) { return new MethodDelegationBinder.ParameterBinding.Anonymous(new TextConstant(source.toString())); } else if (parameterType.represents(int.class)) { return new MethodDelegationBinder.ParameterBinding.Anonymous(IntegerConstant.forValue(source.getModifiers()));
typeDescription = TypeDescription.ForLoadedType.of(double.class); } else if (value instanceof String) { stackManipulation = new TextConstant((String) value); typeDescription = TypeDescription.STRING; } else {
Class<?> type = fixedValue.getClass(); if (type == String.class) { return new ForPoolValue(new TextConstant((String) fixedValue), TypeDescription.STRING); } else if (type == Class.class) { return new ForPoolValue(ClassConstant.of(TypeDescription.ForLoadedType.of((Class<?>) fixedValue)), TypeDescription.CLASS);
Class<?> type = value.getClass(); if (type == String.class) { return setsValue(new TextConstant((String) value), String.class); } else if (type == Class.class) { return setsValue(ClassConstant.of(TypeDescription.ForLoadedType.of((Class<?>) value)), Class.class);
return ForNullConstant.INSTANCE; } else if (value instanceof String) { return new ForStackManipulation(new TextConstant((String) value), String.class); } else if (value instanceof Boolean) { return new ForStackManipulation(IntegerConstant.forValue((Boolean) value), boolean.class);
suppliedType = TypeDescription.ForLoadedType.of(double.class); } else if (value instanceof String) { stackManipulation = new TextConstant((String) value); suppliedType = TypeDescription.STRING; } else if (value instanceof Class) {
/** * Ctor. * @param string String */ public SmtString(String string) { super( new TextConstant(string) ); } }
enum SignatureBinder implements TargetMethodAnnotationDrivenBinder.ParameterBinder<StringValue> { INSTANCE; // singleton @Override public Class<Signature> getHandledType() { return Signature.class; } @Override public MethodDelegationBinder.ParameterBinding<?> bind(AnnotationDescription.Loaded<StringValue> annotation, MethodDescription source, ParameterDescription target, Instrumentation.Target instrumentationTarget, Assigner assigner) { if (!target.getTypeDescription().represents(String.class)) { throw new IllegalStateException(target + " makes illegal use of @Signature"); } StackManipulation constant = new TextConstant("<signature goes here>"); return new MethodDelegationBinder.ParameterBinding.Anonymous(constant); } }
@Override public final StackManipulation stackManipulation() { return new StackManipulation.Compound( new TextConstant(typeDescription.getName()) ); } }
@Override public final StackManipulation stackManipulation() { return new TextConstant(field.getName()); } }