On 10/09/2015 02:30 PM, Jaroslav Bachorik wrote:
To answer my question: "How is one supposed to compile an MXBean that
would work in JDK8- and at the same time in JDK9+ without java.desktop
in the module graph?"
Annotate the constructor with the both the @j.b.CP and the new @CP. In
JDK 9 the new @CP will be picked and in JDK 8 the mapper will utilize
@j.b.CP.
In that case, new @CP would have to be backported to JDK8u right?
Nope. As Alan pointed out an annotation with an unrecognized type is
simply ignored. And this would work fine for this purpose - in JDK 8
the new @CP will be ignored while @j.b.CP will be used to identify the
constructor for reconstruction.
Sorry, but I must be missing something.
When you compile a class (not an MXBean as Daniel pointed out, but a
data object class) with JDK9, it can't be used on JDK8 because of class
file version.
When you compile a class with JDK8, it can't contain new @CS annotation,
because it is not part of the official Java SE API on the Java 8 platform.
So I still don't see how one could compile a data class so that it could
be used on JDK8 as well as on JDK9 without java.desktop module?
Regards, Peter