RFR 7199353: Allow ConstructorProperties annotation from any package
jaroslav.bachorik at oracle.com
Mon Oct 12 07:49:47 UTC 2015
On 9.10.2015 17:36, Peter Levart wrote:
> 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
>>> 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?
Compile the annotated class using JDK 9 javac and specifying '-target 8
-source 8'. When running on Java 8 the java.desktop module will be
required (as is the case now) and when running on Java 9 the new @CP
will work (and java.desktop will not be required).
> Regards, Peter
More information about the jigsaw-dev