SI-4788 Respect RetentionPolicy of Java annotations

Also closes SI-5420 and SI-5948.
What's the difference?