@Entity
class Student{
@NotNull
private int sid;
@NotNull
private String sname;
private int age;
}
i have to show the name of the field that contain @NotNull annotation
I created a function
public boolean hasNotNull() {
return Arrays.stream(this.getClass().getDeclaredFields())
.anyMatch(field -> field.isAnnotationPresent(NotNull.class));
}
public Object[] getValue() {
if (hasNotNull())
return Arrays.stream(this.getClass().getDeclaredFields())
.filter(field -> field.isAnnotationPresent(NotNull.class)).toArray();
else
return null;
}
But I am getting the 500 Internal Server Error.
Following are the warnings:
WARNING: An illegal reflective access operation has occurred
WARNING: Please consider reporting this to the maintainers of com.fasterxml.jackson.databind.util.ClassUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
What should I do?