/** * {@inheritDoc} */ public MethodInvoker make(TypeDescription instrumentedType) { if (!typeDescription.asErasure().isAccessibleTo(instrumentedType)) { throw new IllegalStateException(typeDescription + " is not accessible to " + instrumentedType); } return new ForVirtualInvocation(typeDescription); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, wrapperType.asErasure().getInternalName(), unboxingMethodName, unboxingMethodDescriptor, false); return size; }
/** * {@inheritDoc} */ public AnnotationValue<?, ?> getValue(MethodDescription.InDefinedShape property) { if (!property.getDeclaringType().asErasure().equals(annotationType)) { throw new IllegalArgumentException(property + " is not declared by " + getAnnotationType()); } AnnotationValue<?, ?> annotationValue = values.get(property.getName()); if (annotationValue == null) { annotationValue = getAnnotationType().getDeclaredMethods().filter(is(property)).getOnly().getDefaultValue(); } if (annotationValue != null) { return annotationValue; } throw new IllegalStateException(property + " is not defined on annotation"); }
/** * Returns a method handle for a getter of the given field. * * @param fieldDescription The field to represent. * @return A method handle for a getter of the given field. */ public static MethodHandle ofSetter(FieldDescription.InDefinedShape fieldDescription) { return new MethodHandle(HandleType.ofSetter(fieldDescription), fieldDescription.getDeclaringType().asErasure(), fieldDescription.getInternalName(), TypeDescription.VOID, Collections.singletonList(fieldDescription.getType().asErasure())); }
/** * Returns a method handle for a setter of the given field. * * @param fieldDescription The field to represent. * @return A method handle for a setter of the given field. */ public static MethodHandle ofGetter(FieldDescription.InDefinedShape fieldDescription) { return new MethodHandle(HandleType.ofGetter(fieldDescription), fieldDescription.getDeclaringType().asErasure(), fieldDescription.getInternalName(), fieldDescription.getType().asErasure(), Collections.<TypeDescription>emptyList()); }
@Override protected void fieldRead(MethodVisitor methodVisitor) { methodVisitor.visitFieldInsn( Opcodes.GETFIELD, persistentFieldAsDefined.getDeclaringType().asErasure().getInternalName(), persistentFieldAsDefined.getInternalName(), persistentFieldAsDefined.getDescriptor() ); }
@Override protected void fieldWrite(MethodVisitor methodVisitor) { methodVisitor.visitFieldInsn( Opcodes.PUTFIELD, persistentFieldAsDefined.getDeclaringType().asErasure().getInternalName(), persistentFieldAsDefined.getInternalName(), persistentFieldAsDefined.getDescriptor() ); } }
@Override protected void fieldWrite(MethodVisitor methodVisitor) { methodVisitor.visitFieldInsn( Opcodes.PUTFIELD, persistentFieldAsDefined.getDeclaringType().asErasure().getInternalName(), persistentFieldAsDefined.getInternalName(), persistentFieldAsDefined.getDescriptor() ); } }
@Override protected void fieldRead(MethodVisitor methodVisitor) { methodVisitor.visitFieldInsn( Opcodes.GETFIELD, persistentFieldAsDefined.getDeclaringType().asErasure().getInternalName(), persistentFieldAsDefined.getInternalName(), persistentFieldAsDefined.getDescriptor() ); }
/** * Creates a method handle representation of the given method. * * @param methodDescription The method ro represent. * @return A method handle representing the given method. */ public static MethodHandle of(MethodDescription.InDefinedShape methodDescription) { return new MethodHandle(HandleType.of(methodDescription), methodDescription.getDeclaringType().asErasure(), methodDescription.getInternalName(), methodDescription.getReturnType().asErasure(), methodDescription.getParameters().asTypeList().asErasures()); }
if ( persistentField.getDeclaringType().asErasure().equals( managedCtClass ) ) { methodVisitor.visitFieldInsn( Opcodes.GETFIELD, persistentField.getDeclaringType().asErasure().getInternalName(), persistentField.getName(), persistentField.getDescriptor() methodVisitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, persistentField.getDeclaringType().asErasure().getInternalName(), EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + persistentField.getName(), Type.getMethodDescriptor( Type.getType( persistentField.getDescriptor() ) ),
@Override protected void fieldWrite(MethodVisitor methodVisitor) { methodVisitor.visitFieldInsn( Opcodes.PUTFIELD, persistentFieldAsDefined.getDeclaringType().asErasure().getInternalName(), persistentFieldAsDefined.getInternalName(), persistentFieldAsDefined.getDescriptor() ); } }
@Override protected void fieldRead(MethodVisitor methodVisitor) { methodVisitor.visitFieldInsn( Opcodes.GETFIELD, persistentFieldAsDefined.getDeclaringType().asErasure().getInternalName(), persistentFieldAsDefined.getInternalName(), persistentFieldAsDefined.getDescriptor() ); }
@Override protected void fieldWrite(MethodVisitor methodVisitor) { methodVisitor.visitFieldInsn( Opcodes.PUTFIELD, persistentFieldAsDefined.getDeclaringType().asErasure().getInternalName(), persistentFieldAsDefined.getInternalName(), persistentFieldAsDefined.getDescriptor() ); } }
@Override protected void fieldRead(MethodVisitor methodVisitor) { methodVisitor.visitFieldInsn( Opcodes.GETFIELD, persistentFieldAsDefined.getDeclaringType().asErasure().getInternalName(), persistentFieldAsDefined.getInternalName(), persistentFieldAsDefined.getDescriptor() ); }
if ( persistentField.getDeclaringType().asErasure().equals( managedCtClass ) ) { methodVisitor.visitFieldInsn( Opcodes.GETFIELD, persistentField.getDeclaringType().asErasure().getInternalName(), persistentField.getName(), persistentField.getDescriptor() methodVisitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, persistentField.getDeclaringType().asErasure().getInternalName(), EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + persistentField.getName(), Type.getMethodDescriptor( Type.getType( persistentField.getDescriptor() ) ),