Your SlideShare is downloading. ×
Nantes Jug - Java 7
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Nantes Jug - Java 7

1,088
views

Published on

The slides I used for the Nantes JUG Java 7 session (november 3rd, 2011)

The slides I used for the Nantes JUG Java 7 session (november 3rd, 2011)

Published in: Technology, News & Politics

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,088
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1.  Sébastien Prunier › Architecte JEE chez Ovialis › Adepte des JUGs › Certifié Bonita OS @sebprunier gplus.to/sebprunier Java User Blog ! › sebprunier.wordpress.com
  • 2.  Relations avec des partenaires technologiques
  • 3.  19h – 21h (max) Pot offert par Ovialis http://www.xebia.fr/xebia-essentials
  • 4.  Ce soir nous allons donc parler de Java !
  • 5.  Refactoring de code Source : http://www.energizedwork.com
  • 6.  Sortie officielle de Java SE 7
  • 7.  JSR 334 – Project Coin › Evolutions du langage JSR 292 – InvokeDynamic › Support pour les langage dynamiques JSR 166 – Fork / Join › Programmation parallèle JSR 203 – NIO.2 › Nouvelles APIs Et d’autres petites nouveautés sympa !
  • 8.  Binary Literals Underscores in Numeric Literals String in switch Statements Multiple Catch and More Precise Rethrow Type Inference for Generics Instanciation Try-with-resource Statement Simplified Varargs Method Invocation
  • 9.  Avant // 213 int binarynumber = Integer.parseInt("11010101", 2); Après // 213 int binarynumber = 0b11010101;
  • 10.  Avant int bignumber = 45321589; Après int bignumber = 45_321_589; // 213 int binarynumber = 0b1101_0101;
  • 11.  Qui n’a pas essayé cela avant Java 7 ? String command = args[0]; switch (command) { case "start": MyApplication.start(); break; case "stop": MyApplication.stop(); break; default: // Manage error break; }
  • 12.  Objectif : factoriser ! try { // Database access stuff ... } catch (ClassNotFoundException | SQLException e) { System.err.println("Error during database access : " + e.getMessage()); } catch (Exception e) { System.err.println("Unexpected error !" + "Please contact the technical support"); }
  • 13.  Avant private void manageData() throws SQLException, IOException { // Database access, File access ... } public void myAction() throws Exception { try { manageData(); } catch (Exception e) { // your stuff here ! throw e; } }
  • 14.  Après private void manageData() throws SQLException, IOException { // Database access, File access ... } public void myAction() throws SQLException, IOException { try { manageData(); } catch (Exception e) { // your stuff here ! throw e; } }
  • 15.  Avant List<String> list = new ArrayList<String>(); Map<String, Integer> map = new HashMap<String, Integer>(); Map<String, List<BigDecimal>> map2 = new HashMap<String, Lis
  • 16.  Après List<String> list = new ArrayList<>(); Map<String, Integer> map = new HashMap<>(); Map<String, List<BigDecimal>> map2 = new HashMap<>();
  • 17.  ZE nouveauté ! Un réel intérêt : éviter des bugs bêtes try (BufferedReader reader = new BufferedReader(…)) { String line = reader.readLine(); while (line != null) { System.out.println(line); line = reader.readLine(); } } catch (IOException e) { System.err.println("Erreur : " + e.getMessage()); } finally{…} close()
  • 18.  java.lang.AutoCloseable public class MyResource implements AutoCloseable { ... @Override public void close() throws Exception { // Your stuff here ! } }
  • 19.  @SafeVarargs @SafeVarargs public static <T> void addToList(List<T> listArg, T... elements) { for (T x : elements) { listArg.add(x); } } Type safety: Potential heap pollution via varargs parameter elements
  • 20.  java.util.Objects 9 méthodes utilitaires sur les « Object » Un vrai + pour du code plus simple, plus lisible Deux exemple dans la démo : › Objects.toString() › Objects.hash()
  • 21. > javadoc -stylesheetfile MyStylesheet.css
  • 22.  Exemple de la copie de fichiers › java.nio.file.*FileSystem fs = FileSystems.getDefault();Path src = fs.getPath("/home", "source.txt");Path tgt = fs.getPath("/backup", "target.txt");Files.copy(src, tgt, StandardCopyOption.REPLACE_EXISTING);
  • 23.  Un peu de lecture si vous le souhaitez …http://groups.google.com/group/lescastcodeurs/msg/90ddf025c52a9412
  • 24.  Tirer parti des processeurs multiples API de programmation parallèle Voir aussi › Map / Reduce › Hadoop › GridGain
  • 25.  Approche très simpleif (my portion of the work is small enough) do the work directlyelse split my work into two pieces invoke the two pieces and wait for the results Démo !http://download.oracle.com/javase/tutorial/essential/concurrency/forkjoin.html
  • 26.  Collection Literals › Initialement dans Coin List<Integer> piDigits = [3, 1, 4, 1, 6, 5, 3, 5, 9]; Set<Integer> primes = { 2, 7, 31, 127, 8191, 131071}; Map<Integer, String> platonicSolids = { 4 : "tetrahedron", 6 : "cube", 8 : "octahedron", 12 : "dodecahedron", 20 : "icosahedron" };http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/001193.html
  • 27.  JSR 335 – Lamba Expressions › Closures › Fonctions anonymes x -> x + 1 (x) -> x + 1 (int x) -> x + 1 (int x, int y) -> x + y (x, y) -> x + yhttp://mail.openjdk.java.net/pipermail/lambda-dev/2011-September/003936.html
  • 28.  Modularité : Projet JIGSAWmodule-info.javamodule com.greetings @ 0.1 { requires jdk.base; // default to the highest available version requires org.astro @ 1.2; class com.greetings.Hello;} http://openjdk.java.net/projects/jigsaw/
  • 29.  Java 7 : Hands-On ! › Démo sur GitHub › https://github.com/sebprunier/nantesjug-java7 Java 8 : Watch ! › Sortie prévue été 2013 Java 9 …
  • 30.  Questions / Réponses