N
N
Nikolai Gerasimov2016-09-09 11:10:10
Java
Nikolai Gerasimov, 2016-09-09 11:10:10

Are annotations inherited in java?

There are two classes
First:

@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class Parent implements Serializable

Second: So, will the @JsonIgnoreProperties annotation be performed on the Child class?
public class Child extends Parent

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
artemsee, 2016-09-09
@GerNik

By default it will not be inherited. However, if the annotation is marked as Inherited , then it is inherited. Since most often annotations are not inherited, helpers can be used to search for annotations on a class and its parents, for example, the Spring Core library contains findAnnotations methods to search for specific annotations on a class (or its parents) or a method (or parent methods that are overridden by this method ).
Here is a good example explaining how Inherited works: tyrts .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question