Documente Academic
Documente Profesional
Documente Cultură
&implicity matters
Ho& Java Evolves and )da(ts
'% the community( y the community( %or the community
.
.
8
J'/ 8 0 Pro(osed *ontent
8
8
Language
1
1
Bi+ 'isclai$er
"he synta) used in the
%ollowing slides may
change
-a$2da E3(ressions I
Closures and Functional Programming
* Lamda e)pressions provide anonymous %unction types to Java
* "hey replace the use o% single astract method types +&AM,
* "hey are !ust instances o% Runnale
Argument List Arrow "o-en .ody
+int )( int y, /0 ) 1 y
Synta3
+a, A single e)pression2 ody is evaluated and result value returned3
+, &tatement loc-2 ody is evaluated as a method ody and #return$ statement
returns control to the caller3
.ody can e2
-a$2da E3(ressions II
Closures and Functional Programming
Runnable r = () ->
{ System.out.println( "I'm a Runnable!" ); };
r.run();
jbutton.addActionListener(
e -> { System.out.println( "Clicked" ); } );
* n -> n % 2 != 0;
* (char c) -> c == 'y';
* (x, y) -> x + y;
* (int a, int b) -> a * a + b * b;
* () -> { return 3.14 };
* (String s) ->
{ System.out.println(s); };
* "ype o% parameters can e e)plicitly declared or ta-en %rom conte)t3
* Argument parenthesis are optional when there is only one and its type
can e in%erred3
* Argument List can e empty( i% it is so( parenthesis must e)ist3
* 4% ody has more that one statement( then curly races are needed3
-a$2da E3(ressions III
Closures and Functional Programming
E3tension 4et#ods
.ringing Multiple 4nheritance to Java
*
Provide a mechanism to add new methods to e)isting inter%aces
* 5ithout rea-ing ac-wards compataility
* 6ives Java multiple inheritance
(u2lic inter"ace Set<T> e3tends *ollection<T>
5
(u2lic int si6e()7
88 999 T#e rest o" t#e e3istin+ Set $et#ods
(u2lic T reduce( :educer<T> r ) de"ault *ollections9<T>set:educer7
;
)nnotations on Java Ty(es
public void process(@notnull List data) {}
* Annotations can currently only e used on type declarations
* Classes( methods( variale de%initions
* E)tension %or places where types are used
* e3g3 Parameters
* Permits error detection y pluggale type chec-ers
* e3g3 null pointer errors( race conditions( etc
)ccess to Para$eter <a$es at :unti$e
* Mechanism to retrieve parameter names o% methods and
constructors
* At runtime via core re%lection
*
4mproved code readaility
* Eliminate redundant annotations
* 4mprove 47E capailities
* Auto/generate template code
S$all T#in+s
* Repeating annotations
Multiple annotations with the same type applied to a single program element
* 8o more apt tool and associated AP4
Complete the transition to the J&R 9:9 implementation
* 7oc"ree AP4
Provide access to the syntactic elements o% a !avadoc comment
* 7ocLint tool
;se 7oc"ree AP4 to identi%y asic errors in !avadoc comments
* Javadoc support in javax.tools
4nvo-e !avadoc tools %rom AP4 as well as command line<e)ec
Lirary
*oncurrency =(dates
* &calale update variales