For inspecting the annotations of the superclass, we need to call the getAnnotatedSuperclass() method:
This method returns the superclass type that is annotated:
Class<Melon> clazz = Melon.class;
AnnotatedType superclassType = clazz.getAnnotatedSuperclass();
And let's get some information as well:
// modern.challenge.Cucurbitaceae
System.out.println("Superclass type: "
+ superclassType.getType().getTypeName());
// [@modern.challenge.Family()]
System.out.println("Annotations: "
+ Arrays.toString(superclassType.getDeclaredAnnotations()));
System.out.println("@Family annotation present: "
+ superclassType.isAnnotationPresent(Family.class)); // true