Annotations across modules
Alex Buckley
alex.buckley at oracle.com
Thu Nov 12 19:53:10 UTC 2015
On 11/12/2015 5:50 AM, Stephen Colebourne wrote:
> My understanding of annotations today is that annotations are not
> required at runtime. ie. if an annotation is placed into a class at
> compile time but the .class file for the annotation is not available
> on the runtime classpath. then there is no error.
>
> Does this change in any way with modules?
No.
> My specific case is wrt @ConstructorProperties which is in java.beans.
> In 9, a user may run my software without the java.beans module. Can I
> safely assume that if the annotation is available on the compile
> module path but not the runtime module path, everything will be OK
> (ie. no error)?
Yes, subject to assumptions that your software doesn't crash if it can't
get a Class object for the java.beans.ConstructorProperties annotation type.
The fact that the java.beans package is part of the huge java.desktop
module (due to unfortunate use of AWT types in Beans signatures) is the
reason why JMX recently introduced its own annotation type for
constructor properties (javax.management.ConstructorParameters). With an
eye on behavioral compatibility, some JMX spec work was needed to
account for when the @java.beans.ConstructorProperties annotation is
present but the java.beans.ConstructorProperties annotation type is not
available. See the discussion around JDK-7199353 at
http://mail.openjdk.java.net/pipermail/jmx-dev/2015-October/thread.html.
Alex
More information about the jigsaw-dev
mailing list