Constructor getAnnotatedReceiverType() method in Java with Examples Last Updated : 25 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The getAnnotatedReceiverType() method of a Constructor class is used to return an AnnotatedType object that represents the AnnotatedType to specify the receiver type of this constructor. If the constructor has a receiver parameter then The receiver type of a constructor is available. If this constructor either has no receiver parameter or has a receiver parameter with no annotations on its type, then the return value is an AnnotatedType object representing an element with no annotations. If this constructor is a top-level static member then the return value is null. Syntax: public AnnotatedType getAnnotatedReceiverType() Parameters: This method accepts nothing. Return value: This method returns an object of AnnotatedType representing the receiver type of the method or constructor represented by this Executable or null if this Executable can not have a receiver parameter. Below programs illustrate the getAnnotatedReceiverType() method: Program 1: Java // Java program to demonstrate // Constructor.getAnnotatedReceiverType() method import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.AnnotatedType; import java.lang.reflect.Constructor; public class GFG { public static void main(String[] args) throws NoSuchMethodException { // create a constructor class Constructor<?> c = Test.class.getConstructors()[0]; // apply getAnnotatedReceiverType() AnnotatedType atr = c.getAnnotatedReceiverType(); // print result System.out.println(atr); System.out.println("Type = " + atr.getType().getTypeName()); } } class Test { public Test(@Annotation Test test) {} } @Target({ ElementType.TYPE_USE }) @Retention(RetentionPolicy.RUNTIME) @interface Annotation { } Output: sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl@12a3a380 Type = Test Program 2: Java // Java program to demonstrate // Constructor.getAnnotatedReceiverType() method import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.AnnotatedType; import java.lang.reflect.Constructor; public class GFG { public static void main(String[] args) throws NoSuchMethodException { // create a constructor class Constructor<?> c = Demo.class.getConstructors()[0]; // apply getAnnotatedReceiverType() AnnotatedType atr = c.getAnnotatedReceiverType(); // print result System.out.println(atr); System.out.println("Type = " + atr.getType().getTypeName()); } } class Demo { public Demo(@PathVar String str) {} } @Target({ ElementType.TYPE_USE }) @Retention(RetentionPolicy.RUNTIME) @interface PathVar { } Output: sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl@12a3a380 Type = Demo References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Constructor.html#getAnnotatedReceiverType() Comment More infoAdvertise with us Next Article Constructor getName() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Constructors Java-Functions java-lang-reflect-package Practice Tags : Java Similar Reads Constructor getAnnotatedReturnType() method in Java with Examples The getAnnotatedReturnType() method of a Constructor class is used to return an AnnotatedType object which represents AnnotatedType to specify return type of Constructor Object. The returned AnnotatedType represents implementation of AnnotatedType itself or any of its sub-interfaces like AnnotatedAr 2 min read Constructor getAnnotation() method in Java with Examples The getAnnotation() method of a Constructor class is used to get this constructor object annotation for the specified type if such an annotation is present, else null. Specified type is passed as parameter. Syntax: public <T extends Annotation> T getAnnotation(Class<T> annotationClass) P 2 min read Constructor getName() method in Java with Examples The constructor class provides information about a single constructor for a class and it also provides access to that constructor. The getName() method of java.lang.reflect.Constructor is used to return this constructor name, as a string. Constructor name is the binary name of the constructor's decl 1 min read Constructor getDeclaredAnnotations() method in Java with Examples The getDeclaredAnnotations() method of java.lang.reflect.Constructor class is used to return annotations present on this Constructor element as an array of Annotation class objects. The getDeclaredAnnotations() method ignores inherited annotations on this constructor object.Returned array can contai 2 min read Constructor getParameterAnnotations() method in Java with Examples The getParameterAnnotations() method of a Constructor class is used to get a two-dimensional Annotation array that represent the annotations on the formal parameters of this Constructor. If the Constructor contains no parameters, an empty array will be returned. If the Constructor contains one or mo 2 min read Class getAnnotatedInterfaces() method in Java with Examples The getAnnotatedInterfaces() method of java.lang.Class class is used to get the superinterface type annotations present in this class. The method returns an array of annotations present. Syntax: public Annotation[] getAnnotatedInterfaces() Parameter: This method does not accepts any parameter.Return 2 min read Like