Showing posts with label java 9. Show all posts
Showing posts with label java 9. Show all posts

6 December 2017

Java 9 @Deprecated

That is to say: Java 9 enhances Deprecated.

@Deprecated(forRemoval=true)

The @Deprecated annotation has a new parameter forRemoval (default: false).
If the parameter is true, the item will be removed in a future version, according to javadoc.
This used to be the meaning of Deprecated in the beginning (when it was still a javadoc tag), but Java never actually removed anything marked Deprecated AFAIK.
That is, until Java 9, where some items effectively got pruned, to avoid cyclic dependencies in the new module system (in java.beans.PropertyListener).
Oracle says that, for Java SE, the intend is that something marked with @Deprecated(forRemoval=true) in Java 10, will be gone in Java 11 (ouch).

Suppressing warnings

Deprecation warnings are also impacted.
You can surpress compiler deprecation warnings with @SuppressWarnings(“deprecation”) in your code.
This does not work for imports, but that is a bug that is (finally) solved in Java 9.
On the other hand, In Java 9 the @SuppressWarnings(“deprecation”) will not work for @Deprecatedor(forRemoval=true). And rightfully so, given that people suppress the warnings because they assume nothing is going away any time soon.
 In Java 9, to suppress forRemoval=true warnings, use  @SuppressWarnings(“removal”).
To suppress both forRemoval=false and forRemoval=true, use @SuppressWarnings("deprecation", “removal”).



2 February 2016

Java plugin deprecated in Java9

With Java9 the java web plugin will be discontinued. Browsers like Microsoft Edge are removing plugin support, so this is a logical step.
Java's origins are in embedded execution, running applets in the browser, using the plugin.
Oracle has a whitepaper with migration options.

19 August 2015

Java 9 JShell


Jshell (developed in project Kulla) is a java shell allowing you to type java instructions at the shell prompt and have them executed.

  • if jshell detects a complete statement even without a closing semicolon
  • you can type an expression which will be evaluated 
-> 2 + 2
| Expression value is: 4
| assigned to temporary variable $1 of type int
  • you are not obliged to catch exceptions
  • you can save and load your command history
  • you can use methods and references that will only be defined later
-> double volume(double radius) {
>> return 4.0 / 3.0 * PI * cube(radius);
>> }
| Added method volume, however, it cannot be invoked until method cube(double), and variable PI
are declared
  • you can list current variables, methods...
  •  tab completion as you type
Here's a small tutorial.