/** * {@inheritDoc} */ public String getDescriptor() { return delegate.getDescriptor(); }
/** * Returns the method descriptor of this method type representation. * * @return The method descriptor of this method type representation. */ public String getDescriptor() { StringBuilder stringBuilder = new StringBuilder("("); for (TypeDescription parameterType : parameterTypes) { stringBuilder.append(parameterType.getDescriptor()); } return stringBuilder.append(')').append(returnType.getDescriptor()).toString(); }
/** * {@inheritDoc} */ public String getDescriptor() { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < arity; i++) { stringBuilder.append('['); } return stringBuilder.append(componentType.getDescriptor()).toString(); }
/** * Returns the method descriptor of this method handle representation. * * @return The method descriptor of this method handle representation. */ public String getDescriptor() { StringBuilder stringBuilder = new StringBuilder().append('('); for (TypeDescription parameterType : parameterTypes) { stringBuilder.append(parameterType.getDescriptor()); } return stringBuilder.append(')').append(returnType.getDescriptor()).toString(); }
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder().append('('); for (TypeDescription parameterType : parameterTypes) { stringBuilder.append(parameterType.getDescriptor()); } return stringBuilder.append(')').append(returnType.getDescriptor()).toString(); } }
/** * {@inheritDoc} */ public String getName() { String descriptor = componentType.getDescriptor(); StringBuilder stringBuilder = new StringBuilder(descriptor.length() + arity); for (int index = 0; index < arity; index++) { stringBuilder.append('['); } for (int index = 0; index < descriptor.length(); index++) { char character = descriptor.charAt(index); stringBuilder.append(character == '/' ? '.' : character); } return stringBuilder.toString(); }
/** * {@inheritDoc} */ public Object asConstantPoolValue() { StringBuilder stringBuilder = new StringBuilder().append('('); for (TypeDescription parameterType : getParameterTypes()) { stringBuilder.append(parameterType.getDescriptor()); } return Type.getMethodType(stringBuilder.append(')').append(getReturnType().getDescriptor()).toString()); }
/** * {@inheritDoc} */ public String getDescriptor() { StringBuilder descriptor = new StringBuilder().append('('); for (TypeDescription parameterType : getParameters().asTypeList().asErasures()) { descriptor.append(parameterType.getDescriptor()); } return descriptor.append(')').append(getReturnType().asErasure().getDescriptor()).toString(); }
/** * {@inheritDoc} */ public String getDescriptor() { return getType().asErasure().getDescriptor(); }
/** * {@inheritDoc} */ public Object asConstantPoolValue() { StringBuilder stringBuilder = new StringBuilder().append('('); for (TypeDescription parameterType : getParameterTypes()) { stringBuilder.append(parameterType.getDescriptor()); } String descriptor = stringBuilder.append(')').append(getReturnType().getDescriptor()).toString(); return new Handle(getHandleType().getIdentifier(), getOwnerType().getInternalName(), getName(), descriptor, getOwnerType().isInterface()); }
/** * Tries to append a given annotation by reflectively reading an annotation. * * @param annotation The annotation to be written. * @param visible {@code true} if this annotation should be treated as visible at runtime. * @param annotationValueFilter The annotation value filter to apply. */ private void doAppend(AnnotationDescription annotation, boolean visible, AnnotationValueFilter annotationValueFilter) { handle(target.visit(annotation.getAnnotationType().getDescriptor(), visible), annotation, annotationValueFilter); }
/** * Tries to append a given annotation by reflectively reading an annotation. * * @param annotation The annotation to be written. * @param visible {@code true} if this annotation should be treated as visible at runtime. * @param annotationValueFilter The annotation value filter to apply. * @param typeReference The type annotation's type reference. * @param typePath The type annotation's type path. */ private void doAppend(AnnotationDescription annotation, boolean visible, AnnotationValueFilter annotationValueFilter, int typeReference, String typePath) { handle(target.visit(annotation.getAnnotationType().getDescriptor(), visible, typeReference, typePath), annotation, annotationValueFilter); } }
/** * Returns a constant {@code null} value of type {@link Object}. * * @return A dynamically resolved null constant. */ public static Dynamic ofNullConstant() { return new Dynamic(new ConstantDynamic("nullConstant", TypeDescription.OBJECT.getDescriptor(), new Handle(Opcodes.H_INVOKESTATIC, CONSTANT_BOOTSTRAPS, "nullConstant", "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;", false)), TypeDescription.OBJECT); }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, METHOD_HANDLE, type.getMethodName(), methodDescription.isStatic() || methodDescription.isConstructor() ? methodDescription.getDescriptor() : "(" + methodDescription.getDeclaringType().getDescriptor() + methodDescription.getDescriptor().substring(1), false); int parameterSize = 1 + methodDescription.getStackSize(), returnValueSize = methodDescription.getReturnType().getStackSize().getSize(); return new Size(returnValueSize - parameterSize, Math.max(0, returnValueSize - parameterSize)); } }
/** * {@inheritDoc} */ public SignatureVisitor onNonGenericType(Generic typeDescription) { if (typeDescription.isArray()) { typeDescription.getComponentType().accept(new ForSignatureVisitor(signatureVisitor.visitArrayType())); } else if (typeDescription.isPrimitive()) { signatureVisitor.visitBaseType(typeDescription.asErasure().getDescriptor().charAt(ONLY_CHARACTER)); } else { signatureVisitor.visitClassType(typeDescription.asErasure().getInternalName()); signatureVisitor.visitEnd(); } return signatureVisitor; }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { if (implementationContext.getClassFileVersion().isAtLeast(ClassFileVersion.JAVA_V5) && typeDescription.isVisibleTo(implementationContext.getInstrumentedType())) { methodVisitor.visitLdcInsn(Type.getType(typeDescription.getDescriptor())); } else { methodVisitor.visitLdcInsn(typeDescription.getName()); methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;", false); } return SIZE; } }
/** * Returns a {@link Enum} value constant. * * @param enumerationDescription The enumeration value to represent. * @return A dynamically resolved enumeration constant. */ public static JavaConstant ofEnumeration(EnumerationDescription enumerationDescription) { return new Dynamic(new ConstantDynamic(enumerationDescription.getValue(), enumerationDescription.getEnumerationType().getDescriptor(), new Handle(Opcodes.H_INVOKESTATIC, CONSTANT_BOOTSTRAPS, "enumConstant", "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Enum;", false)), enumerationDescription.getEnumerationType()); }
@Override protected void fieldRead(MethodVisitor methodVisitor) { methodVisitor.visitMethodInsn( Opcodes.INVOKESPECIAL, managedCtClass.getSuperClass().asErasure().getInternalName(), EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + persistentFieldAsDefined.getName(), Type.getMethodDescriptor( Type.getType( persistentFieldAsDefined.getType().asErasure().getDescriptor() ) ), false ); }
@Override protected void fieldRead(MethodVisitor methodVisitor) { methodVisitor.visitMethodInsn( Opcodes.INVOKESPECIAL, managedCtClass.getSuperClass().asErasure().getInternalName(), EnhancerConstants.PERSISTENT_FIELD_READER_PREFIX + persistentFieldAsDefined.getName(), Type.getMethodDescriptor( Type.getType( persistentFieldAsDefined.getType().asErasure().getDescriptor() ) ), false ); }
@Override protected void fieldWrite(MethodVisitor methodVisitor) { methodVisitor.visitMethodInsn( Opcodes.INVOKESPECIAL, managedCtClass.getSuperClass().asErasure().getInternalName(), EnhancerConstants.PERSISTENT_FIELD_WRITER_PREFIX + persistentFieldAsDefined.getName(), Type.getMethodDescriptor( Type.getType( void.class ), Type.getType( persistentFieldAsDefined.getType().asErasure().getDescriptor() ) ), false ); } }