On Thu, Jun 8, 2017 at 12:19 PM, Gary Gregory <garydgreg...@gmail.com>
wrote:

> > 3. JDK9 adds some extra parameters to the Deprecated annotation (most
> notably  forRemoval=true, which is used to indicate that the annotated item
>  is really really deprecated.)   It's not needed in this case, but is
> worth thinking about  when jdk9 is eventually released (latest schedule
> change : from 7/27/2017 to 9/21/2017).
>
> I do not think we plan on making Java 9 a requirement for any current
> project.


I just double checked, and it does seem that the jdk-9 dependency is at
library compile time.  Compiling a class with an enhanced deprecation
annotation, using the jdk-9 compiler, but with source & target 1.8, and
then compiling another class that uses the deprecated class works, and
gives the expected messages.

Using -Xlint:deprecation shows the detailed deprecation warning.  Using
plain -Xlint adds some extra warnings about the ignored annotation bits
which require -Xlint:-classfile to disable.

Compiling the second class with jdk9 issues the new "removal" warning (with
-Xlint:-removal required to downgrade the warning to a note).

None of this is particularly urgent, but if/when jdk9 is released, it might
be worth considering

Simon

ses@snarkive$ javac -version
*javac 1.8.0_131*

ses@snarkive$ javac  -cp build/classes/main depup/src/EyeOfTheWeasel.java
*Note: depup/src/EyeOfTheWeasel.java uses or overrides a deprecated API.*
*Note: Recompile with -Xlint:deprecation for details.*

ses@snarkive$ javac -Xlint:deprecation -cp build/classes/main
depup/src/EyeOfTheWeasel.java
*depup/src/EyeOfTheWeasel.java:7: warning: [deprecation] Weasel in unnamed
package has been deprecated*
*        Weasel.main(new String[] {"UTF-8"});*

ses@snarkive$ javac -Xlint -cp build/classes/main
depup/src/EyeOfTheWeasel.java
*build/classes/main/Weasel.class: warning: Cannot find annotation method
'since()' in type 'Deprecated'*
*build/classes/main/Weasel.class: warning: Cannot find annotation method
'forRemoval()' in type 'Deprecated'*
*depup/src/EyeOfTheWeasel.java:7: warning: [deprecation] Weasel in unnamed
package has been deprecated*
*        Weasel.main(new String[] {"UTF-8"});*
*        ^*
*3 warnings*

ses@snarkive$ javac -Xlint  -Xlint:-classfile -cp build/classes/main
depup/src/EyeOfTheWeasel.java
depup/src/EyeOfTheWeasel.java:7: warning: [deprecation] Weasel in unnamed
package has been deprecated
        Weasel.main(new String[] {"UTF-8"});
        ^
1 warning

ses@snarkive$ java  -cp build/classes/main/:depup/src/:build/classes
EyeOfTheWeasel
Emoji Lovin' Hippies!
annotation = @java.lang.Deprecated()

ses@snarkive$ /usr/lib/jvm/openjdk-9-internal/bin/javac  -cp
build/classes/main depup/src/EyeOfTheWeasel.java
*depup/src/EyeOfTheWeasel.java:7: warning: [removal] Weasel in unnamed
package has been deprecated and marked for removal*
*        Weasel.main(new String[] {"UTF-8"});*
*        ^*
*1 warning*

Reply via email to