Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do package-level annotations apply to subpackages?

Tags:

java

If I have a tree of packages like so:

com.foo
com.foo.bar
com.foo.bar.baz

and then I add a package-info.java file in com.foo and add an annotation to the com.foo package, will the annotation also be applied to the children packages, com.foo.bar and com.foo.bar.baz (and so on)? Or will I need to make another package-info.java in each of them with the same annotations?

like image 548
Ricket Avatar asked Mar 01 '26 06:03

Ricket


1 Answers

The annotation is not applied to the "children" packages (by my experiment). But it might get implemented in higher versions of Java (see JEP 104)

like image 187
Jan Kl. Avatar answered Mar 03 '26 20:03

Jan Kl.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!